Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to make linked issues field mandatory for specific resolution selected in transition screen?

P_D_ Foerster
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.
March 6, 2019

Hi there,

I am trying to get the following to work:

If I execute the action Resolve and select the resolution 'Existing change' within the transition screen the linked issues field should be required so that I have to create an issue link to at least one issue of type Change.

To achieve this I use the 'Linked Issue(s) Validator (JMWE add-on)'.

  • Mode = Require the creation of issue links on the transition screen
  • Issue Link Type = Any (except Issue/Subtask and Epic/Story)
  • Min. Linked Issues = 1
  • Max. Linked Issues = (unbound)
  • Condition on linked issues:
    • linkedIssue.getAsString("issuetype") == "Change"
  • Conditional validation = active
    • // Execute only if resolution = 'Existing change'
      log.debug("Im Screen ausgewählter Resolution Name ist: ${transientVars.get("issue").get("resolution")?.name}")
      log.debug("Im Screen ausgewählte Resolution ID ist: ${transientVars.get("issue").get("resolution")?.id}")

      transientVars.get("issue").get("resolution")?.id == 10201

 

The condition on linked issues works fine, i.e. if I apply this no matter which resolution value I select.

However, if I use the conditional validation stated above the validation script returns false and is not applied.

 

I added some logging. According to the variables values it should work but it doesn't

