Pages

Tuesday, 27 December 2022

Client Scripting reference powerapps

  1. Get formcontext from execution Context


var formContext = executionContext.getFormContext();


  1. Show/Hide field


//Show

formContext.getControl("fieldname").setVisible(true);


//Hide

formContext.getControl("fieldname").setVisible(false);


  1. Set requirement level


//required

formContext.getAttribute("fieldname").setRequiredLevel("required");


//recommended

formContext.getAttribute("fieldname").setRequiredLevel("recommended");


//Optional

formContext.getAttribute("fieldname").setRequiredLevel("none");


  1. Set enable/disable field

//Disbale

formContext.getControl("fieldname").setDisabled(true);


// Set field enable

formContext.getControl("fieldname").setDisabled(false);



  1. Show/Hide tab

//show tab

var tab1 = formContext.ui.tabs.get("tabname");

tab1.setVisible(true);


// Hide tab

var tab2 = formContext.ui.tabs.get("tabname");

tab2.setVisible(false);



Get or Update fields on form using JavaScript in Dynamics 365 v9

After Microsoft released v9.0 of Microsoft Dynamics 365, Xrm.page became deprecated that it have been replaced by ExecutionContext.getFor...