Automatic Update Integer Field when send a Email

luizmarcond
Tera Contributor
Hey guys!

Basically I need there to be a Business Rule so that when I send an email from a certain table, the increment field in that table counts +1, thus updating the subject of the email.

I already have the increment fields etc, I'm having difficulty writing the code. 

How could I write this code, can anyone help me?
5 REPLIES 5

priyatam_pvp
Tera Guru

Can you elaborate more, like when you want to increase the record count whenever an email is sent on the record?

Please mark it helpful
Regrads
Priyatam

Sorry, I think I wasn't very clear in my questioning.

 

I need that, every time I send an email related to a certain table (most likely we would have to reference some field from sys_email, such as 'target table'), the increment field of that table is incremented, so I can update the subject of the email as I send the emails, for example, Subject: Update 1, Update 2, etc.

 

Currently I have an email template and the increment field in the desired table, I'm just having difficulty writing this in a BR.

 

jaswalvishal106
Tera Expert

Hello @luizmarcond Maybe I haven't understood the question completely however as per my understanding, here is what I have done:

Created a dummy table 

jaswalvishal106_0-1740681024186.png


Created a Before Business Rule

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
current.u_increment = current.u_increment + 1;

})(current, previous);



jaswalvishal106_1-1740681055783.png



jaswalvishal106_2-1740681062788.png
Created a dummy e-mail notification

jaswalvishal106_3-1740681225491.png

 

jaswalvishal106_7-1740681466538.png

 


So, whenever a new record is created in the dummy table form as shown below, the increment field's value increments to + 1

Before record creation:

jaswalvishal106_8-1740681494720.png

 


After Record Submission/creation:

jaswalvishal106_9-1740681516069.png


E-mail sent:

jaswalvishal106_10-1740681540154.png

 





 

 

 

Thanks for trying helping me!

 

Sorry, I think I wasn't very clear in my questioning.

 

I need that, every time I send an email related to a certain table (most likely we would have to reference some field from sys_email, such as 'target table'), the increment field of that table is incremented, so I can update the subject of the email as I send the emails, for example, Subject: Update 1, Update 2, etc.

 

Currently I have an email template and the increment field in the desired table, I'm just having difficulty writing this in a BR.