Preventing Users from Deleting Calendar Items and Activities According to Conditions
The configuration that Siebel 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, Siebel 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.re
s_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 Siebel CRM Desktop displays in the day for 6/30/2012 in the calendar. Siebel CRM Desktop then displays the activity form for this activity. This activity form is similar to a typical Outlook calendar entry. 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 Siebel 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 entry, 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; } } }