Help on a Behaviour (ScriptRunner) - Edit screen issue

support for vo January 3, 2023

Hello Atlassian Community,

First of all, best wishes for 2023 !
I'm contacting you as we are facing an issue on our Behaviours (ScriptRunner plugin), especially on Edit screen.

Here is our usecase :
We have 2 projects : Project A with Epic issuetype and Project B with Timesheet Log issuetype, with same fields on both.

For these 2 projects, 2 Behaviours created : one for Project A and one for Project B.
Depending on values chosen one some fields, other fields are displayed or not, with default value or not, mandatory or not (->a lot of IF conditions).

To avoid mistakes on Create screens some values are initialized to "None" or "null" by default on some fields.
It's OK for Create screen but not on Edit one : in this case, as we reset most of the values to "None" or "null", the Edit screen resets automatically the values, which we do not want.

So here is our question : is it possible to restrict Behaviours only to Create screen, to avoid it apply on the Edit one ?

Thank you for any help on that case :)

1 answer

1 accepted

2 votes
Answer accepted
Florian Bonniec
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 3, 2023

Hi @support for vo 

There is 2 way to do it.

You can select a Guide Workflow in the Rule Behaviour configuration then for each Fields you can add a condition to execute only when it's a certain action suche as Create.

 

You can also in you script add the following condition at the begining of your script.

 

if(getActionName() == "Create"){

<YOUR CODE HERE>

}

 

Regards

support for vo January 4, 2023

Hello @Florian Bonniec

Thanks a lot for your quick answer !
I have tested and it works well :)

Just for my information, to have it on Edit, is it ? :

if(getActionName() == "Update"){

<YOUR CODE HERE>

}

Best regards

Florian Bonniec
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 4, 2023

Hi

 

No actually it will be empty.

getActionName() refer to the workflow transition, Update is not related to the WF so it return null.

https://docs.adaptavist.com/sr4js/latest/features/behaviours/api-quick-reference

Regards

Like support for vo likes this
support for vo January 4, 2023

Thank you :)

deepali3031
Contributor
February 24, 2023

For Edit screen the behaviours should be as below

if(getActionName() == null){

<YOUR CODE HERE>

}

 

Regards,

Deepali Kohli

Like support for vo likes this
Регина Андреева November 13, 2024

I use this script for field "due date", but it doesn't work for field "original estimate"?

if (getActionName() == null) {
    getFieldById("duedate").setReadOnly(true)
}

Suggest an answer

Log in or Sign up to answer