This is an article documenting how to update Creator from a workflow written in a Deluge Script held in ZohoCRM.
Why?
I've also started this article to document an issue we encountered where our code was as per the documentation provided, and the responses returned as successful, but the target fields did not update. This was as a result after changing the owner of the Creator app to another person and adding our previous Super Admin account as a "Developer".
How?
I'm going to demo two methods here using the <connection_link>
Setup the Connection Link
- Login to ZohoCRM as the creator super admin/owner (might not be the same as CRM super admin!!!)
- Go to Setup » Developer Space » Connections » Create Connection » Zoho
- Ensure you enable/tick "ZohoCreator/creatorapi".
- Note the name that you call it (displayed in mixed case but will be used in its lowercase form)
Method #1: Using UpdateRecords() function with Connection Link:
- The syntax for this iscopyraw
response = zoho.creator.updateRecord( ownerName, appLinkName, formLinkName, id, dataMap, connectionlinkName);
- response = zoho.creator.updateRecord( ownerName, appLinkName, formLinkName, id, dataMap, connectionlinkName);
- Where
- ownerName is the owner of the Creator app.
- appLinkName is the name of the Creator app.
- formLinkName is the name of the Creator form.
- id is the Creator ID of the record.
- dataMap is the map() to post.
- connectionLinkName is the connection link obtained previously (as a string).
- For example:copyraw
v_RecordID = "1234567890123456789".toLong(); m_Params = Map(); m_Params.put("FieldToUpdate", "ValueToUpdateWith"); m_response = zoho.creator.updateRecord( "myAdminAccount", "myApp", "myForm", v_RecordID, m_Params, "myzohocreatorconnection");
- v_RecordID = "1234567890123456789".toLong();
- m_Params = Map();
- m_Params.put("FieldToUpdate", "ValueToUpdateWith");
- m_response = zoho.creator.updateRecord( "myAdminAccount", "myApp", "myForm", v_RecordID, m_Params, "myzohocreatorconnection");
- Successful Response:
Method #2: Using API v1 (using JSON not XML)
- Generate AuthToken:
- Browser Mode: Open a browser to https://accounts.zoho.com/apiauthtoken/create?SCOPE=ZohoCreator/creatorapi
- OR API Mode: https://accounts.zoho.com/apiauthtoken/nb/create?SCOPE=ZohoCreator/creatorapi&EMAIL_ID=<email_address>&PASSWORD=<password> where you enter your own email address and zoho password.
- Determine the EndPoint:
- Following the syntax: https://creator.zoho.com/api/<ownername>/<format>/<applicationName>/form/<formName>/record/update where ownername is the owner, format is the type (I prefer JSON), applicationName is the name of your app, and form name the Creator form name. If you are on the EU or COM domain, enter this as the TLD of your endpoint (eg. creator.zoho.eu or creator.zoho.com).
- For example: https://creator.zoho.eu/api/myAdminAccount/json/myApp/form/myForm/record/update
- The code to update a form (sample data for demonstration purposes). Note that the payload here is submitted through URL parameters:copyraw
v_AccessToken = "123abc456def789abc123def456abc"; v_Criteria = "ID=1234567890123456789"; v_EndPoint = "https://creator.zoho.eu/api/myAdminAccount/json/myApp/form/myForm/record/update/" v_EndPoint = v_EndPoint + "?criteria=" + v_Criteria + "&FieldToUpdate=ValueToUpdateWith"; m_Params = Map(); m_Params.put("authtoken",v_AccessToken); m_Params.put("scope","creatorapi") response = invokeurl [ url :v_EndPoint type :POST parameters:m_Params.toString() connection:"myzohocreatorconnection" ];
- v_AccessToken = "123abc456def789abc123def456abc";
- v_Criteria = "ID=1234567890123456789";
- v_EndPoint = "https://creator.zoho.eu/api/myAdminAccount/json/myApp/form/myForm/record/update/"
- v_EndPoint = v_EndPoint + "?criteria=" + v_Criteria + "&FieldToUpdate=ValueToUpdateWith";
- m_Params = Map();
- m_Params.put("authtoken",v_AccessToken);
- m_Params.put("scope","creatorapi")
- response = invokeUrl
- [
- url :v_EndPoint
- type :POST
- parameters:m_Params.toString()
- connection:"myzohocreatorconnection"
- ];
- Successful Response:
copyraw
{ "formname": [ "myForm", { "operation": [ "update", { "criteria": "ID=1234567890123456789", "newvalues": [ { "FieldToUpdate": "ValueToUpdateWith" } ], "status": "Success" } ] } ] }
- {
- "formname": [
- "myForm",
- {
- "operation": [
- "update",
- {
- "criteria": "ID=1234567890123456789",
- "newvalues": [
- {
- "FieldToUpdate": "ValueToUpdateWith"
- }
- ],
- "status": "Success"
- }
- ]
- }
- ]
- }
Encountered Issues:
- #2945 INVALID TICKET: Ensure you are using creator.zoho.com or creator.zoho.eu for your endpoints as appropriate.
- #2945 MORE_THAN_MAX_OCCURRENCE: Ensure your params are submitted as a JSON string (not a JSON list).
- Update Success: Not updating creator: This is a permissions issue. Ensure the owner or SuperAdmin of creator is the one creating the connection link. The JSON response is that the update was successful but the Creator tables do not update...
- ZohoCreator/creatorapi option not available to enable: resolved by deleting any existing ones, refreshing the page and trying again.