When passing primaryControl in Ribbon WorkBench we use it as executionContext and then get FormContext out of it.
But when same thing is done on UCI we get the Error getFormContext is not a function
We got this error in UCI and not in Legacy WebClient,
- We were Passing CRM Parameter PrimaryControl to Button in Ribbon workbench
- In JS we were getting FormContext from primaryControl(Executioncontext) which was working fine in the Legacy app
function readXML(primaryControl) { var formContext = null; if (primaryControl!== null) { formContext = primaryControl.getFormContext(); } } }
- But when same is called in UCI we get ” ” Script Error, Because here we need to treat primary control as formContext
So final change needed in Code is as below
function readXML(primaryControl) { var formContext = null; if (primaryControl!== null) { if (typeof primaryControl.getAttribute === 'function') { formContext = primaryControl; //called from the ribbon. } else if (typeof primaryControl.getFormContext === 'function' && typeof(primaryControl.getFormContext()).getAttribute === 'function') { formContext = primaryControl.getFormContext(); // most likely called from the form via a handler } } }