formContext.ui.formSelector(Client API reference)|used case[Set From based on optionset value in UCI]

Hello Folks,

Is it not a good learning experience,where you do relative comparison? I wrote a JavaScript to understand how formContext.ui.formSelector and its sub property work completely.

Please, take a look on high level overview of formContext.ui.formSelector which is tabulated below.

Scenario: I took the scenario where will set entity form based on option set value.This scenario covers ui.formselector entirely, likewise as:

  1. formContext.ui.formSelector.items.get();
  2. formContext.ui.formSelector.getCurrentItem.getId();
  3. formContext.ui.formSelector.getCurrentItem.getLabel();
  4. formContext.ui.formSelector.getCurrentItem.navigate();

Implementation: Find the code snippet below:

var formContext;
function setForm(executionContext)
formContext = executionContext.getFormContext();
if (formContext.ui.getFormType()==2)
var caseType = formContext.getAttribute(logicalname).getValue();
case 1:
case 2:
changeForm(“Trial Order”);
changeForm(“Case for Interactive experience”);

function changeForm(formName)
var currentForm = formContext.ui.formSelector.getCurrentItem();
var availableForms = formContext.ui.formSelector.items.get();
if (currentForm.getLabel().toLowerCase() != formName.toLowerCase())
for (var i in availableForms)
var form = availableForms[i];
// to find a form based on the name
if (form.getLabel().toLowerCase() == formName.toLowerCase())
return true;

Call this function on page load event and make sure that this code is present on all other forms.

Testing: I am creating case record from default case form by putting up case type as Trial order.Once record is saved.It will navigate screen to trial order case form and have similar behavior for claims case form too.

Hope it is informative! 🙂 Keep dynamics-power with you.

One thought on “formContext.ui.formSelector(Client API reference)|used case[Set From based on optionset value in UCI]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s