Assign permissions dynamically to users in the application

Assign permissions dynamically to users in the application

Requirement

When a customer is added to the application, the application is instantly shared with the user, with the required permissions.

Use Case

In the order management application, a customer might sign up on the go once the business is live. All non-administrator users of the application should be given appropriate permissions —for example, a customer can view their orders and products. A vendor can see their products and the performance of those products. Appropriate permissions need to be assigned to the users who sign up as a customer or a vendor.

See how it works

Steps to follow

1. Create two forms with the following details:
Form
Form Link Name
Field Type
Field Name
Field Link Name
Vendor
Vendor
Name
Name
Name
Address
Address
Address
Email
Email
Email
Customer
Customer
Name
Name
Name
Address
Address
Address
Email
Email
Email

The Email field holds the email address with which a customer or a vendor logs in to Zoho Creator to access the order management application.
 
2. Create the different sets of permissions for different users. In the application's Settings, click User Permissions under Permissions. Then, click the Add Permission button.
 
3. Give relevant permissions for the customers and click Save.
 
4. Similarly, create a permission set for Vendors and click Save.
 
5. Create a workflow to execute when a Customer record is added.
 
6. Click Add New Action, then click Deluge Script. Add the below code to assign the permission set Customer to the customer's email.
  1. //share the application with customer with Customer permission
  2. thisapp.permissions.assignUserInProfile(input.Email,"Customer");
  3. //Send notification mail with link to access the application
  4. sendmail
  5. [
  6. from :zoho.adminuserid
  7. to :input.Email
  8. subject :"Invitation to access Order Management"
  9. message :"Hi,<div><br></div><div>You have been successfully added as a Customer.</div><div><br></div><div>Click&nbsp;<a href=\"" + " https://app.zohocreator.com" + zoho.appuri + "\"" + " target=\"_blank\">here</a>&nbsp;to access \"Order Management\"</div><div><br></div><div>Regards,</div><div>" + zoho.adminuser + "</div>"
  10. ]

7. Similarly, create a workflow to execute when a Vendor is added.
 
8. Click Add New Action, then click Deluge Script. Add the below code to assign the permission set Vendor to the vendor's email.
  1. //share the application with customer with Vendor permission
  2. thisapp.permissions.assignUserInProfile(input.Email,"Vendor");
  3. //Send notification mail with link to access the application
  4. sendmail
  5. [
  6. from :zoho.adminuserid
  7. to :input.Email
  8. subject :"Invitation to access Order Management"
  9. message :"Hi,<div><br></div><div>You have been successfully added as a Vendor.</div><div><br></div><div>Click&nbsp;<a href=\"" + " https://app.zohocreator.com" + zoho.appuri + "\"" + " target=\"_blank\">here</a>&nbsp;to access \"Order Management\"</div><div><br></div><div>Regards,</div><div>" + zoho.adminuser + "</div>"
  10. ]

See how it works