Hi CRMers,
Thanks for reading my issue.
Environments:
CRM 2013 On Premise, Ribbon Button, Lookup on focus
Functionality:
We have custom Ribbon button. We also have a user lookup (Requester) which is a required field.
On click of ribbon button event handler, call a custom function in JavaScript, which changes some attributes and SAVE the form.
Issue:
We want to check the user lookup value (required field) before doing anything in ribbon button event handler function. But unfortunately when we are checking the value for user lookup, returns previous value, suppose to return null .
Reason for this behavior is, lookup has still focus but if user clicks outside of this lookup and click ribbon button, then fields returns null in event handler function.
Your suggestions:
So when user removes the user look up value ( the focus is still on user lookup), and tries to click ribbon button, is there any way can we get lookup value as null instead of previous value in JavaScript?
here is the code, it gives previous value, instead of null.
var inputType = Xrm.Page.getControl(fieldName).getControlType();
if (getText)
return Xrm.Page.getAttribute(fieldName).getValue()[0].id;
else
return Xrm.Page.getAttribute(fieldName).getValue()[0].name;
Thanks in advance for your support.