Purchase Order Processing

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

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

 

 

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
Community showcase
Published Oct 31, 2018 in Marketplace Apps

Marketplace Spotlight: Zephyr

Hello Atlassian Community! Each month, we run a series of Spotlights to highlight Marketplace vendors and apps that our team thinks this Community would find valuable. In last month's Spotlig...

414 views 0 3
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you