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 rules (be it Tasks / Project) and associate the custom function to it.
We have complied a gallery of the most frequently solved use cases for Issues custom functions. You can access the same using the steps available in this link.
And, today I would like to highlight one of the Gallery custom functions - updateTheStatusOfALinkedIssue.
Use case:-
Let us assume there are two issues Issue A and Issue B linked with type "is duplicate of" then the status update done for Issue A will be streamlined to Issue B as well i.e when Issue A status is updated to "In Progress" then Issue B status will automatically be updated to the same status.
Below is the custom function code for reference. We can associate this code with Business rule available within Issue tracker settings.
Custom function code:-
getIssueDetailsUrl = projectsDomain + "/restapi/portal/" + portalId + "/projects/" + bugProjectId + "/bugs/" + bugId + "/";
getBugDetResp = invokeurl
[
url :getIssueDetailsUrl
type :GET
connection:"XXXXXXX"
];
//info getBugDetResp;
currentIssueStatusId = getBugDetResp.get("bugs").get("0").get("status").get("id");
getLinkedIssuesUrl = projectsDomain + "/api/v3/portal/" + portalId + "/projects/" + bugProjectId + "/bugs/" + bugId + "/linkedissues";
getLinkedIssuesResp = invokeurl
[
url :getLinkedIssuesUrl
type :GET
connection:"XXXXXXX"
];
//info getLinkedIssuesResp;
issueLinked = getLinkedIssuesResp.get("issue_linked");
reverseLinkedIssues = getLinkedIssuesResp.get("reverse_linked_issues");
info issueLinked;
if(issueLinked.get("linked_issues") != null)
{
linkedIssues = issueLinked.get("linked_issues");
duplicateOfIssues = linkedIssues.get("is duplicate of");
for each duplicateIssue in duplicateOfIssues
{
duplicateIssueId = duplicateIssue.get("issue_id");
duplicateIssueStatusId = duplicateIssue.get("status_id");
if(!duplicateIssueStatusId.equals(currentIssueStatusId))
{
updateIssueStatusUrl = projectsDomain + "/restapi/portal/" + portalId + "/projects/" + bugProjectId + "/bugs/" + duplicateIssueId + "/";
updateIssueStatusParam = Map();
updateIssueStatusParam.put("status_id",currentIssueStatusId);
updateStatusResp = invokeurl
[
url :updateIssueStatusUrl
type :POST
parameters:updateIssueStatusParam
connection:"XXXXXXX"
];
info updateStatusResp;
}
}
}
if(issueLinked.get("reverse_linked_issues") != null)
{
linkedIssues = issueLinked.get("reverse_linked_issues");
duplicateOfIssues = linkedIssues.get("is duplicate of");
for each duplicateIssue in duplicateOfIssues
{
duplicateIssueId = duplicateIssue.get("issue_id");
duplicateIssueStatusId = duplicateIssue.get("status_id");
if(!duplicateIssueStatusId.equals(currentIssueStatusId))
{
updateIssueStatusUrl = projectsDomain + "/restapi/portal/" + portalId + "/projects/" + bugProjectId + "/bugs/" + duplicateIssueId + "/";
updateIssueStatusParam = Map();
updateIssueStatusParam.put("status_id",currentIssueStatusId);
updateStatusResp = invokeurl
[
url :updateIssueStatusUrl
type :POST
parameters:updateIssueStatusParam
connection:"XXXXXXX"
];
info updateStatusResp;
}
}
}
Make sure to replace XXXXXXX with the Zoho Projects connection link name with scope ZohoProjects.bugs.READ, ZohoProjects.bugs.UPDATE. Check this link to learn how to create the connection. Also, a screenshot of the sample Business rules is attached for reference.
We hope you found this post useful. If you have any questions, feel free to share them in the comments below.