Siebel CRM Desktop for Microsoft Outlook Administration Guide > Customizing Siebel CRM Desktop > Customizing UI Behavior >

Preventing Users from Deleting Records According to Conditions


This topic describes how to configure Siebel CRM Desktop to prevent the user from deleting records in the client according to a condition. For example, not allowing the user to delete an opportunity if the Status is Pending. The delete button in the client is a native Outlook button that you cannot disable. Instead, you can modify the code that runs if the user clicks Delete.

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 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

  1. 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_confirmation_message"),ctx.session.res_string("msg_delete_exclude_confirmation_caption"), 0x123))

    {

    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_confirmation_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 CRM Desktop from displaying multiple dialog boxes.

    For more information, see Customizing Form Functions.

  2. 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

Preventing Users from Deleting Calendar Items and Activities According to Conditions

The configuration that CRM Desktop uses for activities and calendar items is different than the configuration it uses for contacts. Instead, the activity or calendar item uses the Event object in Outlook. This configuration allows the user to access an activity or calendar item in different ways.

For example, assume the user accesses the contact form. This form includes one activity, named Test Delete. Assume the user opens the activity form for Test Delete from the contact form and finds that Test Delete includes the following values:

  • Birthday Call in the Type field.
  • 6/30/2012 in the Start field.

At this point, CRM Desktop behavior is similar to other Siebel objects. To prevent the user from deleting an activity with a type of Birthday Call, you can add the following code, which is similar to how you handle delete prevention for most objects:

if (item["type_id"] == "Action" && item["Type"] == "Birthday Call")
{
ctx.ui.message_box(0,ctx.session.res_string("msg_cant_delete_item"),ctx.session.res_string("msg_cant_delete_item_caption"), 0x40);
action_ctx.cancel_action = true;
return;
}

However, the user can access this same activity from the Calendar. The user can drill down on the entry for this activity that CRM Desktop displays in the day for 6/30/2012 in the calendar. CRM Desktop then displays the activity form for this activity. This activity form is similar to a typical Outlook calendar appointment. The delete handler represents the activity with the typical following Outlook type, so the item variable now includes only the standard Outlook field:

type_id='Event'

You cannot use only the Siebel type field. Instead, if CRM Desktop receives an event through the event handler, then it gets the same object but as type_id='Action'. You then use the same code that you use in Preventing Users from Deleting Contacts According to Conditions to do the remaining conditional examination. You use the following code.

To prevent users from deleting calendar items and activities according to conditions

  • Use the following code:

    if (item["type_id"] == "Event")
    {
    // This is a standard calendar appointment, so we need to retrieve the Activity
    // Use the Id to retrieve the right object
    // Get id from the active object
    var intId = item["id"];
    if (intId != null)
    {
    // The id fields is an object and need to be converted
    intId = ctx.session.hexstring_to_id(ctx.session.id_to_hexstring(intId).substr(0, 200));
    // Setup a search spec to query for the Activity
    var filter = ctx.session.create_expression("PIMObjectId", "eq", intId);
    // Run the query
    var oAction = ctx.session.find_item("Action",filter);
    // If we have found the Activity then we can do the similar thing again.
    if (oAction && oAction["Type"] == "Birthday Call")
    {
    ctx.ui.message_box(0,ctx.session.res_string("msg_cant_delete_item"),ctx.session.r s_string("msg_cant_delete_item_caption"), 0x40);action_ctx.cancel_action = true;
    return;
    }
    }
    }

Siebel CRM Desktop for Microsoft Outlook Administration Guide Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Legal Notices.