Purchase Order Processing

Peter Gomez December 27, 2016

Hey all,

 

Trying to find an easy way to break down my Jelly script into the groovyrunner add-on. What it does is it assigns a certain user to the purchase order depending on what department it is placed under. I was curious if I should be doing a different script per person or if one/two escalation services would be sufficient enough. Here is a copy of the script:

<JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.enterprise.JiraTagLib" xmlns:core="jelly:core" xmlns:log="jelly:log" >
<jira:Login username="ahsscripting" password="************">

<!--Shared variables-->
<core:set var="workflowUser" value="ahsscripting" />

<!-- ##########################Capex Processing######################################-->
<core:set var="workflowStepCAPEX" value="311" />
<core:set var="filterCAPEX" value="13774" />

<!-- Run the SearchRequestFilter -->
<jira:RunSearchRequest filterid="${filterCAPEX}" var="issues" />
<!-- Iterate over the issues -->
<core:forEach var="issue" items="${issues}">
<log:warn>Processing CAPEX Purchase Order</log:warn>
<jira:TransitionWorkflow key="${issue.key}" user="${workflowUser}" workflowAction="${workflowStepCAPEX}" />
<jira:AssignIssue key="${issue.key}" assignee="jguser" />
</core:forEach>


<!-- ##########################Non-Capex Processing #################################-->
<core:set var="CORP" value="CORP" />
<core:set var="Finance" value="Finance" />
<core:set var="Sales" value="Sales" />
<!--Finance Assigned to MH-->
<core:set var="IT" value="IT" />
<!--IT Assigned to MH-->
<core:set var="Delaware" value="DELA" />
<!--DELA Assigned to RC-->
<core:set var="Chambersburg" value="PA" />
<!--CHAM assigned RC-->
<core:set var="Falmouth" value="ME" />
<!--Falmouth assigned to Liddy Wilson-->
<core:set var="StatenIsland" value="SI" />
<!--Staten Island assigned to RC-->
<core:set var="Lombard" value="IL" />
<!--Lombard assigned to L K-->
<core:set var="Salem" value="MA" />
<!--Salem/Braintree assigned to LG-->
<core:set var="NHBH" value="NHBH" />
<!--Salem/Braintree assigned to JM-->
<core:set var="workflowStep" value="321" />
<core:set var="filter" value="13775" />
<!-- Run the SearchRequestFilter -->
<jira:RunSearchRequest filterid="${filter}" var="issues" />
<!-- Iterate over the issues -->
<core:forEach var="issue" items="${issues}">
<core:set var="Environment" value="${issue.environment}" />

<!--CORP/Finance/Sales Condition-->
<core:if test="${Environment == CORP}">
<log:warn>Processing Non-CAPEX Purchase Order</log:warn>
<jira:AddComment comment="Assigned to Finance for approval." issue-key="${issue.key}" />
<jira:TransitionWorkflow key="${issue.key}" user="${workflowUser}" workflowAction="${workflowStep}" />
<jira:AssignIssue key="${issue.key}" assignee="mhuser" />
</core:if>
<core:if test="${Environment == Finance}">
<log:warn>Processing Non-CAPEX Purchase Order</log:warn>
<jira:AddComment comment="Assigned to Finance for approval." issue-key="${issue.key}" />
<jira:TransitionWorkflow key="${issue.key}" user="${workflowUser}" workflowAction="${workflowStep}" />
<jira:AssignIssue key="${issue.key}" assignee="mhuser" />
</core:if>
<core:if test="${Environment == Sales}">
<log:warn>Processing Non-CAPEX Purchase Order</log:warn>
<jira:AddComment comment="Assigned to Finance for approval." issue-key="${issue.key}" />
<jira:TransitionWorkflow key="${issue.key}" user="${workflowUser}" workflowAction="${workflowStep}" />
<jira:AssignIssue key="${issue.key}" assignee="mhuser" />
</core:if>

