Share / Unshare
The Share/UnShare Deluge task can be used in Form/Field action scripts to dynamically share or unshare an email address to all the Forms and Views in an application or to only specific Forms or Views in an application or to sections under which the Forms/Views are arranged. This feature enables the owner of an application to define roles and add logic to share the forms/views with users, based on the roles assigned. This makes it easy to share the application.
share <component-type>(<component name>, <email>);
- <component-type>- Refers to the level at which application is shared. It can have the following values:
- application - to share the entire application.
- page - to share all the forms and views arranged under a section/header.
- form - to share only a specific form.
- view - to share only a specific view.
- <component name> - Select the name of the application / form / view / page to be shared.
- <email> - Specify the email address to share the component. You can either specify an email address, for example, email@example.com or add a Deluge expression that will return an email address, as value. For example, input.emailid, where emailid is the name of a form field. The shared email ids will be listed under the Share tab.
Let us take the example of a simple Employee Management application to illustrate the usage of the share/unshare Deluge task. This application comprises of the following forms:
- Role Form - To enter the role names, for example, Team Member, Manager etc.,
- Basic Information Form - To enter the basic information of employees like Name, Email Id, Role etc. Here, the field Role is a lookup from the Role Form.
The following script is added to the on add -> on success block of the Employee form and will be executed when a new employee record is added to the database. It will dynamically share the employee email id to the forms/views based on his role. As per the script, the Views "My_Salary_View" and "My_Basic_Informaton" will be shared with all the employees where as the View "View_All_Salary" and "View_All_Basic_Information" can be accessed only by an employee whose role is "Manager".
// dynamically share the employee email id to the forms/views based on his role
share view("My_Salary_View", input.EmailId);
share view("My_Basic_Informaton", input.EmailId);
if (input.Role == "Manager")
share view("View_All_Salary", input.EmailId);
share view("View_All_Basic_Information", input.EmailId);