2019-03-06 11:48:37,285 http-nio-8070-exec-180 DEBUG pfoerster 708x46034x1 f4b4ig 1.2.3.4 /secure/CommentAssignIssue.jspa [c.i.j.plugins.validators.IssueLinkingValidator] Executing Validator with [transientVars={issue=SWR-16, configuration=com.opensymphony.workflow.config.DefaultConfiguration@6704fa0f, proj=Project: SWR, project=[GenericEntity:Project][name,Support workflows rework][assigneetype,2][description,][projecttype,business][id,17140][counter,0][avatar,14753][originalkey,SWR][url,null][lead,sa-jira-service-desk][key,SWR], currentSteps=[SimpleStep@2[owner=, actionId=0, status=null]], store=com.opensymphony.workflow.spi.ofbiz.OfbizWorkflowStore@54f39316, descriptor=com.atlassian.jira.workflow.ImmutableWorkflowDescriptor@753507e1, userKey=pfoerster, originalAssigneeId=sa-jira-service-desk, entry=com.opensymphony.workflow.spi.SimpleWorkflowEntry@318840bb, context=com.opensymphony.workflow.basic.BasicWorkflowContext@46a9168c, originalissueobject=SWR-16, actionId=31, pkey=SWR, transaction=com.atlassian.jira.transaction.TransactionSupportImpl$TransactionImpl@3a9c3b87};args={maxLinkedIssues=, groovyExpression=linkedIssue.getAsString("issuetype") == "Change", validatorMode=requireNewLinks, minLinkedIssues=1, selectedLinkType=*:*, errorMessage=Link the existing issue of type Change., conditionalValidationScript=// Execute only if resolution = 'Existing change'
log.debug("Im Screen ausgewählter Resolution Name ist: $⁣{transientVars.get("issue").get("resolution")?.name}")
log.debug("Im Screen ausgewählte Resolution ID ist: $⁣{transientVars.get("issue").get("resolution")?.id}")

transientVars.get("issue").get("resolution")?.id == 10201, checkAllLinkedIssues=no, class.name=com.innovalog.jmwe.plugins.validators.IssueLinkingValidator, conditionalValidation=yes};ps=com.opensymphony.module.propertyset.ofbiz.OFBizPropertySet {
}
]
2019-03-06 11:48:37,286 http-nio-8070-exec-180 DEBUG pfoerster 708x46034x1 f4b4ig 1.2.3.4 /secure/CommentAssignIssue.jspa [c.innovalog.groovy.GroovyExpression] [Class:IssueLinkingValidator ; Worflow:Problem workflow 4.0.0 ; Transition:31 ; Issue:SWR-16] Im Screen ausgewählter Resolution Name ist: Existing change
2019-03-06 11:48:37,287 http-nio-8070-exec-180 DEBUG pfoerster 708x46034x1 f4b4ig 1.2.3.4 /secure/CommentAssignIssue.jspa [c.innovalog.groovy.GroovyExpression] [Class:IssueLinkingValidator ; Worflow:Problem workflow 4.0.0 ; Transition:31 ; Issue:SWR-16] Im Screen ausgewählte Resolution ID ist: 10201
2019-03-06 11:48:37,287 http-nio-8070-exec-180 INFO pfoerster 708x46034x1 f4b4ig 1.2.3.4 /secure/CommentAssignIssue.jspa [c.i.j.plugins.validators.IssueLinkingValidator] IssueLinkingValidator: conditional validation script returned false. Skipping validator.
2019-03-06 11:48:37,298 http-nio-8070-exec-180 DEBUG pfoerster 708x46034x1 f4b4ig 1.2.3.4 /secure/CommentAssignIssue.jspa [c.i.j.plugins.functions.ClearFieldValueFunction] Create new holder with items - [com.atlassian.jira.issue.history.ChangeItemBean@2c786373[fieldType=jira,field=status,from=1,fromString=Open,to=5,toString=Resolved,created=<null>]]
2019-03-06 11:48:37,298 http-nio-8070-exec-180 DEBUG pfoerster 708x46034x1 f4b4ig 1.2.3.4 /secure/CommentAssignIssue.jspa [c.i.j.plugins.functions.ClearFieldValueFunction] Executing function with [transientVars={issue=SWR-16, configuration=com.opensymphony.workflow.config.DefaultConfiguration@6704fa0f, proj=Project: SWR, project=[GenericEntity:Project][name,Support workflows rework][assigneetype,2][description,][projecttype,business][id,17140][counter,0][avatar,14753][originalkey,SWR][url,null][lead,sa-jira-service-desk][key,SWR], currentSteps=[SimpleStep@2[owner=, actionId=31, status=Not Done]], store=com.opensymphony.workflow.spi.ofbiz.OfbizWorkflowStore@54f39316, descriptor=com.atlassian.jira.workflow.ImmutableWorkflowDescriptor@753507e1, userKey=pfoerster, originalAssigneeId=sa-jira-service-desk, entry=com.opensymphony.workflow.spi.SimpleWorkflowEntry@318840bb, oldStatus=IssueConstantImpl[[GenericEntity:Status][sequence,2][statuscategory,2][name,Open][iconurl,/images/icons/statuses/open.png][description,The issue is open and ready for the assignee to start work on it.][id,1]], context=com.opensymphony.workflow.basic.BasicWorkflowContext@46a9168c, createdStep=SimpleStep@6[owner=, actionId=0, status=Done], originalissueobject=SWR-16, actionId=31, pkey=SWR, changeItems=[com.atlassian.jira.issue.history.ChangeItemBean@2c786373[fieldType=jira,field=status,from=1,fromString=Open,to=5,toString=Resolved,created=<null>]], transaction=com.atlassian.jira.transaction.TransactionSupportImpl$TransactionImpl@3a9c3b87};args={throwExceptions=false, class.name=com.innovalog.jmwe.plugins.functions.ClearFieldValueFunction, fields=customfield_12442, useGroovyCondition=false, full.module.key=com.innovalog.jmwe.jira-misc-workflow-extensionsClearFieldValue-function};ps=com.opensymphony.module.propertyset.ofbiz.OFBizPropertySet {
}
]
2019-03-06 11:48:37,298 http-nio-8070-exec-180 DEBUG pfoerster 708x46034x1 f4b4ig 1.2.3.4 /secure/CommentAssignIssue.jspa [c.i.workflow.utils.FieldValueService] Set custom field value [field=Follow-up,type=com.atlassian.jira.issue.customfields.impl.DateTimeCFType@644f0285,oldValue=null,newValue=null]
2019-03-06 11:48:37,299 http-nio-8070-exec-180 DEBUG pfoerster 708x46034x1 f4b4ig 1.2.3.4 /secure/CommentAssignIssue.jspa [c.i.workflow.utils.FieldValueService] Issue [SWR-16] got modfied fields - [{attachment=com.atlassian.jira.issue.ModifiedValue@25812757, customfield_11340=com.atlassian.jira.issue.ModifiedValue@31b09ac0, issuelinks=com.atlassian.jira.issue.ModifiedValue@5e3c047e, customfield_12442=com.atlassian.jira.issue.ModifiedValue@37c6d286, fixVersions=com.atlassian.jira.issue.ModifiedValue@1b51e0b6, resolution=com.atlassian.jira.issue.ModifiedValue@2e820f86}]
2019-03-06 11:48:37,299 http-nio-8070-exec-180 DEBUG pfoerster 708x46034x1 f4b4ig 1.2.3.4 /secure/CommentAssignIssue.jspa [c.i.j.plugins.functions.ClearFieldValueFunction] Release holder with items - [com.atlassian.jira.issue.history.ChangeItemBean@2c786373[fieldType=jira,field=status,from=1,fromString=Open,to=5,toString=Resolved,created=<null>]]

 

What am I missing? Do you have any ideas what might be wrong?

 

Regards,
Patrice

1 answer

1 accepted

0 votes
Answer accepted
David Fischer
Community Champion
March 6, 2019

Hi Patrice,

Try comparing with "10201". I believe the id is actually a string (containing a number). 

Also, to access the current issue, just use the {{issue}} variable. 

P_D_ Foerster
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.
March 7, 2019

Hi @David Fischer ,

thank you! Comparing it as a number was the problem.
Comparing it as a string solved it :)

Can you please answer one more question (since I'm new to writing scripts):

Why is it possible to get the resolution from the issue variable?
I thought the issue variable holds all data already persisted for the current issue.
Because I want to compare resolution id that is not persisted yet I assumed that I have to use the transientVars variable because the value is selected in the transition screen.

Ah and using

issue.get("resolution")?.id == "10201"

also works fine :)

Cheers,
Patrice

David Fischer
Community Champion
March 7, 2019

The {{issue}} variable holds the issue object being modified during the transition. The original (persisted) issue is in the {{originalIssue}} variable. 

Like P_D_ Foerster likes this
P_D_ Foerster
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.
March 7, 2019

Alright, so for cases where I just need issue data I don't need to use transientVars then.

Suggest an answer

Log in or Sign up to answer