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,070
Community Members
 
Community Events
184
Community Groups

Set insight field value on request form

I have a request form with some insight fields on it. I am trying to set the value of the insight fields on the form (this is BEFORE the issue is created). The script looks like:

 

def countryField = getFieldById("customfield_16805")
def storedObjectBean = objectFacade.loadObjectBean(theCountryId)
countryField.setError(storedObjectBean.toString()) // this works -> Canada (TVM-256028)

//none of these work
//countryField.setFormValue(storedObjectBean)
//countryField.setFormValue([storedObjectBean])
//countryField.setFormValue(theCountryId)
//countryField.setFormValue([theCountryId])

Since the issue is not yet created, there is no issue variable and I cannot use the mutableIssue.setCustomFieldValue() which usually works.

Any ideas?

2 answers

0 votes
Ilya Turov
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.
Oct 07, 2019

Hey, I don't quite understand the question, since you are saying that there's method that works

Ilya Turov
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.
Oct 08, 2019

oh, i didn't notice the "working" part was about setting error message, not field value.

anyways, looks like it's impossible to do via behaviour:

1. https://community.atlassian.com/t5/Jira-Core-questions/Behaviours-insight-set-field-value/qaq-p/197420

2. https://community.atlassian.com/t5/Adaptavist-questions/Insight-customfield-not-compatible-with-behaviours/qaq-p/679429

but you can add a postfunction on creation transition and set it there

0 votes
Zoi Raskou
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.
Oct 07, 2019

Hello Mario,

First of all, are you working on Cloud or Server?
You can use a mutable issue as you mentioned, why can't you use it? (I imagine you are using updateIssue when you use mutableIssue.setCustomFieldValue)
Also, this can be easily done with a post function, which will update the custom field's value. 

On server.

The script is run on the customer portal, during the initial submission of the form, I.E. the issue is not yet created (hence why there isn't an issue variable and the web IDE reports an error when using it)

The scenario requires all operations be done on the portal in real time while the client is populating the fields

Zoi Raskou
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.
Oct 08, 2019

Then the only solution would be to use a mutable issue. You can paste your script here and we can help you find why it's not working for you. 

I really do not know how to explain it better. I am using service desk mapping for the behavior. If I try to use

 

MutableIssue mutableIssue = (MutableIssue) issue;

 

I get "The varibale [issue] is undeclared" which is normal, since there is no issue created yet, hence I cannot use the methods provided there.

Zoi Raskou
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.
Oct 08, 2019 • edited

I am sharing a piece of my script that uses mutable issue. Hope it helps:

IssueService issueService = ComponentAccessor.getIssueService()
IssueInputParameters issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters
.setProjectId(inputs.projectID)
.setSummary(subject)
.setDescription(description)
.setIssueTypeId(inputs.IssueTypeID)
.setPriorityId("3")
.setReporterId("admin")
.setAssigneeId("admin")

ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
// Create new issue from email
IssueService.CreateValidationResult createValidationResult = issueService.validateCreate(user, issueInputParameters)
if (createValidationResult.isValid())
{
IssueService.IssueResult createResult = issueService.create(user, createValidationResult)
if (!createResult.isValid())
{
log.error("Error while creating the issue.")
}
}

def testIssue = createValidationResult.getIssue()

MutableIssue mutableIssue = issueManager.getIssueObject(testIssue.getId())

mutableIssue.setCustomFieldValue(textCf, "Some text value")

Where is this run? I'm getting: inputs is undeclared

Zoi Raskou
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.
Oct 08, 2019

This is part of the script. As the script does something completely different there is no point in me pasting it here. You will need to adjust the script to your needs instead of using it as is. 

Inputs, subject, description, and priority ID will be different for you. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events