-
-
Save furkankaracan/98502f425de0c190fe8c0856778eca9e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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