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,559,883
Community Members
 
Community Events
185
Community Groups

issue getting value on backend

Hi Community,

 I am facing an issue to fetch custom-field value in the backend(Scriptrinner) multiple times.

I am using 1 custom field and one system field to make a condition.

1- Reporter

2- Custom-Field A

I used Reporter to fetch some information and set it on the form Custom-Field A then I get the value of Custom-Field A e.g. "Apple: in the backend and make conditions to perform a certain action. I get the backend value e.g. 112233 only once. if I change the reporter the new value sets on the form e.g. "Mango" however, in the back it wont change and remain same value e.g. 112233. How i can achieve that whenever my reporter change the the value on the form and back end both change.

Scripting on CustomField A

Thanks.

 

2 answers

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Mar 29, 2023

I am not sure I understand what you are trying to do here.  Could you explain what you are trying to do with each script?

Script A looks like it gets the reporter, then sets a value on customfield_12345, then sets it readonly.

Script B looks like it is just reading a value from customfield_12345.

There is a problem with doing this - you can't know which way around the scripts are going to run.  customfield_12345 may have its original value (or default or available if it's a create screen) when the second script executes, and then the first script changes it and sets it read only. 

I would suggest changing the second script such that it runs the same logic as the first one - working out what the first script is going to do and use that value

0 votes
Radek Dostál
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.
Mar 29, 2023

Well, this is a tad too generic description. Any code, what you're currently doing, how?

on reporter field i added scriptcode is : 

import java.lang.String
import com.atlassian.jira.component.ComponentAccessor;
import com.onresolve.jira.groovy.user.FieldBehaviours;
import com.atlassian.jira.user.ApplicationUser;

def reporterUser = getFieldById(getFieldChanged());
String reporterValue = reporterUser.getFormValue();
def userValue = ComponentAccessor.getUserManager().getUserByName(reporterValue);
def values = null;

String employeeCompany = ComponentAccessor.getUserPropertyManager().getPropertySet(userValue).getString("jira.meta.Company");
def employeeidCompany = getFieldById("customfield_12345");
employeeidCompany.setFormValue(employeeCompany);
employeeidCompany.setReadOnly(true);
**********************************************************************************************
in custom field A, I added scriptCode is: 
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
def companyField = getFieldById("customfield_12345");
String companyFieldValue = companyField.getFormValue();

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events