How to send a Mail on update particular Field - Forum - Rollbase - Progress Community

How to send a Mail on update particular Field

 Forum

How to send a Mail on update particular Field

  • Dear RB Gurus

    I have a query related to sending a mail 

    Can someone explain to me steps to do to send a mail on field update. 

    I have to create any specific field  (e.g: group of Option boxes / Text Fields / Currency Fields ) or any other fields>
    if the field is updated in a view / Page / tab 

    It has to shoot a mail to me saying XYZ field was "THIS" and it has been udpated to "THAT " now 

    The field can be updated in multiple location (e.g thru mass update / Workflow / human intervention  / mobile) but the mail has to shoot once the field has BEEN MODIFIED /UPDADTED only

  • Hello,

    Please see a similar post on how to send an email on an update of a particular field.https://community.progress.com/community_groups/rollbase/f/25/t/13395.aspx


    Thank you,
    Gian

  • i'm afraid the page link you provided seems to be down

    "Sorry, there was a problem with your last request!

    Either the site is offline or an unhandled error occurred. We apologize and have logged the error. Please try your request again or if you know who your site administrator is let them know too.'

  • Hello,

    Please try this link instead: https://community.progress.com/.../13395.aspx

    Thank you,

    Gian

  • Hi Gian

    Thanks for the info... But that seems to be confusing me, as I'm novice to RB and really don't have that expertise knowhow like yours, but my mind works very logically.

    Give me a single field update option, the way its published there seems to be very confusing to me.

    Whats needs to be done first

    Whats needs to be done Second

    What needs to be done third

    What needs to be done Fourth and if its final

    So that I can create my own document and keep it.

    I don't  mind shortcuts but it has to be sequential so that I don't bother everyone in the community time and again please

    I guess I'm not being too demanding..... Just trying to learn the right way

  • Hello,

    I'll explain it clearly here:

    1. First, create a duplicate of the field you need to compare with. If it is a text field, create a new text field. This will hold the previous value of the original text field. (text field 1 is the original field and text field 2 is the cloned field)

    2. Create an "After Update" trigger that sets the value on the cloned text field.

    3. Create a "Send Email" trigger that will send the email conditionally. This checks if the field value is changed.

    4.  The trigger hierarchy should be like this:

    - 1. Send Email

    - 2. Update Previous Value

    5. For the email template, create a formula field that will hold the dynamic value to be displayed in the email. Add the formula field token in the email template afterwards.

    Hope this is clear enough. Let me know if you have any more questions.

    Thank you,

    Gian

    return "{!text_field_1#value}";

  • Hello,

    I'll explain it clearly here:

    1. First, create a duplicate of the field you need to compare with. If it is a text field, create a new text field. This will hold the previous value of the original text field. (text field 1 is the original field and text field 2 is the cloned field)



    2. Create an "After Update" trigger that sets the value on the cloned text field.



    3. Create a "Send Email" after update trigger that will send the email conditionally. This checks if the field value is changed.



    4.  The trigger hierarchy should be like this:

    - 1. Send Email

    - 2. Update Previous Value

    5. For the email template, create a formula field that will hold the dynamic value to be displayed in the email. Add the formula field token in the email template afterwards.



    Hope this is clear enough. Let me know if you have any more questions.

    Thank you,

    Gian

  • I wasn't able to create different fields in my system due to the fact we crossed list of fields available in the object.

    So this is the way I'm trying to do things and make it work... But unfortunately its not anywhere close to what I'm thinking it is....

    Let me explain to you what I've been doing so far

    MAIL CONTENT  field value

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

    {

    var content = "";

    var fi="{!abc}";

    var bfi="{!R77816268.before_abc}";

    if(fi != bfi){

    content += "abc  <br></br>";}

    var cfi="{!aaa}";

    var bcfi="{!R77816268.before_aaa}";

    if(cfi != bcfi){

    content += "aaa  <br></br>";}

    var sp="{!bbb#id}";

    var bsp="{!R77816268.before_bbb#value}";

    if(sp != bsp ){

    content += "bbb  <br></br>";}

    return content;

    }

    -------------------------------------

    TRIGGER  - Lock Desk Changes SP

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

    {

    if ("{!abc}" != "{!R77816268.before_abc}" ||"{!co_borrower_aaa}" != "{!R77816268.before_co_borrower_aaa}")

    {

    return true;

    }

    else {return false;}

    }

    ----------------------------------

    Trigger Name - update to Client2 New

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

    {

    var fi= rbv_api.getFieldValue("client6",{!id}, "abc");

    rbv_api.setFieldValue("client_21", {!R77816268.id}, "before_abc", fi);

    var cfi= rbv_api.getFieldValue("client6",{!id}, "co_borrower_aaa");

    rbv_api.setFieldValue("client_21", {!R77816268.id}, "before_co_borrower_aaa", cfi);

    }

    -----------------------------------------------

    ----------------------------------

    EMAIL TEMPLATE - Lock Desk Changes SP

    Attention Lock Desk,

    Client : {!name#text}

    info # : {!lnumber#value}

    The following fields have changed in this record:

    {!mail_content_new#value}

    After all this doing... When I change a field in the system I still do not see which field has been changed or modified.

    Where am I going wrong

  • Hello,

    I've cleaned some of the code since you are comparing the ID with the #value which will not work. Can you check if the records being tested have a related record and also please use the debug mode in triggers to check if it is entering the conditions you specified and if there are no errors on the triggers.

    -------------------------------------

    formula field to be displayed in the email

    if("{!R52185052.xyz#value}"=="Locked" || "{!R52185052.xyz#value}"=="Expired" || "{!R52185052.xyz#value}"=="Cancelled")
    {
        var content = "";
        var fi="{!abc#value}";
        var bfi="{!R77816268.before_abc#value}";

        if(fi != bfi){
            content += "abc<br></br>";
        }
            
        var cfi="{!aaa#value}";
        var bcfi="{!R77816268.before_aaa#value}";
            
        if(cfi != bcfi){
            content += "aaa<br></br>";
        }
                
        var sp="{!bbb#value}";
        var bsp="{!R77816268.before_bbb#value}";

        if(sp != bsp ){
            content += "bbb<br></br>";
        }

        return content;
    }

    -------------------------------------

    TRIGGER  - Lock Desk Changes SP

    if("{!R52185052.xyz#value}"=="Locked" ||"{!R52185052.xyz#value}"=="Expired" ||"{!R52185052.xyz#value}"=="Cancelled")
    {
        if ("{!abc#value}" != "{!R77816268.before_abc#value}" || "{!co_borrower_aaa#value}" != "{!R77816268.before_co_borrower_aaa#value}")
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    -------------------------------------

    Trigger Name - update to Client2 New

    if("{!R52185052.xyz#value}"=="Locked" ||"{!R52185052.xyz#value}"=="Expired" ||"{!R52185052.xyz#value}"=="Cancelled")
    {
        var fi= "{!abc#value}";
        rbv_api.setFieldValue("client_21", {!R77816268.id}, "before_abc", fi);

        var cfi= "{!co_borrower_aaa#value}";
        rbv_api.setFieldValue("client_21", {!R77816268.id}, "before_co_borrower_aaa", cfi);
    }

    TRIGGER HIERARCHY
    1. Lock Desk Changes SP | after update trigger
    2. update to Client2 New | after update trigger

    Hope this helps.

    Thank you,

    Gian

  • Hello Gian

    I'm not able to send the values by mail  

    which means "I'm not getting values of my PREVIOUS VALUE and CHANGED TO VALUE"

    my mailcontent formula field has this

    Field Type : FORMULA (string)

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

    {

    var sp="{!special_program#value}";

    var bsp="{!R77816268.before_special_program#value}";

    if(sp != bsp ){

    content += "Special Program values changed from " +sp+ to +bsp;}

    return content;

    }

  • Hello,

    Can you use the debug feature in trigger #2 just to see if it is updating the previous field value properly? Make sure you are using the correct relationship name.

    -------------------------------------

    Trigger Name - update to Client2 New

    if("{!R52185052.xyz#value}"=="Locked" ||"{!R52185052.xyz#value}"=="Expired" ||"{!R52185052.xyz#value}"=="Cancelled")
    {
        var fi= "{!abc#value}";
        rbv_api.setFieldValue("client_21", {!R77816268.id}, "before_abc", fi);

        var cfi= "{!co_borrower_aaa#value}";
        rbv_api.setFieldValue("client_21", {!R77816268.id}, "before_co_borrower_aaa", cfi);
    }


    Thank you,

    Gian

  • Gian

    My main issue in here is that its not picking the values as it shows while I debug.

    I'm just presuming that the way I'm writing the code is wrong

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

    {

    var content = "";

    var fi="{!ficouw}";

    var bfi="{!R77816268.before_abc}";

    if(fi != bfi){

    content += "aaabbbbbccccc  <br></br>";}

    var cfi="{!co_borrower_ficouw}";

    var bcfi="{!R77816268.before_co_borrower_aaa}";

    if(cfi != bcfi){

    content += "aaaaaaaaaaaaaaaaaa <br></br>";}

    var sp="{!special_program#id}";

    var bsp="{!R77816268.before_special_program#value}";

    if(sp != bsp ){

    content += "Special Program <br><br>";}

    return content;

    }

    OUTPUT by MAIL i get

    Attention <bla bla bla>,

    Client : clientname

    LOAN # : 1411120000

    The following fields have changed in this record:

    Special Program

    Thank you,

    company

    but I would expect is to have

    SPECIAL PROGRAM  value has changed

    Previous Value =  ONE

    Current Value = TWO

    so I need to show the values "SP" and "BSP"

    I suppose this is clear...

  • Hello,

    Is the formula field the only problem that you are encountering? If so, I edited the script and added the tokens to be displayed in the formula field:

    if("{!R52185052.lock_status#value}"=="Locked" ||"{!R52185052.lock_status#value}"=="Expired" ||"{!R52185052.lock_status#value}"=="Cancelled")
    {
        var content = "";
        var fi="{!ficouw}";
        var bfi="{!R77816268.before_abc}";

        if(fi != bfi){
            content += "aaabbbbbccccc  <br></br>";
        }


        var cfi="{!co_borrower_ficouw}";
        var bcfi="{!R77816268.before_co_borrower_aaa}";

        if(cfi != bcfi){
            content += "aaaaaaaaaaaaaaaaaa <br></br>";
        }

        var sp="{!special_program#id}";
        var bsp="{!R77816268.before_special_program#value}";

        if(sp != bsp ){
            content += "Special Program <br><br>";
            content += "Previous Value = "+bsp+"<br>";
            content += "Current Value = "+sp+"<br>";
        }

        return content;
    }

  • Thanks Gian

    Now I see some things happening and receiving some data which might be helpful.

    The current challenge is that I'm not getting the Values of the Variables 

    E.g special program  field :  which is a group check box 

    for now special program has around 20 group radio boxes so if i select one radio box 
    e.g : special program : HOUSE  
    in th email it must display special program : current Value : house 

    But right now its showing something like : ID values in numeric


    Client : tester,test
    The following fields have changed in this record:

    FICO (UW INPUT) 
    Co-Borrower FICO(UW INPUT) 
    Special Program 

    Previous Value = 98558090 [ in place of this I would like to see it as  BUNGALOW]
    Current Value = 62382552 [HOUSE]

    also I'm facing some small challenge which is  "receiving mails even though above 3 mentioned fields are not changed " the trigger is invoking mails 
    Is there a way to tell the system to send the mail unless and untill only these 3 fields are changed or amended.....

  • Hello,

    If both fields are group of radio button, just use the #value instead. Please refer to the Rollbase User Guide, Chapter 5: Adding Business Logic for more information on how to use each token types.

    var sp="{!special_program#value}";
    var bsp="{!R77816268.before_special_program#value}";

    You need to check the token types if they are correct so that the email trigger will fire properly. Please use the debug function to check the conditions if correct.

    Hope this helps,

    Gian


        var sp="{!special_program#id}";
        var bsp="{!R77816268.before_special_program#value}"; - See more at: https://community.progress.com/community_groups/rollbase/f/25/p/14348/51714.aspx#51714