Skip to content

Instantly share code, notes, and snippets.

@furkankaracan
Last active October 16, 2022 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save furkankaracan/98502f425de0c190fe8c0856778eca9e to your computer and use it in GitHub Desktop.
Save furkankaracan/98502f425de0c190fe8c0856778eca9e to your computer and use it in GitHub Desktop.
function switchForm(executionContext) {
var mainFormId = "cf74c4d2-2696-4298-9166-e53d79a6bd07";
var alternativeFormId = "cf4fc8f1-08c6-4ae3-9dcf-45a11838a00a";
//Get formContext.
var formContext = executionContext.getFormContext();
//Get all the available forms for the current user.
var listOfAvailableForms = formContext.ui.formSelector.items.get();
//ID of the current form.
var currentFormId = formContext.ui.formSelector.getCurrentItem().getId();
var myAttribute = formContext.getAttribute("myAttribute").getValue();
//Checking if user has access to alternative form and the current form isn't the alternative.
if (myAttribute === 1 && currentFormId !== alternativeFormId) {
listOfAvailableForms.forEach(element => {
if (element.getId() === alternativeFormId) {
element.navigate();
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment