简体   繁体   中英

JavaScript displaying word “null” in CRM 2011 fields w/ no value

I am using the following code to remove commas from an integer (whole number) field in CRM 2011:

function Form_onload() { document.getElementById("new_universalid").value =Xrm.Page.data.entity.attributes.get("new_universalid").getValue(); }

The issue is that for any accounts/contacts w/out a value for 'new_universalid', it's displaying the word "null".

My goal is to display a blank field, rather than the word NULL.

Thanks in advance for any suggestions.

The simplest way I can explain it and that is most obvious to understand is as follows, simply check to make sure the value is not null before assigning:

function Form_onload()
{
    var new_uid=Xrm.Page.data.entity.attributes.get("new_universalid").getValue();
    if(new_uid != null){
        document.getElementById("new_universalid").value = new_uid;
    }
}

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