Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,560,040
Community Members
 
Community Events
185
Community Groups

Help with Jira SIL (set custom field on a ticket where it doesn't exist)

Edited

Hello all,

I would like to add a customfield_12555 into a jira issue when a condition matches. But it only works if a ticket is created with it. The type of issue what I'm creating, doesn't have #{Tracking} (customfield_12555) field by default. I don't want to change the background config for this (messing with screens, fields or schemes etc)

So when a ticket is created with #{Tracking} by default, I'm able to pass the condition. For eg:

 

if (contains(reporter, "jira_api_admin") and contains(labels, "Tracking-importer")) {

    #{Tracking} = "black";

} else {

return false;

}
When it is not present in the ticket at all, I want it to add it and give it a value.
How do I do it? This is the first time I'm coming across this issue as whatever I'm working on, it only creates the ticket with only necessary fields.
I also tried using customfield_12555 instead of #{Tracking}, didn't work.
if (contains(reporter, "jira_api_admin") and contains(labels, "Tracking-importer")) {

    customfield_12555 = "black";

} else {

return false;

}

 

To test if my condition is working, I added addComment function and it works perfectly fine.

 

Any help would be appreciated.

 

EDIT: This is added as a SIL listener, targeting "Issue Created" for a specific project.

Thanks,
Arun.

1 answer

Hello @Arun Chatterjee ,

Is my understanding correct that you are trying to set field values for a field that is not present on the screen and maybe even missing from this project? I don`t think it will work that way if the field is not in the right context. 
I haven`t tried it, but probably you can use admAddFieldToScreen after your condition (more details about the routine is here https://appfire.atlassian.net/wiki/spaces/PSJ/pages/15488327/admAddFieldToScreen

Please correct me if my understanding of your use case is wrong...

Hey Anna,

Yes, I'm trying to add a customfield that exists on the project but doesn't show up on the jira issue once its created (automatically). Normally, I have to go to Edit and add some value to the customfield_12555 to show up on the Jira issue. while I'm trying to automate this via SIL.

I tried admFieldToScreen option. If I'm understanding it right, I'm trying to run this post the "Issue Created" via SIL listener. So the issue would have been already created. Does admFieldToScreen apply here?.

Thanks for the help!

Hi @Arun Chatterjee ,

I`ve just tested your scenario on my side and it works just fine. I slightly modified your script, because the reporter normally gives you a user key like JIRAUSER1234, not a user name. So it looks like this: 

JUser rep= getUser(reporter);
if (rep.username == "anna_admin") {
%key%.customfield_16500 = "black";
} else {
return false;
}

But for some Jira versions before GDPR changes existing user keys may still have the same user key value as user name, so maybe it`s your case. 

Based on what you said: "Yes, I'm trying to add a custom field that exists on the project but doesn't show up on the jira issue once its created (automatically). Normally, I have to go to Edit and add some value to the customfield_12555 to show up on the Jira issue." That`s the normal operation of any empty custom field. So if you don`t type any value during the issue creation step, you will not see the field until you go to Edit to add field value. Or alternatively, you may have different screens for creating/edit/view with different sets of fields. Also, the issue may be in the field type Tracking. Is it coming from another 3d app? In my test I tried Jira`a text custom field. 

As the reason for it may be different and requires a deeper investigation, I would offer you to open a support request here and continue working on this with me in frames of a support ticket (in the ticket description you can also include a link to this community question for visibility). 

Best regards,
Anna

Like # people like this

Thanks for the response, @Anna Hryhoruk _Appfire_ 

I did this and it does not work still :( For testing, I added addComment to test if it actually detects the if loop based on the additional conditions, it added the comment. but %key%.customfield_12555 did not have any effect on this.

customfield_12555 for me is a Label. I normally add = "value" or for multiple values, { "val1" } + { "val2" } worked for me, where site normally has any value. But not in this case. So I'm not so sure what the issue is here. I'm using Jira Server 8.1.1 if that helps. We will be migrating to Cloud or DC very soon. I'll try not to hinder you further here :) I'll see if I can open a ticket with you guys. Thanks for the help so far, Anna.

Like Anna Hryhoruk _Appfire_ likes this

Hello @Arun Chatterjee ,

When you wrote that it`s a level field, I was pretty sure that it may be a reason. So because of curiosity, I performed tests with the label and it works on my end as expected. Therefore, it should be something else so I started to think about differences we may have in configuration and I found something. Could you please ensure that your SIL Listener is Synchronous :2023-05-12 13 24 53.png

So the settings should look like this: (without checkmark near Asynchronous )

2023-05-12 13 25 53.png


I think it may be the reason because since I`ve changed it to Async, I received the same behavior as you had - the comment was added but the field value was not updated. 

Some documentation about the differences Synchronous vs Asynchronous 
Please let me know if that solves the mystery. 


Best regards,
Anna

Like Arun Chatterjee likes this

hey, thanks for responding again. you've been really helpful!

as for the sync setting, it seems to be in "Sync" as shown in the image above. We never have that ticked to be "Asynchronous" in our other scripts.

i thought may be doing "Async" will work, but apparently not. I just tried. No bueno :(

Suggest an answer

Log in or Sign up to answer