A super quick article on how to pre-select the pipeline on deal creation within CRM based on the department specified on a user's profile.
Why?
A client asked that when staff create a deal/opportunity record in CRM, the pipeline is automatically pre-selected based on the user.
How?
So there's a bit of a pre-amble for setting up the fields, we'll then use a client script to automatically read the user's record, retrieve the department, and set the correct pipeline option.
Setup: Department Field on User Profile
- Login to ZohoCRM as a system administrator > Go to Setup > Users > Click the pencil icon (top-right most) to edit any profile
- On the user's dialog/popup in the bottom left, there will be a link saying "Manage Fields"
- Add a picklist field type called "Department" with the options "Hire Team", and "Sales Team".
- Save and Close
Setup: Specify Pipeline Options
- Login to ZohoCRM as a system administrator > Go to Setup > Pipelines
- Using the "Standard" layout, let's simply create a new pipeline by clicking the button in the top right.
- For this demo, we ensure there are at least 2 pipelines: "Hire Pipeline", and "Sales Pipeline".
Setup: the Client Script
- Login to ZohoCRM as a system administrator > Go to Setup > Client Script
- Clicking on the "New Script" button in the top right.
- For this demo, we give it the name "On Deal Creation" and in the description I've commented that this will select a pipeline based on the user's department.
- Category is "Module", Page is "Create Page", and Module is "Deals"
- Event Type is "Page Event" and Event is "onLoad".
- Give it the code:
var r_User = ZDK.Apps.CRM.Users.fetchById($Crm.user.id); var r_Field = ZDK.Page.getField('Pipeline'); if (r_User.Department == "Sales Team") { r_Field.setValue("Sales Pipeline"); } else { r_Field.setValue("Hire Pipeline"); } - Save and Close
Issue(s) Encountered
- Using the CS IDE Run: This can't run ZDK Apps.CRM.Users (this can't read any module)... Simply save the above code and test it using the CRM and not the IDE.
Discussion
Comments
Questions, corrections and useful additions are reviewed before appearing here.
No comments yet. Start the discussion.