Changesto() and changesfrom() not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2017 02:47 AM
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;
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2017 11:39 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2017 11:45 AM
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)