Business Rule to change a State field

122932
Tera Expert

Hi


I need to create a Business Rule where the State field is equal to "10", the same State field will change to "Open"

my Script:

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

// Add your code here

if(current.state == '10'){

current.setValue('state', Open); // use valid choice value

}

if(current.state == '9'){

current.setValue('state', Close); // use valid choice value

}

})(current, previous);

 

Tks!

1 ACCEPTED SOLUTION

Hi Julio, Is this issue fixed or your looking help How these are calling by label or value ?? Thanks Chandu Telu

View solution in original post

6 REPLIES 6

Mark Endsley
Tera Guru

do it this way instead.

 

current.state = 3

 

replacing three with the number corresponding to the closed state (which could actually be 3)

 

Hello how are you?
I did like this:

(X)Before
(X)Update

if(current.state == '9'){ //<---- The feild State is a Table task

current.state = 'Encerrado';
}

if(current.state == '111'){

current.state = 'Reaberto';
}

})(current, previous);

It didn't work, can you help me?

It looks to me like you are trying to set the State to the Label of the choice instead of the Value.

 

find_real_file.png

 

right click on the State field and push configure dictionary. From there click the Choices tab at the bottom. 

 

There you can see the mappings between the choices and the values associated with them. You need to be testing and assigning current.state based on the values, not the labels.

Hello, how are you?
I have these fields defined, but for some failure, sometimes the ones called instead of coming with the name bring the number 9 or 111, as an outline I need to change to another value. Remembering that 9 and 111 are already defined.

Thank you for your help