I want to create a copy of status column to another column using js script in dynamics 365 when we click on button on select of record
I have two tables "Pre Approval Header" and "Claim Header" , once record is created in Pre Approval Header table , i want to copy two fields Primary column and status to the Claim header table using JS script.
Image may be NSFW.
Clik here to view.
When i click on "Claim Create" button i added using ribbon workbech, it will create new record in Claim header
Image may be NSFW.
Clik here to view.'
Image may be NSFW.
Clik here to view.
In Claim header table, i was able to copy the Primary column "Pre approval Refrence" to the Cliam header table, but status column is not copied.
want to know, how to copy status column too, below is the code i used to copy Primary column " Pre approval refrence"
function enableclaimcreate(SelectedControl)
{
var returnflag = true;
return returnflag;
}
function onclickinitiateClaim(SelectedControl)
{
var selectedRow = SelectedControl.getGrid().getSelectedRows().get(0).getData().getEntity();
selectedRow._attributes._collection.cs_claimcreationinitiate.setValue(true);
var entityFormOptions = {};
entityFormOptions["formId"] = "1533E4B3-5087-ED11-81AD";
entityFormOptions["entityName"] = "cs_claimrecordheader";
entityFormOptions["windowPosition"] = 1;
entityFormOptions["navbar"] = "entity";
// Set default values
var formParameters = {};
formParameters["cs_preapprovalreference"]=selectedRow.getEntityReference(); //cs_preapprovalreference is Pre approval refrence column in Claim header table
Xrm.Navigation.openForm(entityFormOptions, formParameters).then(
function (success) {
console.log(success);
},
function (error) {
console.log(error);
});
}
Tried adding below code to above to update status but it didnt work:
var formContext = executionContext.getFormContext();
var ApprovalStaus = formContext.getAttribute("statuscode").getValue(); //statuscode is column name of Pre Approval Header table
formContext.getAttribute("cs_claimstatus").setValue(ApprovalStaus); // cs_claimstatus is column name of claim Header table.