Extension Pointers - Simple yet significant pointers #8: CRM variables

Extension Pointers - Simple yet significant pointers #8: CRM variables



Getting and setting CRM variable values in an extension
 
CRM variables come in handy when you need global access to a variable across an entire extension. There may also be a need for user-specific data, which the user must provide at the time of installation. CRM variables come in handy in these situations as well. Let's look at how and where you can get or set the value of a CRM variable in an extension.
  • Get org variable - Fetch the value of an org/CRM variable
  • Set org variable - Set the value of an org/CRM variable 
What are the options available to get or set values for a CRM variable?

1. In a custom function using Deluge tasks: When you need to get or set the value of a CRM variable in a custom function, you can use the Deluge tasks available.
 
 Get org variable - Syntax: 
<Response> = zoho.crm.getOrgVariable("<customVariableName>");
 
➤ Set org variable - Syntax: 
<Response> = zoho.crm.invokeConnector("crm.set", <valueMap Map>);
 
You can refer to this link for more details.
 
2. In widgets: When you need to get or set a CRM variable as part of the widget UI you are designing, then you can use the below syntax.
 
➤ Get org variable - Syntax: 
ZOHO.CRM.API.getOrgVariable("variableNamespace").then(function(data){
console.log(data);
});
 
You can refer to this link for more details.

➤ Set org variable - Syntax: 
var variableMap = { "apiname": "{crm variable API name}", "value": "{value}"};
ZOHO.CRM.CONNECTOR.invokeAPI("crm.set", variableMap);
 
SEE ALSO: