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>);
where,
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:
Deluge Script
The script definition of the Basic Information Form is given below. The on add -> on success script added to this form will be executed when a new employee record is added to the database and 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".
form Basic_Information
{
displayname = "Basic Information"
Employee_ID
(
displayname = "Employee ID"
type = number
width = 20
)
Name
(
type = text
)
EmailId
(
type = email
)
Role
(
type = picklist
values = Role.Role
)
actions
{
on add
{
Submit
(
type = submit
displayname = "Submit"
on success
{
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);
}
}
)
Reset
(
type = reset
displayname = "Reset"
)
}
}
}