issueService.validateCreate fails when creating an issue with REQUIRED custom field

I have a REQUIRED single select customfield set for a given screen which is mapped to a given issue in JIRA.(the one i will be creating programmatically). The value to be set for these fields is obtained from another dropdown in a transition screen.

When I try to create the issue programmatically using a jira plugin, it fails probably because a value is REQUIRED for the customfield(despite setting a default value for the field in JIRA) . If I dont make the field REQUIRED, i am able to create the issue and also update its value using 

customField.updateValue()

after creating the issue.

But I want to keep the REQUIRED option else I cannot remove the None option from the dropdown. 

Ive tried setting the value using the below code before the issue is created.

issueInputParameters.addCustomFieldValue(custFieldId,"value to set");
UpdateValidationResult update = issueService.validateUpdate(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(), issue.getId(), issueInputParameters); 

if (update.isValid()) {		  issueService.update(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(), update);

 System.out.println("Update is valid"); //It prints this
 }else{	 
   
 System.out.println("Update is not valid");
 }
IssueLinkManager issueLinkManager = ComponentAccessor.getIssueLinkManager();
CreateValidationResult createValidationResult = issueService.validateCreate(user, issueInputParameters);

but createValidationResult fails and the issue is not created. Where am I going wrong ? Ive also tried using 

issueInputParameters.setSkipScreenCheck(true)

but with no luck. Can anyone please help me to create the issue keeping the REQUIRED field option set.

1 answer

This widget could not be displayed.

Hi Komail! This looks like a developer question, so it would be better to post it at community.developer.atlassian.com that's where our developer community hangs out :)

Cheers,

Ana

Hi Ana, I've raised the same question  there . I was using this forum earlier and got replies to my other questions regarding jira development, so assumed that its the right one :)

https://community.developer.atlassian.com/t/issueservice-validatecreate-fails-when-creating-an-issue-with-required-custom-field/4009

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

130 views 2 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you