Hi Shalu,
If you are trying to access context information you can always add the below reference to your html web resource.
<script type="text/javascript" src="../ClientGlobalContext.js.aspx"></script>
Also if you want to make any changes to CRM entity records then always use Web Api. Please see the code below.
<script>
function Update(accountID){
var entity = {};
entity.accountcategorycode = 1;
var req = new XMLHttpRequest();
req.open("PATCH", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/accounts("+accountID+")", false);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function() {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 204) {
//Success - No Return Data - Do Something
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send(JSON.stringify(entity));
}
</script>
Import REST Builder Solution to your CRM organization and generate the above WEB API Request.
github.com/.../CRMRESTBuilder
Regards
AKHIL R