I am working on Scriptrunner post function - Send Custom Email. I am needing to have the condition be if the Request Type is either Option A, Option B, or Option C. Each thing I have tried is not working as I can't seem to figure out the operator for it to be any of those.
Hi @Bryan Trummer - ReleaseTEAM
Could you please specify the field type you use for the Request Type? Is it a Single Select / Multi Select List?
I have run a quick test in my environment and don't seem to be encountering any issues.
Below is the sample code that I have tested with:-
def currentIssue = Issues.getByKey(issue.key)
def sampleListValue = currentIssue.getCustomFieldValue('Sample List').toString()
sampleListValue == 'Option 1'
Please note that the sample working code above is not 100% exact to your environment. Hence, you will need to make the required modifications.
Below is a screenshot of the Post-Function configuration:-
I have run the test using ScriptRunner's HAPI feature.
Below are a couple of test screenshots:-
1. Create an issue and set the value for the Sample List field to Option 1, as shown in the screenshot below:-
2. Transition the issue to In Progress as shown in the screenshot below:-
3. As expected, the email is delivered as shown in the screenshot below:-
Thank you and Kind regards,
Ram
Hi @Ram Kumar Aravindakshan _Adaptavist_ - Thank you for the response! For the field type is the JSM standard field 'Customer Request Type' so I am not 100% certain the field type but it behaves like a single select list.
For the samplelistvalue to add multiple options in there do I just separate with a comma and then include the single quotes?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Bryan Trummer - ReleaseTEAM
Sorry for the delay; I've been pretty busy.
In regards to your case, it's pretty much the same. The only thing you will need to modify the field name accordingly.
Below is the sample updated code for your reference:-
def currentIssue = Issues.getByKey(issue.key)
def sampleListValue = currentIssue.getCustomFieldValue('Customer Request Type').toString()
sampleListValue == 'st/bug'
As shown in the updated sample code, update the field name to 'Customer Request Type'.
Next, add a check to see what is the value of the Customer Request Type field. So the In the case of testing with a Bug issue type, the value is <ISSUE_KEY>/bug all in lowercase.
In the test above, I am testing with a project called Service Test, and the key is ST. So when adding the condition, I am setting it to st/bug. You will need to modify this according to the Project and Issue type you are using.
Below is an updated screenshot for your reference:-
Below is an updated test screenshot:-
The email is also returned as expected:-
I hope this helps to solve your question. :-)
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.