Issue summary with conditional logic & smart values
Asked by David Quiram:

I want an issue summary to contain custom field information but with a little logic.

Stick with me here...

The issue will have one of two potential date fields filled in depending on other options in the issue. So for ease we will call them issue.CustomDate1 and issue.CustomDate2

I want the issue Summary to have some text and then insert CustomDate1 -OR- CustomDate2, whichever field has a value as the other will be null.

How would that be scripted?


Answers:
author: Jack Brickey
body: if one is always empty try just including both...

Action - edit issue - Summary

{{issue.summary}} - {{issue.due date}} - {{issue.other date}}

this will append both dates but if say the first is "none" then you get this...

*this is my summary - - 2202-02-23*

as an example

comments: author: David Quiram
body: On a low level, this *could* work. We would just a random space that nobody will realize except me.

As someone who likes easy solutions, this appeases me ?

As someone who is OCD and is unnecessarily focused on formatting, this annoys me ?


author: Bill Sheboy
body: Hi [@David Quiram](/t5/user/viewprofilepage/user-id/4501008)

Yes, and...to what Jack suggests:

1. If one is \*always\* null, just put them side-by-side and one will disappear, without the extra delimiter: {{issue.summary}} - {{issue.firstDate}}{{issue.secondDate}}
2. Otherwise, you could use the conditional logic to do this in-line or use if/else components for extra testing: <https://support.atlassian.com/cloud-automation/docs/jira-smart-values-conditional-logic/>

I recommend #2 as \*always\* may be difficult to enforce/remember.

Kind regards,  
Bill


author: Jack Brickey
body: You can add an if/else condition to check one of your date fields for empty and if empty then use the other date, if not the use that date.

now what I find worrisome is the fact that you could have a date in both so I think you need to consider this in your automation to help flag this apparent error condition.


author: Jack Brickey
body: Yes as [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) says You can omit the delimiter. I left it in thinking it might be nice to be able to identify which date was applied based on placement in summary.


author: David Quiram
body: [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) So I agree and would love to use conditional logic for this task. I had reviewed that article you linked numerous times before posting here and I don't understand how I would script it out.   

I know it's possible, just don't know what syntax to use. There's no clear example on that article referencing my exact situation from what I can tell.


author: Bill Sheboy
body: On that page, please take a look at the example for the exists() function to do what you ask: <https://support.atlassian.com/cloud-automation/docs/jira-smart-values-conditional-logic/#exists>

That function checks if a field has a value, and then uses it when present.


author: David Quiram
body: Ahh! Thank you for pointing me to that specific function. I think I have an idea of how to script this now... time for testing.


author: Curt Holley
body: Hi [@David Quiram](/t5/user/viewprofilepage/user-id/4501008)

At a high level it would go like this:

![dd.png](https://community.atlassian.com/t5/image/serverpage/image-id/184915i164230669802B715/image-size/large?v=v2&px=999 "dd.png")

by using the {{issue.Summary}} smart value, the automation repopulates the existing summary. Then by added {{issue.duedate}} (or in your case, one of your custom date fields) you get the date after the Summary.

You could simply do a rule for each field or use an If/else condition.

You can also format the date to best suit your needs. See [Jira smart values - date and time \| Cloud automation Cloud \| Atlassian Support](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/)

comments: author: David Quiram
body: So this Summary is being filled in on a linked issue during a Create Issue action in an automation flow. Hence why I was looking for conditional logic in smart values.


author: Curt Holley
body: That can be done [@David Quiram](/t5/user/viewprofilepage/user-id/4501008) via branching and some smart values. Best you state your complete use case so we can provide more focused responses for you.


author: David Quiram
body: OK, hopefully this helps clarify everything for you.

Automation will check an issue on creation and create a linked issue in another project if it meets specifics requirements. That is all working just fine.

On the created linked issue, I would like the Summary to include some text and either CustomDate1 or CustomeDate2, whichever field has a value as the other field will be null.


author: Curt Holley
body: In that case [@David Quiram](/t5/user/viewprofilepage/user-id/4501008) it will be very much as [@Jack Brickey](/t5/user/viewprofilepage/user-id/853369) has suggested, but as part of the creation of the linked issue:

Action - Create issue

Summary: {{triggerIssue.summary}} - {{triggerIssue.SomeOtherText}} - {{triggerIssue.due date}} - {{triggerIssue.other date}}

Resulting in something like:

*this is my summary* - *this is the other text - - 2202-02-23*

Obviously you need to define where from the trigger issue you are getting the extra text from. And as discussed here, you can format the summary field to your requirements and add if/else or any other conditional logic required.

But by using the triggerIssue smart values in the creation of the linked issue, as generated by your currently working rule using the "Issue Created" trigger, should see the results you are after in the summary field of the linked issue.


Tags: cloud