- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2023 12:27 AM
Hello Folks,
I have a string field where count needs to be increased by 1 whenever caller updates the comments. This is needed for reporting to capture communication count from caller.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2023 12:45 AM
Hi,
I would suggest you write an onBefore Business rule to handle this.
Business rule should run only on update.
Conditions would be:
additional comment changes
AND
updated by is same as caller.user ID
Script something like below:
(function executeRule(current, previous /*null when async*/) {
var counter = current.getValue('u_your_custom_field_name');
if (!counter){
current.setValue('u_your_custom_field_name', '1');
}
else{
counter = parseInt(counter, 10);
counter++;
current.setValue('u_your_custom_field_name', counter);
}
})(current, previous);
Try it, and see if it works.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2023 01:36 AM
Oh, sorry about that, change the last line like the following:
current.setValue('u_your_custom_field_name', counter.toString());

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2023 12:45 AM
Hi,
I would suggest you write an onBefore Business rule to handle this.
Business rule should run only on update.
Conditions would be:
additional comment changes
AND
updated by is same as caller.user ID
Script something like below:
(function executeRule(current, previous /*null when async*/) {
var counter = current.getValue('u_your_custom_field_name');
if (!counter){
current.setValue('u_your_custom_field_name', '1');
}
else{
counter = parseInt(counter, 10);
counter++;
current.setValue('u_your_custom_field_name', counter);
}
})(current, previous);
Try it, and see if it works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2023 01:14 AM
I am getting results as 1.0, 2.0, 3.0 but i need like 1 for first comment , 2 for second comment.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2023 01:36 AM
Oh, sorry about that, change the last line like the following:
current.setValue('u_your_custom_field_name', counter.toString());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2023 02:36 AM
Thanks Olan, have a great day.