Preventing Users from Deleting Contacts According to Conditions
The example in this topic prevents the user from deleting any opportunity that includes a Status of Pending. You can configure Siebel CRM Desktop to handle all Siebel CRM objects that it stores in the Outlook Contact objectin the same way. This configuration applies to contacts, accounts, opportunities, and any other custom Siebel CRM object, such as service requests or call reports.The following variable provides access to the record data for these objects:
item
This example configures Siebel CRM Desktop to determine if an item of the correct type exists, such as a contact, account, or opportunity. It then determines if this object meets a condition. If the condition exists, then it cancels the delete.
To prevent users from deleting contacts according to conditions
Locate the following code:
var action = "cancel"; if (can_delete_all) { if (exclude_allowed) { switch (ctx.ui.message_box(0,ctx.session.res_string("msg_delete_exclude_confirmatio n_message"),ctx.session.res_string("msg_delete_exclude_confirmation_caption" ), 0x123)) {
Siebel CRM Desktop routes every delete to the siebel_item_delete function in the actions.js file. This function sets up the default delete behavior. You can modify the delete behavior in the following function:
this.execute
This function includes a section that starts with the following code:
var action = "cancel"; if (can_delete_all) { if (exclude_allowed) { switch (ctx.ui.message_box(0,ctx.session.res_string("msg_delete_exclude_confirmatio n_message"),ctx.session.res_string("msg_delete_exclude_confirmation_caption" ), 0x123))
This code displays delete confirmation to the user. You place the code that you modify before the siebel_item_delete function to prevent Siebel CRM Desktop from displaying multiple dialog boxes.
For more information, see Customizing Form Functions.
Add the following code before the code that you located in step 1:
if (item[“type_id”??] == “Opportunity”?? && item[“Status”??] ==“Pending”??) { // show a message to the users ctx.ui.message_box(0,ctx.session.res_string("msg_cant_delete_item"),ctx.session .res_string("msg_cant_delete_item_caption"), 0x40);// cancel the delete event action_ctx.cancel_action = true;// stop processing this function (otherwise the item might still get deleted) return; } End If