crm 2011 xrm.page.getattribute returns null when there is value

浪子不回头ぞ 提交于 2019-12-04 19:18:30

You need to use getValue to return the value in the field. Your code is merely checking that the field exists on the Page.

You also need to be aware that in Create mode, these values are not set, so you can't retrieve them. In Update mode they will work. So you need to check that the Page is in Update mode too:

var formType = Xrm.Page.ui.getFormType();

if (formType === 2) // Update
{
    var creationDate = Xrm.Page.getAttribute(creationDateName).getValue();
}

it gives you the attribute not the value..

to get the value you have to write code as below

var creationDateAttr = Xrm.Page.getAttribute(creationDateName);
var valueDateAttr=creationDateAttr.getValue();

OR

var creationDateAttrValue = Xrm.Page.getAttribute(creationDateName).getValue();

hope this will help

Silly me, I forgot to add the field I was looking for that's why it return null but thanks to Donal for the answer, actually I was trying to verify if the field was full or was null. Thanks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!