Wednesday, April 25, 2012

How to force CRM Save after javascript update on form

If you made an update of the form on a disabled field in CRM 2011, after the Save button was pushed you realized that the information wasn't saved.


What you have to do is to set the field as "dirty",  so that CRM knows the field value has changed and should be submitted in the update of the record.  Meaning that you have to add also a javascript code so that change will be taken into the save of the form.


In CRM 4.0 this was done by:
crmForm.all.[fieldname].ForceSubmit = true;

In CRM 2011 this is done by:
Xrm.Page.getAttribute("new_field").setSubmitMode("always");

This should force CRM to include the field when updating the record instead of ignoring the update.

How to set Default Area for CRM 2011 user

If you want to change the default area for a Microsoft CRM Dynamics 2011 user, you can't do it by using the Options Menu from CRM 2011.

What you have to do is to modify the  organization database by using a sql script.

So if you want to make ‘Announcements’ as default page for all the users in that case just run this query under your organization database and after that reset IIS.

update UserSettingsBase set Homepagearea=’Workplace’,Homepagesubarea=’nav_news’

Refresh tab programmatically in CRM 2011 using javascript

In CRM 2011 if you want to refresh a tab in the entity form you have yo use some javascript code.

To do this you have to find the id of the tab. The ids are like: tab0Tab, tab1Tab...in order of appearence in the form.

So what you have to do is to create a javascript file in which to insert the following function:

function changeTab()
{var link=document.getElementById('tab0Tab');
link.onclick=function()
{
window.location.reload(true);
loadArea('areaForm');
crmForm.GetTab($get('tab0', crmForm), true);
}
}

And after that to insert the function on the OnLoad event of the page.

And that's it all. After that when you'll press on the tab you selected in the function the form will be refreshed.