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 <componenet-type>(<component name>, <email>);
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:
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);