Workflow Condition Script Runner - how to set error message to single line text field

Nannette Mori March 24, 2023

If the condition is false I need to set a message into a customfield that is fieldtype single line text field.

below is the code I have for the customfield

def cf2 = ComponentAccessor.getCustomFieldManager().getCustomFieldObjects ByName('Transition Blocker')

In the condition it does not allow me to

get the custom field value and then getFieldByID and set the FormValue or per documentation do

cf2.setError ("this is it)

else 

cf2.clearError()

Using script runner version 7.8.0

 

1 answer

0 votes
Fabio Racobaldo _Herzum_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 24, 2023

Hi @Nannette Mori ,

first of all workflow condition defines if a transition button should appear or not. Based on that there's no way to set an error. If you need that, my suggestion is to use a workflow validator instead.

Hope this helps,

Fabio

Nannette Mori March 24, 2023

I just realized those conditions are in behaviours

Nannette Mori March 24, 2023

We don't want the transition button to display but we also want the users to know why

Nannette Mori March 24, 2023

How do you check on the condition that was  created in the workflow in the validator?

Fabio Racobaldo _Herzum_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 25, 2023

@Nannette Mori , if you use behaviour you can just put the error on your field using the following code :

def cf2 = getFieldByName("Transition Blocker")
cf2.setError ("this is it)

This should fix your issue. You don't need to take cf through CustomFieldManager.

 Fabio

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
9.4.3
TAGS
AUG Leaders

Atlassian Community Events