Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Script postfunction on jira cloud

Yogesh Mude
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.
August 26, 2018 edited

HI Team,

 i wanted to fetch the radio button custom field value and on the basis of custom field values, i want to set this to another custom field value.


def customFields = get("/rest/api/2/field")
.asObject(List)
.body
.findAll { (it as Map).custom } as List<Map>


def newSQL = customFields.find { it.name == 'custom_field 1' }?.id
def newUser = customFields.find { it.name == 'customf_field 2' }?.id
def newLibrary = customFields.find { it.name == 'custom_field 3' }?.id
//def vaRequired = customFields.find { it.name == 'custom field 4' }?.id

def newSQLFieldValue = issue.fields[newSQL] as String
def newUserFieldValue = issue.fields[newUser] as String
def newLibraryFieldValue = issue.fields[newLibrary] as String

if(newSQLFieldValue != null && newUserFieldValue != null && newLibraryFieldValue != null){

logger.info(" New SQL " + newSQLFieldValue + " New User " + newUserFieldValue + " New Libraby " + newLibraryFieldValue)

if(newSQLFieldValue.equalsIgnoreCase('yes') && newUserFieldValue.equalsIgnoreCase('yes') && newLibraryFieldValue.equalsIgnoreCase('yes')){


//here if all the three field values are "Yes"/"No" then this values should be set accordingly to Custom_field 4.


}
}

Right now I'm getting the three custom field values but while checking within the condition it fails.

 

 

 

1 answer

1 accepted

1 vote
Answer accepted
Dave Bosman [Realdolmen]
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.
August 26, 2018

Hi,

 

You could use Automation for JIRA to do this instead of scripting it. 

 

Regards

Dave

Yogesh Mude
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.
August 26, 2018

@Dave Bosman [Realdolmen] thanks for your response.

we are on jira cloud, and this add-on is for Jira server.

Dave Bosman [Realdolmen]
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.
August 26, 2018

Hi @Yogesh Mude

 

Sorry, i missed that. They have a Cloud version to

 

Regards

Dave

Yogesh Mude
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.
August 26, 2018

@Dave Bosman [Realdolmen] i do not see any post function using which i can set another custom field value based on the condition.

post_function.png

Could you please let me know which post function I need to use?

Dave Bosman [Realdolmen]
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.
August 26, 2018

You don't have to use post functions, in the project administration you have a new menu item called "Automation"

Create a new rule and let it trigger on an event. use the event that is triggered by your workflow. (you can use a custom event for this) 

Then you can perform the action that you need. 

You can find all the information how the plugin works on this site

Dave Bosman [Realdolmen]
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.
August 26, 2018

I just noticed there is a better solution. 

in the automation rule you can use "issue transitioned" as a trigger. 

Yogesh Mude
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.
August 27, 2018

HI @Dave Bosman [Realdolmen]

Actually, i am evaluating this add-on but I did not find any way to configure this for particular workflow or Issue type..because in my project the same workflow is used for three different issue types and using  this addon we can apply this rule on status wise like from open status to stat in dev but this status might be using in another workflow for another issue types then how can i configure it.

Dave Bosman [Realdolmen]
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.
August 27, 2018

After the transition trigger you can add a new condition. 

Use the JQL condition and write a JQL that selects what you need. You can make it as easy or complex as you need. 

For example to select 2 issuetypes. 

issuetype in (Bug, Epic)

 After the condition you can add the action end you use "edit issue" 

Select the field you want to update and look in the documentation link i send you to find the value that you want to add. 

Regards

Dave

Yogesh Mude
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.
August 29, 2018

@Dave Bosman [Realdolmen] thanks for your time and response. :)

Yogesh Mude
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.
February 11, 2019

HI @Dave Bosman [Realdolmen]

Using this add-on we have used to achieve the functionality but the thing here is...the Automation for Jira add-on has the restriction like 300 rule can be executed per month.

Because of this we not able to add the more rules ..is there any different add-ons is there?

@Alexey Matveev can we achieve this using power scrip add-on.

Yogesh Mude
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.
February 11, 2019

The scenario is as below..

radio button fields

Test1 - Yes

Test2 - Yes    

Test3 - Yes

If all the above fields are Yes then the ABC (radio button) field should set as Yes.

If any of the above fields are Yes then the ABC (radio button) field should set as Yes.

If all the above fields are No then the ABC (radio button) field should set as No.

Alexey Matveev
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.
February 12, 2019

I am not sure why your condition fails with the ScriptRunner add-on. It should work. 

I believe that in Power Scripts it should work too.

Yogesh Mude
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.
February 12, 2019

@Alexey Matveev

Thanks for the response.

Actually for the single functionality, we don't want to purchase the Script runner plugin.

Without the script, I mean to say using any configurations can we achieve the above use case in power script.

Suggest an answer

Log in or Sign up to answer