Copy the work notes of child to its direct Parent

Elena Spıru
Mega Guru

Hello,

 

I have added a related list on problem table called Child problems (which shows all children the particular problem has).

Now I need to add a logic that copies the work notes from child to its direct parent and I have the following scenario:

Problem A is the parent of Problem B

Problem B is the parent of Problem C

 

scenario 1: When the user writes a comment in work notes in Problem C, I want the specific work note to be copied only to Problem B's work notes.

scenario 2: When the user writes a comment in work notes in Problem B, I want it to be copied to Problem A

 

I created a business rule that copies the work notes correctly BUT the issue is that for scenario 1, the work notes get copied to Problem's B work notes, then it gets copied to Problem A's work notes - which is not desired.

 

Is there a solution to this?

 

Thank you,

Elena

1 ACCEPTED SOLUTION

@Elena Spıru 
yeah you cannot add that in condition here but you can add it in the script in IF condition.

Sample script for your reference

var text = "ServiceNow makes work better"; //this is whole comment
var substring = "work";  //substring to check copied from 

if (text.includes(substring)) {
  console.log("Substring found!");  //dont copy the worknotes in this case
} else {
  console.log("Substring not found.");  //copy the worknotes in this loop.
}

 

Accept the solution and mark as helpful if it does, to benefit future readers.
Regards,
Sumanth

View solution in original post

18 REPLIES 18

Chaitanya ILCR
Kilo Patron

Hi @Elena Spıru ,

 

for scenario 2 

 

create a separate BR which is a After update BR with gs.isInteractive() on the condition

which make sure it won't run in a loop

 

 

if this doesn't work please share your script

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

Hello,

 

I don't get it exactly, another after update BR that has only gs.isInteractive()?

How should this look?

Hi @Elena Spıru ,

 

Please share your BR script(s) and configurations(when to run and condition screenshots)

will try to find the issue and enhance it

 

do you have separate BRs for scenario1 and scenario2 or a single BR to take care of both the scenarios?

 

please copy paste the script here so that it will be easy for me to copy it 😊

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

Of course!
This was the original BR logic:

ElenaSpru_0-1747381734820.png