<!--IT Condition-->
<core:if test="${Environment == IT}">
<log:warn>Processing Non-CAPEX Purchase Order</log:warn>
<jira:AddComment comment="Assigned to IT for approval." issue-key="${issue.key}" />
<jira:TransitionWorkflow key="${issue.key}" user="${workflowUser}" workflowAction="${workflowStep}" />
<jira:AssignIssue key="${issue.key}" assignee="mhuser" />
</core:if>
<!--Delware Condition--> 
<core:if test="${Environment == Delaware}">
<log:warn>Processing Non-CAPEX Purchase Order</log:warn>
<jira:AddComment comment="Assigned to Delware Operations for approval." issue-key="${issue.key}" />
<jira:TransitionWorkflow key="${issue.key}" user="${workflowUser}" workflowAction="${workflowStep}" />
<jira:AssignIssue key="${issue.key}" assignee="rcuser" />
</core:if>
<!--Chambersburg Condition-->
<core:if test="${Environment == Chambersburg}">
<log:warn>Processing Non-CAPEX Purchase Order</log:warn>
<jira:AddComment comment="Assigned to Chambersburg Operations for approval." issue-key="${issue.key}" />
<jira:TransitionWorkflow key="${issue.key}" user="${workflowUser}" workflowAction="${workflowStep}" />
<jira:AssignIssue key="${issue.key}" assignee="rcuser" />
</core:if>
<!--Falmouth Condition-->
<core:if test="${Environment == Falmouth}">
<log:warn>Processing Non-CAPEX Purchase Order</log:warn>
<jira:AddComment comment="Assigned to Falmouth Operations for approval." issue-key="${issue.key}" />
<jira:TransitionWorkflow key="${issue.key}" user="${workflowUser}" workflowAction="${workflowStep}" />
<jira:AssignIssue key="${issue.key}" assignee="lwuser" />
</core:if>
<!--Staten Island Condition-->
<core:if test="${Environment == StatenIsland}">
<log:warn>Processing Non-CAPEX Purchase Order</log:warn>
<jira:AddComment comment="Assigned to Staten Island Operations for approval." issue-key="${issue.key}" />
<jira:TransitionWorkflow key="${issue.key}" user="${workflowUser}" workflowAction="${workflowStep}" />
<jira:AssignIssue key="${issue.key}" assignee="rcuser" />
</core:if>
<!--Lombard Condition-->
<core:if test="${Environment == Lombard}">
<log:warn>Processing Non-CAPEX Purchase Order</log:warn>
<jira:AddComment comment="Assigned to Lombard Operations for approval." issue-key="${issue.key}" />
<jira:TransitionWorkflow key="${issue.key}" user="${workflowUser}" workflowAction="${workflowStep}" />
<jira:AssignIssue key="${issue.key}" assignee="lkuser" />
</core:if>
<!--Salem Condition-->
<core:if test="${Environment == Salem}">
<log:warn>Processing Non-CAPEX Purchase Order</log:warn>
<jira:AddComment comment="Assigned to Salem Operations for approval." issue-key="${issue.key}" />
<jira:TransitionWorkflow key="${issue.key}" user="${workflowUser}" workflowAction="${workflowStep}" />
<jira:AssignIssue key="${issue.key}" assignee="lguser" />
</core:if>
<!--NHBH Plaistow Condition-->
<core:if test="${Environment == NHBH}">
<log:warn>Processing Non-CAPEX Purchase Order</log:warn>
<jira:AddComment comment="Assigned to NHBH Operations for approval." issue-key="${issue.key}" />
<jira:TransitionWorkflow key="${issue.key}" user="${workflowUser}" workflowAction="${workflowStep}" />
<jira:AssignIssue key="${issue.key}" assignee="jmuser" />
</core:if>

</core:forEach>
</jira:Login>
</JiraJelly>

Any help would be greatly appreciated. Thanks for reading.

-Peter

1 answer

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 2, 2017

Unfortunately there is no automated jelly->groovy conversion utility.

You will have to do it in steps - after you work out the main parts it should be straightforward. There is a guide here: https://scriptrunner.adaptavist.com/latest/jira/recipes/jelly-migration.html

 

Peter Gomez January 3, 2017

 

I have looked over the link you provided, but it doesn't give me any info on how to assign users to specific issues based on project. Should I be doing an if/then command? Sorry, my groovy commands are very limited...

 

-Peter

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events