How can we send mails to the respective mailing list in batch class - Forum - Rollbase - Progress Community

How can we send mails to the respective mailing list in batch class


How can we send mails to the respective mailing list in batch class

  • Hi all,

    how can we send mails daily by 8 PM to their respective mailing list.

    i have created trigger with type send mail (if city equals "hyd" trigger will fire )to send mails to the respective mail and Lo mail.

    Now my requirement is how can i send mails daily 8 pm to their respective mailing list(email,LO mail).

    If i mention the email,LO mail email address in the Batch class notify address then it will send to the them,But we do not want send mails of  2nd record(sudhakar) info to the 1st mailing list(,

    Kindly let me know how can we achieve the above. 


  • Hi Sudhakar,

    You can use a 'Data Maintenance' batch job to send emails daily every 8PM. Since this type of batch job is like an object script, you can use rbv_api.runTrigger API to run the 'Send Email' trigger programmatically.

    Batch jobs will execute to all records from your selected object but you may use JavaScript to run it on selected records only. Please see sample code below:

    if ("{!email}" == "") rbv_api.runTrigger("customer", {!id}, "sendNotification", true);

  • i am using the same ,i will give my live scenario, i think u can get better understand what im looking.

    1.We have nearly 80 records which satisfy the workflow status Active.  

    2.Each records needs to send  minimum 4 mails.

    if i use the following condition



    rbv_api.runTrigger("customer", {!id}, "sendNotification", true);


    then the batch job  will work for 80 records i know that,my requirement is regarding mailing list,how can i send mails to the respective ppl with respective info,

    For Ex:: record 1 needs to send mails to the  a,b,c,d

                  record 2 needs to send mails to the a,b,x,y

    after completing the Batch job the following should happen::

    person "a" needs to get 2 mails (1 mail regarding record Record 1 info,another one regarding Record 2 Info)

    person "b" needs to get 2 mails (1 mail regarding record Record 1 info,another one regarding Record 2 Info)

    person "c" needs to get 1 mails (1 mail regarding record Record 1 info)  etc....

    I hope now you got clear picture of what im looking for.


  • I think I understand your point much clearer now. I will use your examples to present my ideas.

    1. If you want to send multiple emails per parent per child(1 recipient per email):

    You will need to create a middle object to store all unique combination of parent and child. To automate this, you will need to create a trigger(Timing: After Create) from the child object to create a middle object record.

    With your examples, the trigger should automatically create 8 records:

    1  |record 1  |a

    2  |record 1  |b

    3  |record 1  |c

    4  |record 1  |d

    5  |record 2  |a

    6  |record 2  |b

    7  |record 2  |x

    8  |record 2  |y

    Then, you will create a 'Send Email' trigger in your middle object which will be used in your batch job.

    With your example, Rollbase will send a total of 8 emails.

    2. Else, if you want to send a single email per parent record (1 email with multiple recipients):

    You should transfer the email template from your child object to the parent object. Then, create a 'Send Email' trigger in your parent object. You should use the related children's email addresses (e.g. Children: Email Address, Recipients: Email Adress) on the trigger's TO field. Then, update your batch job to run the newly created trigger on your parent object.

    With your examples, Rollbase will send a total of 2 emails.



  • we both are in different tracks,let me explain what we are doing currently 

    To send info regarding employee to the respective mails(email,LO mail) whose city is hyd ,we are using group action.
    After completing the group action it send mails as follows and infolo@gmail will receive mails (Details about only "All" (sn_emp name) ) and will receive mails.(Details About only siva(sn_emp name)) and prasedlo@gmail will receive mails.(Details About only prasd(sn_emp name) ).

    we want to happen same thing what is happening in the above daily 8 PM in Asynchronous(back ground ) mode.i.e with out user interaction. 
    So how can we do in the above in BatchJob.


  • Hi Sudhakar,

    The solution for this is almost the same with my first answer. I assume you already have a trigger and email template in sn_emp object, and the recipients of the email is configured to be sent to both 'email' and 'LO Mail'. Am I correct?

    Then, create a batch job that will run this trigger every 8PM. In your case, I would use the code below:

    if ("{!city}"  == "hyd")  rbv_api.runTrigger("sn_emp", {!id}, "sendNotification", true);

    **Replace the highlighted text with the integration name of your 'Send Email' trigger. 

    Since the batch job runs on all records, it will send an email to 'Email' and 'LO Mail' if the the value of the sn_emp's city is equal to 'hyd'.

    Below are the screenshots of my trigger and batch job.



  • from the next answer i will get from you will explain the problem what i am talking.

    And my question is How many mails did received after the batch job completed .


  • I ran my batch job just now and received a total of 6 email messages(2 per email address). Please refer to the screenshot of my data below:

    Here's a summary of the email per email address:

    1. got emails referring to All and Prasd.
    2. got emails referring to All and Siva.
    3. got emails referring to Prasd and Siva.

    Did I get the results right? I can send you an XML copy of my application for your reference.



  • as per SS needs to get total of 5 mail . correct me if im wrong.

    1st mail info about All

    2nd mail info about prasd

    reaming 3 you will receive why because you have mentioned  in notify address of batch class.

    in live we have nearly 80 records which satisfy the condition ,so if i mention then you will receive more than 80 mails(80 for notify address,few more mails why because your in the mailing of few records).

    In order to solve the above i have tried below

    i have mention (it is not existed )in  notify address of batch job,

    if i run the batch now then i will receive mails for which records i am in the records mailing extra mail.

    i hope that will works fine,kindly let me know if it does not work,


  • Hi Sudhakar,

    I think you got confused with the 'notify address'.

    I did not receive the 3 email notifications because the 'notify address' in the batch job was only intended to alert users if there are errors in running the batch job. Also, it will only send 1 email describing what went wrong to the batch job.

    A batch job will stop running when an error occurs. Meaning, if your batch job gets an error today, then it will not run on the succeeding days until you update and fix the batch job. Hence, I recommend you to enter your active email address so you will be notified as soon as possible.

    In your live example, I will not get 80 notifications but I will get 1 error notification if an error occurs.



  • thanks for your helps me.