How to set Display value in business rule for state(choices)?

Debarpita Basak
Giga Contributor

Hi All,

Kindly help me . I got one requirement if the current choices start with pending then it changes to another state Work in progress

the script:

(function executeRule(current, previous /*null when async*/) {

var state = current.state.getDisplayValue();
gs.log("track4" + state);
//var a=current.u_email_update.getDisplayValue();

if((state == "Pending-Client") || (state== "Pending-Vendor") || (state == "Pending-Internal")){

//current.state = "Work in progress";
// current.state = 2;
current.state.setDisplayValue('Work in progress');
//current.stage == "closed_skipped";
//current.state = 3;
current.update();
}
})(current, previous);

 

my query how to set the current state setDisplayValue to Work in progress (I have used------ current.state.setDisplayValue('Work in progress')----these line-) but working not for state choice field kindly suggest . I have to set display WIP or not WIP's value(2).

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Debarpita Basak 

Ideal way to set the choice field is using the choice value;

The display value i.e. choice label may change as per business requirement so I would suggest using choice value

If this is before update then remove current.update() as it is not best practice

current.state = 2;

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

12 REPLIES 12

Chander Bhusha1
Tera Guru

Hi debarpita,

Since its business rule even if you set the backend value(2) then also the state of task will set to work in progress.

but for setting the display value you can use this:

Try this out:

current.setDisplayValue('state','Work in Progress');

 

Thanks,

CB

Thanks for the help . it is not working , giving a blank value. Kindly suggest another

hi cb,

It is not working kindly suggest

Hi cb,

Thanks . it is not working . i have to set display 'work inprogress', not the value .

 


var currentstate = current.state.getDisplayValue();
if((current.u_email_update == true))
{
if((currentstate== "Pending-Client") || (currentstate== "Pending-Vendor") || (currentstate == "Pending-Internal"))
{
current.state = 2;
// current.state.setDisplayValue("Work in progress");
//current.setDisplayValue('state','Work in Progress');

}
}