Activating Trigger only on condition

Posted by mysteryminds on 19-Nov-2014 16:18

Hello RB Gurus

I would like to know is there a way to activate the trigger / Mail only when particular field values are added or modified.

I have around 70 fields in one page, so I would like to send a mail to the record owner that the values of only specific mentioned field [SAY 15 FIELDS]  changed.

It can be all the 15 fields or just 1 field of those 15.

I don't want the system to send any notification or activate trigger if  they are doing anything beyond those 15 fields.

Currently what is happening is my system sends mail  even though I open the record and save other details, so i end up getting tons of mails even though they are not valid.


All Replies

Posted by ymaisonn on 19-Nov-2014 17:56

Hi Mysteryminds

You can proceed as follows;

1- Create a "Send email" trigger

2- On the trigger properties page, set On field change to "Any update"

> Thay way the below code will evaluate for any of the fields updated on the page

2- Write the following validation code inside that trigger;

var count = 0;

if ({!field1} != {!field1#before})

count ++;

//...etc.. til field 15,

if ({!field15} != {!field15#before})

count ++;

if (count > 0){

return true;

} else {

return false;


/*** ... #before suffix retrieves the value prior to edition so the code verifies whether the current field value is different from the value prior to edition, if this is the case we increment the counter returning the total number of modified fields ***/

Posted by mysteryminds on 19-Nov-2014 18:02

Dear maison

This is what is in our Send Trigger as I'm novice to RB, I'm just trying to figure out if there is something wrong in the below code.

if("{!R52185052.lock_status#value}"=="Locked" || "{!R52185052.lock_status#value}"=="Expired"||"{!R52185052.lock_status#value}"=="Cancelled")


if(("{!ficouw}"!="{!R77816268.before_fico}" || "{!co_borrower_ficouw}"!="{!R77816268.before_co_borrower_fico}" || "{!special_program#id}"!="{!R77816268.before_special_program#value}"))


return true;


else {return false;}


Posted by ymaisonn on 19-Nov-2014 19:14

{!R52185052.lock_status#value} : do you want to retrieve the value of lock_status before the user change of after the user change?

Here you are retrieveing the before value.

Posted by mysteryminds on 19-Nov-2014 19:18

its before the user change. if you are suggesting something which can really make the code work properly I would be happy to get your suggestions.

All I wanted is the code to activate only when my values of particular fields are changed  and nothing else

Posted by ymaisonn on 19-Nov-2014 19:45

Try to run your code in the debugger printing out the evaluated values

if(("{!ficouw}"!="{!R77816268.before_fico}" || "{!co_borrower_ficouw}"!="{!R77816268.before_co_borrower_fico}" || "{!special_program#id}"!="{!R77816268.before_special_program#value}"))


rbv_api.println("ficouw: " + {!ficouw});

rbv_api.println("R77816268.before_fico: " + {!R77816268.before_fico});

rbv_api.println("coborrower_ficouw: " + {!coborrower_ficouw});

rbv_api.println("R77816268.before_co_borrower_fico: " + {!R77816268.before_co_borrower_fico});

rbv_api.println("special_program#id: " + {!special_program#id});

rbv_api.println("R77816268.before_special_program: " +!R77816268.before_special_program#value});

return true

} else { return false; }

Posted by mysteryminds on 19-Nov-2014 20:14

I suppose it parses error with the before_special_program value

Syntax Error (line #11) in formula:

var rbv_api = new, 81315135);

function wrapper() {

if(("478"!="0" || "32"!="0" || "81502150"!=""))


rbv_api.println("ficouw: " + 478);

rbv_api.println("R77816268.before_fico: " + 0);

rbv_api.println("co_borrower_ficouw: " + 32);



001 var rbv_api = new, 81315135);


003 function wrapper() {

004 if(("478"!="0" || "32"!="0" || "81502150"!=""))

005 {

006 rbv_api.println("ficouw: " + 478);

007 rbv_api.println("R77816268.before_fico: " + 0);

008 rbv_api.println("co_borrower_ficouw: " + 32);

009 rbv_api.println("R77816268.before_co_borrower_fico: " + 0);

010 rbv_api.println("special_program#id: " + 81502150);

011 rbv_api.println("R77816268.before_special_program#value : " + );


013 return true


015 } else { return false; }

016 }

017 wrapper();

Posted by ymaisonn on 20-Nov-2014 02:31

What is the cardinality of Relationship R77816268. It looks like no value is returned from the related fields.

Posted by ymaisonn on 25-Nov-2014 03:12
I haven't received any feedback since my last post. Please let me know if you require further assistance on this issue.

This thread is closed