Hello Everyone,
A Custom Function is a user-written set of code to achieve a specific requirement. Set the required conditions needed as to when to trigger using the Workflow / Business Rules (be it Tasks / Project) and associate the custom function to it.
Requirement:-
Custom function code:-
projectIdColumnName = "ProjectId";
fieldNameColumnName = "FieldName";
oldStatusColumnName = "OldStatus";
newStatusColumnName = "NewStatus";
updatedByColumnName = "UpdatedBy";
workspaceName = "Workspace1";
workspaceResponse = invokeurl
[
url :"https://analyticsapi.zoho.com/restapi/v2/workspaces"
type :GET
connection:"XXXXXXX"
];
workspaceDetails = workspaceResponse.get("data").get("ownedWorkspaces");
for each workspaceDetail in workspaceDetails
{
if(workspaceDetail.get("workspaceName").containsIgnoreCase(workspaceName))
{
workspaceId = workspaceDetail.get("workspaceId");
analyticsOrgId = workspaceDetail.get("orgId");
break;
}
}
if(workspaceId == null)
{
workspaceDetails = workspaceResponse.get("data").get("sharedWorkspaces");
for each workspaceDetail in workspaceDetails
{
if(workspaceDetail.get("workspaceName").containsIgnoreCase(workspaceName))
{
workspaceId = workspaceDetail.get("workspaceId");
analyticsOrgId = workspaceDetail.get("orgId");
break;
}
}
}
headersMap = Map();
headersMap.put("ZANALYTICS-ORGID",analyticsOrgId);
viewName = "table1";
viewResponse = invokeurl
[
url :"https://analyticsapi.zoho.com/restapi/v2/workspaces/" + workspaceId + "/views"
type :GET
headers:headersMap
connection:"XXXXXXX"
];
viewDetails = viewResponse.get("data").get("views");
for each viewDetail in viewDetails
{
if(viewDetail.get("viewName").containsIgnoreCase(viewName))
{
viewId = viewDetail.get("viewId");
break;
}
}
statusTimelineMap = Map();
statusTimelineMap.put(projectIdColumnName,projectId);
statusTimelineMap.put(fieldNameColumnName,projectName);
statusTimelineMap.put(oldStatusColumnName,issueId);
statusTimelineMap.put(newStatusColumnName,issueName);
statusTimelineMap.put(updatedByColumnName,UpdatedBy);
columns = Map();
columns.put("columns",statusTimelineMap);
paramsMap = Map();
paramsMap.put("CONFIG",columns.toString());
analyticsResponse = invokeurl
[
We hope you found this post useful. If you have any questions, feel free to share them in the comments below.