Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to use current.setValue for string field in business rule

Roshini
Giga Guru

I am using a after business rule to set one field value code is . Field type is Choice and name is u_use_method. I need to set this field to local based on few conditions. Am trying to use current.setValue('u_use_method', local), where local is the backend value of the choice field. But this is not working. Any suggestions please

1 ACCEPTED SOLUTION

Anubhav24
Mega Sage

Hi @Roshini ,

It looks like you're running this on when = after, which you can't use to set values. 

You should make the BR before and then as already suggested by other colleague run the setvalue statement.

 

Please mark helpful/correct if my response helped you.

View solution in original post

5 REPLIES 5

Harish KM
Kilo Patron
Kilo Patron

Hi @Roshini please use before update BR and the code below.

current.setValue('u_use_method', 'local'); // you missed ''(codes)

Regards
Harish

SunilKumar_P
Giga Sage

Hi @Roshini, try setting the value 'local' with quotes in the script method.

 

Regards,

Sunil

Anubhav24
Mega Sage

Hi @Roshini ,

It looks like you're running this on when = after, which you can't use to set values. 

You should make the BR before and then as already suggested by other colleague run the setvalue statement.

 

Please mark helpful/correct if my response helped you.

siva krishna M2
Tera Guru

Hello @Roshini ,

 

Please try below code

current.setValue('u_use_method', 'local');

current.setWorkflow(false)

current.update();