简体   繁体   中英

Unlocking CRM 2011 Field with JavaScript only if creating new contact/account

I know there's JavaScript to unlock a field in CRM 2011, but I only want to unlock those fields on 'new' account and contact forms. Existing contacts/accounts should always have locked fields. The reason for this is because we will be having integration set up with another system, but if a rep needs to manually enter a new contact/account, we want them to have that ability.

Your looking for the Xrm.Page.ui.getFormType() method .

In your case you'll check if the current FormType equals 1 (Create):

onLoad: function () {
    var ft = Xrm.Page.ui.getFormType();

    if (ft === 1) {
        // unlock your attributes here
    }    
}

Thanks Filburt. That's exactly what I needed. I used the following code under the onload section:

{
var ft = Xrm.Page.ui.getFormType();
if (ft == 1) 
{
Xrm.Page.getControl("new_universalid").setDisabled(true); 
} 
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM