Forums

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

My requirement is that I want the field(single text) should be mandatory when "CRO" is selected in t

Priyanka khare
Contributor
September 8, 2021

I have a behavior running that shows/hides a field(single text) on the basis of an option - "CRO" selected in the single select field.
My requirement is that I want the field(single text) should be mandatory when "CRO" is selected in the single select field but if anything else is selected it should be optional.

How can I do it? I used behaviours again but that did not work-

def selectCFValue = getFieldByName("Requesting Segment")
def targetField = getFieldByName("Requesting Business Unit")

if (selectCFValue.getValue() == "CRO")
targetField.setRequired(true)
else
targetField.setRequired(false)

Can anyone help?rr.JPG

2 answers

1 accepted

0 votes
Answer accepted
Dirk Ronsmans
Community Champion
September 8, 2021

Hey @Priyanka khare

Maybe I'm misunderstanding it here but from your behaviour it looks like you are trigger on on the changing of the "Requesting Business Unit" field?

If that is changed it needs to check if CRO is the value and then set the targetfield required.

  • Does your behaviour do nothing?
  • throw an error?

If it is triggering you can always check the logs.

personally I would also try and do some log.error messages just to debug (don't forget to add curly braces then in your if)

 

Priyanka khare
Contributor
September 8, 2021

hello @Dirk Ronsmans ,

 

This behaviour does nothing. I added the curly braces and still no action.

 

Regards,

Priyanka

Dirk Ronsmans
Community Champion
September 8, 2021

And the fact about the changing of the Requesting Business Unit is that correct?

I would still suggest to add something like

log.error selectCFValue.getValue() 

and check the logs to see if the If statement is even triggering. also adding some log.error "some message" on the first line would be an easy way to make sure that the behaviour is even triggering at all.

Troubleshooting these things can be annoying so also double check if there is anything in your browser developer console, that might give you some clues.

0 votes
Leo
Community Champion
September 9, 2021

Hi @Priyanka khare,

The script looks fine. but the configuration does not meet your requirement

you've added the script as "server side script" of "Requesting Business Unit" which means your script will be executed only if the target field gets changed

 

you just need to place the same script as server side script of "Requesting Segment" field to get it working 

 

BR,
Leo

Suggest an answer

Log in or Sign up to answer