Hi everyone,
The following script is trigger on field change.
if I comment the line alert(""+projectTitleValue); then my variable projectTitleValue has the value before change and not after change. My script has no failure but don´t have the expected behavior. Do you have any idea why?
I´m a newbie with CRM customization and JavaScript. Thanks.
function onChange_Duplicate() { Xrm.Page.data.entity.save(); var projectTitle = Xrm.Page.getAttribute("eno_projecttitle_kd"); var projectTitleValue = projectTitle.getValue(); var serverUrl = Xrm.Page.context.getClientUrl(); var ODataPath = serverUrl + "/XRMServices/2011/OrganizationData.svc"; var retrieveResultProjectTitle = new XMLHttpRequest(); alert(""+projectTitleValue); if (projectTitleValue != null) { retrieveResultProjectTitle.open("GET", ODataPath +"/OpportunitySet?$select=eno_projecttitle_kd&$filter=eno_projecttitle_kd eq '"+projectTitleValue+"'",false); retrieveResultProjectTitle.setRequestHeader("Accept", "application/json"); retrieveResultProjectTitle.setRequestHeader("Content-Type", "application/json; charset=utf-8?"); retrieveResultProjectTitle.send('grant_type=client_credentials'); if (retrieveResultProjectTitle.readyState == 4) { if (retrieveResultProjectTitle.status == 200) { var retrieved = this.parent.JSON.parse(retrieveResultProjectTitle.responseText).d; var Result = retrieved.results; if (typeof Result !== "undefined") { var count = Result.length; if (count>1) { alert("There is already an entity with this Project Title"); } } } } } }
*This post is locked for comments