In CRM it is common that showing different forms to different user gropus. There might be some conditions that you check to switch and show different forms to users. For cases like these, formSelector() and navigate() functions save the day.
formselector.items collection: A list of all the forms accessible to the current user. Only those forms that share an association with one of the user’s security roles are available in this collection. It is useful to check if the user has access when switching between forms
formItem = formContext.ui.formSelector.items.get(arg);
- formselector.getCurrentItem method: Returns the GUID of the form currently being shown. When only one form is available this method will return null.
formItem = formContext.ui.formSelector.getCurrentItem();
Check the below code for full implementation.