Need help on executing script using adaptavist scriptrunner Edited

Need help on running scriptrunner tasks.


Hi All,

I am having few customizations to be made, I have been asked to use scriptrunner to write the scripts. Can anyone please help me with any complete cycle of script.?
I am having backgruond in Java, so groovy (scripting language of the tool) shouldn't be an issue, but I don't know from where and how to run the scripts.
The problem statement is, I am having 1 custom field, and I need to mark it compulsory for specific status and I also want to make it display  on the specific condition.(For instance the custom field should be only displayed when issue status is in "In progress" or "completed" state)

Any suggestions are welcomed.Moreover any document/article/video as well should be fine if it depicts a complete cycle of scriptrunner flow.

 

Thanks

2 answers

0 votes
Alexey Matveev Community Champion Dec 27, 2017

If you are on Jira Server/Data Center then you could use behaviours

https://scriptrunner.adaptavist.com/4.3.1/jira/behaviours-overview.html#_description

Thanks for update.  

I have written Script to connect database having table containing 

data. Still it is retrieving null in output.

Please suggest me if any step left ??

That is not the right approach to writing the Behaviours and validators to solve your problems.

Could you explain where you're actually stuck

Alexey Matveev Community Champion Jan 02, 2018

You should use

getFieldByName to get your custom fields

def cs1 = getFieldByName("customField1Name")

def cs2 = getFieldByName("customField2Name")

then you should check the value and set the other field to required

if (cs1.getValue().equals("value")) {

cs2.setRequired(true);

} else {

cs2.setRequired(false);

}

ok. Thank you so much Alexey.

We have 2 custom fields and we want to change the value of field 1 dynamically based on the value of field 2(For instance, when field 2 will have some value then field1 should be mandatory and if field 2 has no value then field 1 should be non mandatory).We need some kind of function in scriptrunner which is similar to  jQuery onChange() .Please let me know how this could be achieved ?

Ok, that is the sort of thing Behaviours are for.

It seems you have not yet looked at creating a Behaviour, otherwise you would have seen that it asks you for information that can guide you through this reasonably easily.

Select a field to run the behaviour on, (Probably field 1 in your case), and then add the code for your logic.  When you go into the editor for the code, look beneath it, as it has a quick reference guide for things like "get current field data", "set field data on-screen", "show/hide field" and "set field optional/required".

JIRA_Reference.PNGHere in above image can you please tell that which method will be helpfull for below task :

"We have 2 custom fields and we want to change the value of field 1 dynamically based on the value of field 2(For instance, when field 2 will have some value then field1 should be mandatory and if field 2 has no value then field 1 should be non mandatory).We need some kind of function in scriptrunner which is similar to  jQuery onChange() .Please let me know how this could be achieved ?"

I'd use the getFieldByName and setRequired you found in the table of help.  It's good to read and learn new stuff.

yes...Can you  please help to suggest to solve below problem 

"I have  2 custom field (for DATE) , If I select any date from 1 field than in another filed DATE PICKER should show equal or greater date of SELECTED date of 1st field. I can say in 2nd date field DATE PICKER should DISABLE the EARLIER DATE  from selected 1st Field date. And the 2nd field should not accept earlier date than selected date of 1st field [if user change manually after selecting 1st date]

So can you suggest how can I achieve ??   "

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 25, 2018 in Jira

Atlassian Research Workshop opportunity on Sep. 28th in Austin, TX

We're looking for participants for a workshop at Atlassian! We need Jira admins who have interesting custom workflows, issue views, or boards. Think you have a story to sha...

445 views 7 5
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