Tuesday, May 11, 2010

CRM 4.0: Hiding Save Buttons

Recently had a client that wanted users to only "Save as Completed" activities. That had some users that thought Save & Close would actually "close" the activity. To alleviate the potential error, we decided to remove all Save buttons (Save, Save & Close, and Save and New) from the menu bar and file menu. Below is the code to do this.


var CRMFORMTYPE_CREATE = 1;
var CRMFORMTYPE_UPDATE = 2;
var CRMFORMTYPE_READONLY = 3;
var CRMFORMTYPE_DISABLED = 4;
var CRMFORMTYPE_QUICKCREATE = 5;
var CRMFORMTYPE_BULKEDIT = 6;

if(crmForm.FormType == CRMFORMTYPE_UPDATE)
{
var li = document.getElementsByTagName('LI');
var i = 0;
while(i < li.length)
{
if (li[i].getAttribute('id') == '_MIcrmFormSave' ||
li[i].getAttribute('id') == '_MIcrmFormSubmitCrmForm59truetruefalse' ||
li[i].getAttribute('id') == '_MBcrmFormSave' ||
li[i].getAttribute('id') == '_MBcrmFormSubmitCrmForm59truetruefalse')
{
li[i].outerHTML='';
}

if (li[i].getAttribute('id') == '_MIcrmFormSaveAndClose')
{
document.getElementById('_MIcrmFormSaveAndClose').style.display = "none";
}
if (li[i].getAttribute('id') == '_MBcrmFormSaveAndClose')
{
document.getElementById('_MBcrmFormSaveAndClose').style.display = "none";
}

//alert(li[i].getAttribute('title') + ' | ' + li[i].getAttribute('id'));
i = i + 1;
}
}

No comments:

Post a Comment