- Created by Alexandru Geageac, last modified on May 27, 2024
- Mentions
- 0 Associations
You are viewing an old version of this page. View the current version.
Compare with Current View Page History
« Previous Version 13 Next »
Jira Service Management Structures
Below you’ll find the fields of the structures and some examples for each of them to get you an idea of what it is and what it does.
JSlaInformation
string name; JSlaCompletedCycle[] completedCycles; JSlaOngoingCycle ongoingCycle;
JSlaCompletedCycle
date startTime; date stopTime; boolean breached; number goalDuration; number elepsedTime; number remainingTime;
JSlaOngoingCycle
date startTime; date breachedTime; boolean breached; boolean paused; boolean withinCalendarHours; number goalDuration; number elepsedTime; number remainingTime;
Example 1 - getting the information from SLA customfield
JSlaInformation slaInfo = %key%.customfield_10056; //change the customfield to match your cf_id runnerLog("slaInfoName = " + slaInfo.name); JSlaOngoingCycle slaOC = slaInfo.ongoingCycle; runnerLog("---ongoingCycle---"); runnerLog("startTime = " + slaOC.startTime); runnerLog("breachTime = " + slaOC.breachTime); runnerLog("breached = " + slaOC.breached); runnerLog("paused = " + slaOC.paused); runnerLog("withinCalendarHours = " + slaOC.withinCalendarHours); runnerLog("goalDuration = " + slaOC.goalDuration); runnerLog("elapsedTime = " + slaOC.elapsedTime); runnerLog("remainingTime = " + slaOC.remainingTime); int indexCC = 1; for(JSlaCompletedCycle slaCC in slaInfo.completedCycles) { runnerLog("---completedCycle " + indexCC + "---"); runnerLog("startTime = " + slaCC.startTime); runnerLog("stopTime = " + slaCC.stopTime); runnerLog("breached = " + slaCC.breached); runnerLog("goalDuration = " + slaCC.goalDuration); runnerLog("elapsedTime = " + slaCC.elapsedTime); runnerLog("remainingTime = " + slaCC.remainingTime); indexCC = indexCC + 1; } runnerLog("_________________________________________________");
Example 2 - getting the information from getSlaInformation function
JSlaInformation[] slaInfos = getSlaInformation("SM-1"); int indexBC = 1; for(JSlaInformation slaInfo in slaInfos) { runnerLog("---SLA " + indexBC + "---"); runnerLog("slaInfoName = " + slaInfo.name); JSlaOngoingCycle slaOC = slaInfo.ongoingCycle; runnerLog("---ongoingCycle---"); runnerLog("startTime = " + slaOC.startTime); runnerLog("breachTime = " + slaOC.breachTime); runnerLog("breached = " + slaOC.breached); runnerLog("paused = " + slaOC.paused); runnerLog("withinCalendarHours = " + slaOC.withinCalendarHours); runnerLog("goalDuration = " + slaOC.goalDuration); runnerLog("elapsedTime = " + slaOC.elapsedTime); runnerLog("remainingTime = " + slaOC.remainingTime); int indexCC = 1; for(JSlaCompletedCycle slaCC in slaInfo.completedCycles) { runnerLog("---completedCycle " + indexCC + "---"); runnerLog("startTime = " + slaCC.startTime); runnerLog("stopTime = " + slaCC.stopTime); runnerLog("breached = " + slaCC.breached); runnerLog("goalDuration = " + slaCC.goalDuration); runnerLog("elapsedTime = " + slaCC.elapsedTime); runnerLog("remainingTime = " + slaCC.remainingTime); indexCC = indexCC + 1; } indexBC = indexBC + 1; } runnerLog("_________________________________________________");
JSMCustomerRequest
JSMCustomerRequestActions actions; string[] attachments; //attachments ids number[] comments; //commentsIds date createdDate; JSMCustomerRequestStatus currentStatus; number issueId; string issueKey; JUser[] participants; JUser reporter; number requestTypeId; number serviceDeskId; number[] slaIds; JSMCustomerRequestStatus[] status;
JSMCustomerRequestActions
boolean addAttachment; boolean addComment; boolean addParticipant; boolean removeParticipant;
JSMCustomerRequestStatus
string status; string statusCategory; date statusDate;
Example 1 - get customer request with key/id
JSMCustomerRequest customerRequest = getCustomerRequest("SM-1"); JSMCustomerRequestActions customerRequestActions = customerRequest.actions; runnerLog("---actions---"); runnerLog("addAttachment = " + customerRequestActions.addAttachment); runnerLog("addComment = " + customerRequestActions.addComment); runnerLog("addParticipant = " + customerRequestActions.addParticipant); runnerLog("removeParticipant = " + customerRequestActions.removeParticipant); runnerLog("-------------"); runnerLog("attachments = " + customerRequest.attachments); runnerLog("comments = " + customerRequest.comments); runnerLog("createdDate = " + customerRequest.createdDate); JSMCustomerRequestStatus customerRequestCurrentStatus = customerRequest.currentStatus; runnerLog("---currentStatus---"); runnerLog("status = " + customerRequestCurrentStatus.status); runnerLog("statusCategory = " + customerRequestCurrentStatus.statusCategory); runnerLog("statusDate = " + customerRequestCurrentStatus.statusDate); runnerLog("-------------------"); runnerLog("issueId = " + customerRequest.issueId); runnerLog("issueKey = " + customerRequest.issueKey); int indexPP = 1; for(JUser participant in customerRequest.participants) { runnerLog("---participant " + indexPP + "---"); runnerLog("key = " + participant.key); runnerLog("username = " + participant.username); runnerLog("statusDate = " + participant.displayname); runnerLog("email = " + participant.email); indexPP = indexPP + 1; } runnerLog("--------------"); runnerLog("---reporter---"); runnerLog("key = " + customerRequest.reporter.key); runnerLog("username = " + customerRequest.reporter.username); runnerLog("displayname = " + customerRequest.reporter.displayname); runnerLog("email = " + customerRequest.reporter.email); runnerLog("--------------"); runnerLog("requestTypeId = " + customerRequest.requestTypeId); runnerLog("serviceDeskId = " + customerRequest.serviceDeskId); runnerLog("slaIds: " + customerRequest.slaIds); int indexCC = 1; for(JSMCustomerRequestStatus customerRequestStatus in customerRequest.status) { runnerLog("---customerRequestStatus " + indexCC + "---"); runnerLog("status = " + customerRequestStatus.status); runnerLog("statusCategory = " + customerRequestStatus.statusCategory); runnerLog("statusDate = " + customerRequestStatus.statusDate); indexCC = indexCC + 1; } runnerLog("_________________________________________________");
Example 2 - get only the statuses in which a customer request was
JSMCustomerRequestStatus[] customerRequestCurrentStatuses = getCustomerRequestStatus("SM-1"); int indexCC = 1; for(JSMCustomerRequestStatus customerRequestStatus in customerRequestCurrentStatuses) { runnerLog("---customerRequestStatus " + indexCC + "---"); runnerLog("status = " + customerRequestStatus.status); runnerLog("statusCategory = " + customerRequestStatus.statusCategory); runnerLog("statusDate = " + customerRequestStatus.statusDate); indexCC = indexCC + 1; } runnerLog("_________________________________________________");
JSMApproval
JSMApprover[] approvers; boolean canAnswerApproval; date completedDate; date createdDate; string finalDecision; number id; string name;
JSMApprover
JUser approver; string approverDecision;
Example 1 - getting all approvals for the request provided
JSMApproval[] approvals = getApprovals("SM-1"); int indexVal = 1; for(JSMApproval approval in approvals) { runnerLog("---approval " + indexVal + "---"); JSMApprover[] approvers = approval.approvers; int indexVer = 1; for(JSMApprover approver in approvers) { runnerLog("---approver " + indexVer + "---"); JUser currentApprover = approver.approver; runnerLog("approver key = " + currentApprover.key); runnerLog("approver username = " + currentApprover.username); runnerLog("approver displayname = " + currentApprover.displayname); runnerLog("approver email = " + currentApprover.email); runnerLog("approverDecision = " + approver.approverDecision); indexVal = indexVal + 1; } runnerLog("--------------"); runnerLog("canAnswerApproval = " + approval.canAnswerApproval); runnerLog("completedDate = " + approval.completedDate); runnerLog("createdDate = " + approval.createdDate); runnerLog("finalDecision = " + approval.finalDecision); runnerLog("id = " + approval.id); runnerLog("name = " + approval.name); } runnerLog("_________________________________________________");
Example 2 - getting Approval by id
JSMApproval approval = getApproval("SM-1", 5); JSMApprover[] approvers = approval.approvers; int indexVer = 1; for(JSMApprover approver in approvers) { runnerLog("---approver " + indexVer + "---"); JUser currentApprover = approver.approver; runnerLog("approver key = " + currentApprover.key); runnerLog("approver username = " + currentApprover.username); runnerLog("approver displayname = " + currentApprover.displayname); runnerLog("approver email = " + currentApprover.email); runnerLog("approverDecision = " + approver.approverDecision); indexVer = indexVer + 1; } runnerLog("--------------"); runnerLog("canAnswerApproval = " + approval.canAnswerApproval); runnerLog("completedDate = " + approval.completedDate); runnerLog("createdDate = " + approval.createdDate); runnerLog("finalDecision = " + approval.finalDecision); runnerLog("id = " + approval.id); runnerLog("name = " + approval.name); runnerLog("_________________________________________________");
JSMAttachment
JUser author; string created; string filename; string mimeType; string size;
Example
JSMAttachment[] attachments = getAttachmentsForRequest("SM-1"); int indexVal = 1; for(JSMAttachment attachment in attachments) { runnerLog("---attachment " + indexVal + "---"); JUser author = attachment.author; runnerLog("---author---"); runnerLog("key = " + author.key); runnerLog("username = " + author.username); runnerLog("displayname = " + author.displayname); runnerLog("email = " + author.email); runnerLog("--------------"); runnerLog("created = " + attachment.created); runnerLog("filename = " + attachment.filename); runnerLog("mimeType = " + attachment.mimeType); runnerLog("size = " + attachment.size); indexVal = indexVal + 1; } runnerLog("_________________________________________________");
JSMComment
JSMAttachment[] attachments JUser author; string body; string created; number id; boolean isPublic; string renderedBody;
Example 1 - get all (or just public / private) comments for request
//getCommentsForRequest("SM-1"); //for all, or getCommentsForRequest("SM-1", true); for publicOnly or getCommentsForRequest("SM-1", false); for privateOnly //This will not retrieve the renderedBody and the attachments, if you need those please see the Example 2. JSMComment[] comments = getCommentsForRequest("SM-1"); int indexVal = 1; for(JSMComment comment in comments) { runnerLog("---comment " + indexVal + "---"); JUser author = comment.author; runnerLog("---author---"); runnerLog("key = " + author.key); runnerLog("username = " + author.username); runnerLog("displayname = " + author.displayname); runnerLog("email = " + author.email); runnerLog("--------------"); runnerLog("body = " + comment.body); runnerLog("created = " + comment.created); runnerLog("id = " + comment.id); runnerLog("isPublic = " + comment.isPublic); indexVal = indexVal + 1; } runnerLog("_________________________________________________");
Example 2 - get comment with a provided id from request
//This method will also retrieve the renderedBody and the attachments JSMComment comment = getCommentForRequest("SM-1", 10072); JSMAttachment[] attachments = comment.attachments; int indexVal = 1; for(JSMAttachment attachment in attachments) { runnerLog("---attachment " + indexVal + "---"); JUser author = attachment.author; runnerLog("---author---"); runnerLog("key = " + author.key); runnerLog("username = " + author.username); runnerLog("displayname = " + author.displayname); runnerLog("email = " + author.email); runnerLog("--------------"); runnerLog("created = " + attachment.created); runnerLog("filename = " + attachment.filename); runnerLog("mimeType = " + attachment.mimeType); runnerLog("size = " + attachment.size); indexVal = indexVal + 1; } JUser author = comment.author; runnerLog("---author---"); runnerLog("key = " + author.key); runnerLog("username = " + author.username); runnerLog("displayname = " + author.displayname); runnerLog("email = " + author.email); runnerLog("--------------"); runnerLog("body = " + comment.body); runnerLog("created = " + comment.created); runnerLog("id = " + comment.id); runnerLog("isPublic = " + comment.isPublic); runnerLog("renderedBody = " + comment.renderedBody); runnerLog("_________________________________________________");
JSMServiceDesk
number id; number projectId; string projectKey; string projectName;
Example 1 - get all service desks
JSMServiceDesk[] serviceDesks = getAllServiceDesks(); int indexCC = 1; for(JSMServiceDesk serviceDesk in serviceDesks) { runnerLog("---Service Desk " + indexCC + "---"); runnerLog("id = " + serviceDesk.id); runnerLog("projectId = " + serviceDesk.projectId); runnerLog("projectKey = " + serviceDesk.projectKey); runnerLog("projectName = " + serviceDesk.projectName); indexCC = indexCC + 1; } runnerLog("_________________________________________________");
Example 2 - get service desk for project
JSMServiceDesk serviceDesk = getServiceDesk("SM"); //JSMServiceDesk serviceDesk = getServiceDeskByProjectKey("SM"); //just an alias for the above runnerLog("id = " + serviceDesk.id); runnerLog("projectId = " + serviceDesk.projectId); runnerLog("projectKey = " + serviceDesk.projectKey); runnerLog("projectName = " + serviceDesk.projectName); runnerLog("_________________________________________________");
JSMQueue
string[] fields; number id; number issueCount; string jql; string name;
Example 1 - get all queues for a service desk
JSMQueue[] queues = getServiceDeskQueues(1); int indexCC = 1; for(JSMQueue queue in queues) { runnerLog("---Queue " + indexCC + "---"); runnerLog("fields = " + queue.fields); runnerLog("id = " + queue.id); runnerLog("issueCount = " + queue.issueCount); runnerLog("jql = " + queue.jql); runnerLog("name = " + queue.name); indexCC = indexCC + 1; } runnerLog("_________________________________________________");
Example 2 - get queue by id from service desk
JSMQueue queue = getServiceDeskQueue(1, 1); runnerLog("fields = " + queue.fields); runnerLog("id = " + queue.id); runnerLog("issueCount = " + queue.issueCount); runnerLog("jql = " + queue.jql); runnerLog("name = " + queue.name); runnerLog("_________________________________________________");
JSMAssetsObject
string workspaceId; string globalId; string id;
Example - get assets objects from custom field
JSMAssetsObject[] objects = SM-33.customfield_10079; //change this with your issueKey and assets customfield_id int indexCC = 1; for(JSMAssetsObject object in objects) { runnerLog("---object " + indexCC + "---"); runnerLog("workspaceId = " + object.workspaceId); runnerLog("globalId = " + object.globalId); //from Atlassian this comes as "id" runnerLog("id = " + object.id); //from Atlassian this comes as "objectId" indexCC = indexCC + 1; } runnerLog("_________________________________________________");
JSMKBArticle
string content; string excerpt; string source; string title;
Example - get articles that contains the word “template” as a searchQuery
JSMKBArticle[] articles = getKBArticles("template"); int indexCC = 1; for(JSMKBArticle article in articles) { runnerLog("---article " + indexCC + "---"); runnerLog("content = " + article.content); runnerLog("excerpt = " + article.excerpt); runnerLog("source = " + article.source); runnerLog("title = " + article.title); indexCC = indexCC + 1; } runnerLog("_________________________________________________");
JSMRequestType
string description; string helpText; number iconId; number id; number issueTypeId; number portalId; string name;
Example - get all request types
JSMRequestType[] requestTypes = getRequestsTypes(); int indexCC = 1; for(JSMRequestType requestType in requestTypes) { runnerLog("---Request Type " + indexCC + "---"); runnerLog("name = " + requestType.name); runnerLog("description = " + requestType.description); runnerLog("id = " + requestType.id); runnerLog("helpText = " + requestType.helpText); runnerLog("iconId = " + requestType.iconId); runnerLog("issueTypeId = " + requestType.issueTypeId); runnerLog("portalId = " + requestType.portalId); indexCC = indexCC + 1; } runnerLog("_________________________________________________");
JSMFeedback
number rating; string comment; string type; //kind of useless since all have the same type, but we have it...
Example - get feedback for request
JSMFeedback feedback = getFeedbackForRequest("SM-1"); //SM-1 is the request key for which we'll retrieve the feedback runnerLog("rating = " + feedback.rating); runnerLog("comment = " + feedback.comment); runnerLog("type = " + feedback.type);
General Example For (some of the) Functions
string customerEmail = "icecream@testBuyer.com"; boolean customerCreated = createCustomer("The Ice Cream Buyer", customerEmail); if(customerCreated) { runnerLog("A new customer was invited, let's announce this on the ticket."); addJSDComment(key, "We invited the customer with the following email '" + customerEmail +"' to join us.", true); //public comment } else { addJSDComment(key, "We couldn't invite the customer with the following email '" + customerEmail +"' please take a second look.", false); //internal comment } int[] commentsIds = getAllCommentIds(key); runnerLog("There are '" + size(commentsIds) + "' comments with the following ids: " + commentsIds); string newOrgName = "iFixit"; createOrganization(newOrgName); int propsOrgId = getOrganizationIdByName(newOrgName); runnerLog("We should add the new organization to a JSM project."); addOrganization({"Org", newOrgName}, "JSM"); runnerLog("Let's add some engineers to the newly created organization"); addCustomerToOrganization({"customer_id", "another_customer_id"}, newOrgName); runnerLog("Engineers from organization '" + newOrgName + "': " + getUsersFromOrganizations({newOrgName})); runnerLog("Remove one of them."); removeCustomerFromOrganization({"customer_id"}, newOrgName); runnerLog("Now we have the following engineers: " + getUsersFromOrganizations({newOrgName})); runnerLog("Let's set some properties for a new organization"); setOrganizationPropertyValue(propsOrgId, "DoesItWork", false); setOrganizationPropertyValue(propsOrgId, "IceCreamType", {"McSUNDAE", "McFlurry"}); runnerLog("What properties do we have set on the organization with id " + propsOrgId + "? "); string[] properties = getOrganizationPropertyKeys(propsOrgId); runnerLog("Properties: "+ properties); for(string prop in properties) { runnerLog("Property with key '" + prop + "' has value: " + getOrganizationPropertyValues(propsOrgId, prop)); } runnerLog("Let's put one of the engineers to work."); setOrganizationPropertyValue(propsOrgId, "DoesItWork", true); runnerLog("The new value of 'DoesItWork' is: " + getOrganizationPropertyValues(propsOrgId, "DoesItWork")); runnerLog("Looks like the engineer did a good work."); runnerLog("Since the ice cream machine is working, let's remove the second property."); deleteOrganizationProperty(propsOrgId, properties[0]); runnerLog("Now we only have the following properties: " + getOrganizationPropertyKeys(propsOrgId)); runnerLog("How many organization are associated with project 'JSM': " + size(getAllOrganizationIds("JSM"))); runnerLog("Let's remove the newly created organization from the 'JSM' project."); removeOrganization({newOrgName}, "JSM"); runnerLog("Now we have only '" + size(getAllOrganizationIds("JSM")) + "' organizatons on the project JSM"); runnerLog("Let's get rid of the new organization since we don't use it anymore."); //we'll get the organizationsIds before and after the delete of the organization and get the diff to check if the organization was really deleted int[] initialOrganizations = getAllOrganizationIds(); deleteOrganization(newOrgName); int[] currentOrganizations = getAllOrganizationIds(); string[] deletedOrgs = arrayDiff(initialOrganizations, currentOrganizations); if(size(deletedOrgs) == 1 && deletedOrgs[0] == propsOrgId) { runnerLog("Organization with name: '" + newOrgName + "' does not exist anymore"); } return "Have a nice day.";
- No labels