In this post, I am gonna help you to understand a custom functionality to get the Record ID in a custom field of your Record. Now if you have a question like why we would need the Record ID to be stored in a custom field. So this is actually a general question which can popup in your mind. So If you have been using your data for different types of usages then at some point you would have noticed to track your Records based on a specific key Or ID. So in that Case, Record Id is the right value to track your records and use them appropriately inside the Zoho Apps or Outside using APIs.
Steps to Create Worflow in Zoho CRM
- Go to Setup
- Go to WorkFlow Rules
- Click +Create Rule
- Select Module “Referrals” (In My Case)
- Enter Rule Name “Referral Count” (In My Case)
- Select When This Workflow should Trigger – “On a record action – Create“
- Select First Condition – “All Referrals“
- In Instant Action Select – “Function“
- Click on “+New Function“
- Click on “Write your own function“
- Enter Your Function Name & Rule Name something like “Store_Contact_ID“
- Now you can see the Function writing screen where you will see an option “Edit Arguments“.
- Click on Edit Arguments
- In Key Field, Create a Key “ContactId“
- In Param Value Field, Type # and you will see Module select field. Select “Contacts” & Other Fields pop up just after the Module selection. Select “Contact ID“
- Now, Save the Argument & Move to The Function screen to write your custom function.
Custom Function to Get Record ID & Insert it into Custom Field.
response = zoho.crm.getRecordById("Contacts",contid); myMap = Map(); myMap.put("User_ID",contid); // User_ID is the Key for Long_Integer Field in Zoho CRM to store the Record ID. // resp_update = zoho.crm.updateRecord("Contacts", contid,myMap); info resp_update ;
Now as your function is ready to use. So let’s Save and Execute it for testing. So Click on “Save & Execute” and It will ask you to enter a Contact Record ID. So Get the Record ID for a Contact and Insert the ID in the input field and see if works fine and doesn’t give any error. If the code worked successfully then Click on Final “Save” button and then Save Workflow as well.
Now your workflow is ready to use.