Skip to end of banner
Go to start of banner

Jira Service Management Routines

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

The cloud version uses the following structures:

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

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