How to get previous value in Email Notification?

vqminh
Kilo Explorer

Hello,

I'm trying to get previous value in email notification. I can get this by using Business Rule.

For example:

current.u_previous_state_string = previous.state;

But when I try to use "previous.xx" in mail script, the code didn't work:

<mail_script>

template.print("Previous State: " + previous.state);

</mail_script>

Anyone know why and how can I use "previous.xx" in right way?

Please help, thanks.

1 ACCEPTED SOLUTION

ohhgr
Kilo Sage
Kilo Sage

Hi,



As Bhavesh said, previous is not accessible in the email notification. If your emails are triggered by an event. You could use the parm1 or parm2 to pass the previous state values.



e.g.


to pass the previous state and assignement_group you can use



gs.eventQueue("event_name", current, previous_state+"||"+previous.assignment_group.getDisplayValue(), parm2);



you could access these parameters in your email notification



<mail_script>


template.print("<br/>State : "+current.parm1.split("||")[0]);


template.print("<br/>Assignment Group : "+current.parm1.split("||")[1]);


</mail_script>




Also, just out of curiosity, if you have a field called "u_previous_state_string" on your table, why don't you directly access that field in the email notification?



Thanks,
Mandar


View solution in original post

5 REPLIES 5

Bhavesh Jain1
Giga Guru

previous attribute is available only in Business rules and no where else. In case you need this feature, you will need to create a new field on your form which will store the previous value. You can then use the below code to access the field.


<mail_script>


template.print("Previous State: " + current.u_previous_state_string);


</mail_script>




Regards,


Bhavesh


IGate-logo.png


http://www.igate.com


ohhgr
Kilo Sage
Kilo Sage

Hi,



As Bhavesh said, previous is not accessible in the email notification. If your emails are triggered by an event. You could use the parm1 or parm2 to pass the previous state values.



e.g.


to pass the previous state and assignement_group you can use



gs.eventQueue("event_name", current, previous_state+"||"+previous.assignment_group.getDisplayValue(), parm2);



you could access these parameters in your email notification



<mail_script>


template.print("<br/>State : "+current.parm1.split("||")[0]);


template.print("<br/>Assignment Group : "+current.parm1.split("||")[1]);


</mail_script>




Also, just out of curiosity, if you have a field called "u_previous_state_string" on your table, why don't you directly access that field in the email notification?



Thanks,
Mandar


Dear All,



Can some help me get previous value of any state using script include.



--


Regards,


Pooja


previous.state