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

  • Hi Gian

    I tried the token and still there is only issue with one field which is previous value. Even though I'm referrring to it as value.

    Special Program

    Previous Value = 105671647

    Current Value = VA SL

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

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

           content += "Previous Value = "+bsp+"<br>";

           content += "Current Value = "+sp+"<br>";

    @Gian do you think there is a error in this BEFORE UPDATE TRIGGER

    update to Client2 New

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

    {

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

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

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

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

    var sp= rbv_api.getFieldValue("client6",{!id}, "special_program");

    rbv_api.setFieldValue("client_21", {!R77816268.id}, "before_special_program", sp);

    }

  • Hello,

    Can you modify the highlighted line with this? I just tested this and it returns both values rather than IDs

    var sp= rbv_api.getFieldValue("client6",{!id}, "special_program");

    var sp= rbv_api.getValueById("client6", "special_program", sp);

    rbv_api.setFieldValue("client_21", {!R77816268.id}, "before_special_program", sp);

    It should display the selected radio button value by using both #value in the field token.

    Thank you,

    Gian

    client_21
  • That worked like a charm Gian

    Thanks so much....

    I'm now left with only one thing the send mail trigger

    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;}

    }

    I think the IF condition is not working

    I would like to send mails only when the fields highlighted are changed / modified / added for first time 

    Currently whats happening is when the user is opening and file and just click on save the mail is shooting up 

  • Hello,

    I just added the #value prefix to all field tokens. I also saw that you are comparing the #id prefix with the #value. Try placing this code on your email trigger.

    if("{!R52185052.lock_status#value}"=="Locked" || "{!R52185052.lock_status#value}"=="Expired"||"{!R52185052.lock_status#value}"=="Cancelled")
    {
        if(("{!ficouw#value}"!="{!R77816268.before_fico#value}" || "{!co_borrower_ficouw#value}"!="{!R77816268.before_co_borrower_fico#value}" || "{!special_program#value}"!="{!R77816268.before_special_program#value}"))
        {
            return true;
        }
        else
        {
            return false;
        }
    }


    Thank you,

    Gian

  • Gian

    There seems to be errors shooting up with the previous update  

    "var sp= rbv_api.getFieldValue("client6",{!id}, "special_program");
    var sp= rbv_api.getValueById("client6", "special_program", sp);
    rbv_api.setFieldValue("client_21", {!R77816268.id}, "before_special_program", sp);"

    in formula:var rbv_api = new Packages.com.rb.core.services.api.ServerSideAPI(51684403, 80425403);if("Locked"=="Locked" || "Locked"=="Expired"||"Locked"=="Cancelled"){var fi= rbv_api.getFieldValue("client6",109876359, "ficouw"); rbv_api.setFieldValue("client_21", 109876536, "before_fico", fi);var cf...

  • Hello,

    What update did you do? You told me that it is working before? My last post where meant for the email trigger.

    Thank you,

    Gian

  • Hi Gian

    Remember  i've updated

    var sp= rbv_api.getFieldValue("client6",{!id}, "special_program");
    rbv_api.setFieldValue("client_21", {!R77816268.id}, "before_special_program", sp);

    WITH

    "var sp= rbv_api.getFieldValue("client6",{!id}, "special_program");
    var sp= rbv_api.getValueById("client6", "special_program", sp);
    rbv_api.setFieldValue("client_21", {!R77816268.id}, "before_special_program", sp);"

    Then i received the mails with the exact data  in the email what I was expecting

    The following fields have changed in this record:

    Special Program 
    Previous Value = 84757264
    Current Value = VA SL

    But in the front client screen people were having issues updating the fields  and not able to save. But once I've deactivated  the code the system works without issues.

    But the mails are not giving the right values.

  • Hello,

    "var sp= rbv_api.getFieldValue("client6",{!id}, "special_program");
    var sp= rbv_api.getValueById("client6", "special_program", sp);
    rbv_api.setFieldValue("client_21", {!R77816268.id}, "before_special_program", sp);"


    Please remove the quotes from the formula and please use the debug function in the trigger to check what is causing the issue. Debug it line by line.

    Thank you,

    Gian

    "var sp= rbv_api.getFieldValue("client6",{!id}, "special_program");
    var sp= rbv_api.getValueById("client6", "special_program", sp);
    rbv_api.setFieldValue("client_21", {!R77816268.id}, "before_special_program", sp);" - See more at: https://community.progress.com/community_groups/rollbase/f/25/p/14348/51819.aspx#51819
    "var sp= rbv_api.getFieldValue("client6",{!id}, "special_program");
    var sp= rbv_api.getValueById("client6", "special_program", sp);
    rbv_api.setFieldValue("client_21", {!R77816268.id}, "before_special_program", sp);" - See more at: https://community.progress.com/community_groups/rollbase/f/25/p/14348/51819.aspx#51819
  • Hi Gian

    The funniest part is that its not throwing up any error when I run the DEBUG mode all runs fantastic from trigger perspective but in front end I see the error I've Posted above

  • Hello,

    I see. You can try to add a handling in the getValueById(). It might be because of a null value in the sp variable.

    Thank you,

    Gian