how to send mail based on field value changes? - Forum - Rollbase - Progress Community

how to send mail based on field value changes?

 Forum

how to send mail based on field value changes?

  • Hi all,
    As shown below image "Loan Cannot Be Sold To (Approved):" and "Loan Cannot Be Sold To (CTC):" are two Group of check boxes,if the user changes values in the above two fields,i need to send the mail as below 

    Hi client
    the list of fields changed:

    Loan Cannot Be Sold To (Approved): //we need to include this field if there is change in this field while saving record

    Loan Cannot Be Sold To (CTC)://we need to include this field  if there is change in this field while saving record

    Thanks,
    Support Team.



    if none of the field changed no need to to send mail.

    Kindly let me know how can achieve the above.

    Thanks,
    Sudhakar.

  • Hi Sudhakar,

    Please follow this steps:

    1. Create two text fields that will hold the previous value of those group check box fields.

    2. Create an after update trigger that will update the newly created fields.

    The trigger should contain a code somewhat similar to this:

    return "{!group_cb#value}" /*if the value is an array, use javascript join() method to join the arrays into a string*/

    3. Create a send email after update trigger that has a condition similar to this:

    var newVal = "{!group_cb#value}";

    newVal = newVal.join(",");

    var prevVal = "{!prev_cb#value}";

     

    var newVal2 = "{!group_cb_2#value}";

    newVal2 = newVal2.join(",");

    var prevVal2 = "{!prev_cb_2#value}";

     

    if(newVal != prevVal || newVal2 != prevVal2)

     return true;

    4. Create a formula field that will be inside the email template. This will contain the dynamic value of those check boxes that needs to be displayed. Please follow this sample code:

    var newVal = "{!group_cb#value}";

    newVal = newVal.join(",");

    var prevVal = "{!prev_cb#value}";

     

    var newVal2 = "{!group_cb_2#value}";

    newVal2 = newVal2.join(",");

    var prevVal2 = "{!prev_cb_2#value}";

     

    var outputText = '';

    if(newVal != prevVal)

     outputText += "Loan Cannot Be Sold To (Approved)";

    if(newVal2 != prevVal2)

     outputText += "Loan Cannot Be Sold To (CTC)";

    return outputText;


    5. The trigger hierarchy should be like this:

    - 1. Send Email

    - 2. Update previous field value


    Hope this helps. Let me know if you have any questions.

    Thank you,

    Gian

  • perfect,helps me a lot,thank ...

    Thanks,
    Sudhakar.