What function to unlink a record in the subpanel using backbone.js or any javascript?
Thanks,
Roland
What function to unlink a record in the subpanel using backbone.js or any javascript?
Thanks,
Roland
i am showing you same thing for Contact-Cases. like subpanel for contact of cases
navigate to Admin > Studio > {Parent Module} > Subpanels > Cases and make your changes. Once saved, Sugar will generate ./custom/modules/Cases/clients/<client>/views/subpanel-for-<link>/subpanel-for-<link>.php
which will be used for rendering the fields you selected.
For Delete/Unlink add rowaction like below
subpanel-for-<link>.php
<?php
$viewdefs['Cases']['base']['view']['subpanel-for-contacts-cases'] = array (
'panels' =>
array (
0 =>
array (
'name' => 'panel_header',
'label' => 'LBL_PANEL_1',
'fields' =>
array (
0 =>
array (
'label' => 'LBL_LIST_SUBJECT',
'enabled' => true,
'default' => true,
'name' => 'name',
'link' => true,
),
1 =>
array (
'label' => 'LBL_LIST_STATUS',
'enabled' => true,
'default' => true,
'name' => 'status',
),
2 =>
array (
'target_record_key' => 'account_id',
'target_module' => 'Accounts',
'label' => 'LBL_LIST_ACCOUNT_NAME',
'enabled' => true,
'default' => true,
'name' => 'account_name',
),
3 =>
array (
'label' => 'LBL_LIST_DATE_CREATED',
'enabled' => true,
'default' => true,
'name' => 'date_entered',
),
4 =>
array (
'name' => 'assigned_user_name',
'target_record_key' => 'assigned_user_id',
'target_module' => 'Employees',
'label' => 'LBL_LIST_ASSIGNED_TO_NAME',
'enabled' => true,
'default' => true,
),
),
),
),
'rowactions' =>
array (
'actions' =>
array (
0 =>
array (
'type' => 'rowaction',
'name' => 'delete_button',
'icon' => 'fa-trash-o',
'label' => 'LBL_DELETE_BUTTON',
'event' => 'list:deleterow:fire',
'acl_action' => 'edit',
'allow_bwc' => true,
),
1 =>
array (
'type' => 'rowaction',
'name' => 'edit_button',
'icon' => 'fa-pencil',
'label' => 'LBL_EDIT_BUTTON',
'event' => 'list:editrow:fire',
'acl_action' => 'edit',
'allow_bwc' => true,
),
2 =>
array (
'type' => 'unlink-action',
'icon' => 'fa-chain-broken',
'label' => 'LBL_UNLINK_BUTTON',
),
),
),
'type' => 'subpanel-list',
);
Hope this Helpful to you. let me know further.
Thanks
MSB
Hi Mehul Bhandari,
I already have a custom button in panel-top and i want to call a function that deletes a relationship of a record in the subpanel. I guess using app.api.call('delete', ... ). Or the opposite of getRelatedCollectio();
Thanks,
Roland
i have not tried but i think you can try JSGrouping for this .
Hi Roland,
Have a look at file ./clients/base/views/subpanel-list/subpanel-list.js
You would see warnUnlink and unlinkModel functions. You can mimic the same behavior in your customizations.
Hope this helps.
Best Regards
Tevfik Tümer
Developer Support Engineer
Hi Tevfik Tümer,
How can i achieve this? Lets say i have multiple records in the subpanel, i have a boolean field and i want to remove the record when the boolean of that record is unchecked. Once i click the custom panel-top button, it will unlink the unchecked record.
UPDATE: Never mind, i solved my problem.
Thanks,
Roland