Scenario 4
Rob is a CRM developer in an organization; he comes across a requirement that needs him to deactivate the Contact
form if the parent account status is inactive. He figures he can use JavaScript to solve this problem. We will make a Web API call for the account to check its status and then deactivate the form using a JavaScript function.
First, we will retrieve the statuscode
field of the parent account. Then, we need to check if the status of the parent is inactive; if yes, then we need to deactivate the form. We will write a JavaScript function for this. The whole process is shown in the following code:
function checkAccountStatus() { //Fetch parent account var accountAttribute = Xrm.Page.getAttribute("parentcustomerid"); var accountId; //Check if account is not null if (accountAttribute != null) { //Get value of account attribute accountId = accountAttribute.getValue(); if (accountId != null) { //Gets the account Id accountId = accountId...