Changesto() and changesfrom() not working

shikhakamboj
Kilo Expert

I want to apply a condition on one field called "u_first_time_right" , it should be false only if the "state" is closed and else it should be "true".

i wrote this "before insert" business rule name "first_time_right_true_false" :

update();

function update()

{

current.u_first_time_right = true;

gs.addInfoMessage('inside fun');

if(current.state.changesFrom(1) && !current.state.changesTo(3))         //1 is new and 3 is closed state

{

gs.addInfoMessage('inside if');

current.u_first_time_right = false;

}

}

2 REPLIES 2

SanjivMeher
Kilo Patron
Kilo Patron

Can you try this?



update();



function update()


{


current.u_first_time_right = true;


gs.addInfoMessage('inside fun');


if(previous.state == 1 && current.state!=3)         //1 is new and 3 is closed state


{


gs.addInfoMessage('inside if');


current.u_first_time_right = false;



}


}



Please mark this response as correct or helpful if it assisted you with your question.

Nate23
Mega Guru

if it is on insert i'm not sure you need the changesFrom condition. also you state "it should be false only if the "state" is closed" but in your if !current.state.changesTo(3) is saying "if state is not Closed then it is false" try changing it to current.state.changesTo(3)