Replace "hr_ServicesUtil" script include code in Record Producer Script

Sivakrishna
Kilo Sage

Hi,

         In my organization, having a Record producer called "HR Leave of Absence form", When user submits a record producer in portal, HR case will be created. In the HR Case, the description field (rich_description) field filled with        "<br>" HTML tag instead of "\n" due to below line of code in "hr_CaseUtils" OOTB Script include:

this._case.rich_description = description.replace(/\n/g,"<br>");

 

We have raised a HI case for this issue.

Servicenow recommended, to update the "Sync description with rich_description" business rule with the following code given in HI case reply.
(function executeRule(current, previous /*null when async*/) { 
if(current.operation() == 'insert' && !gs.nil(current.getValue('description'))) 
return; 
current.description = current.rich_description; 
})(current, previous); 
 
After updating the above business rule, I have generated few HR cases of Record Producers using "hr_ServicesUtil" OOTB script include. The HR case description of other Record Producers are also affected due to Updation of OOTB Business Rule.
 
I want to remove "<br>" HTML tags in description field of HR Case when user submitted the "HR Leave of Absence form" Record Producer.
 
Please help me.....
 
With Regards
 
P. Sivakrishna
2 ACCEPTED SOLUTIONS

Anil Lande
Kilo Patron

Hi,

You can update the when to run condition in your business rule. Keep original script as it is and update when to run condition like HR Service IS NOT 'Leave of Absence'.

Create another business rule with the script part as suggested by ServiceNow Hi team, for this Busieness rule you need to add when to run condition so that it will only run for your HR Service "Leave of Absence".

When to run condition would be:

Existing condition 

AND

HR Service IS "Leaveof Absence"

 

Changing script include is not best practice, instead you can achieve this by updating existing BR condition and creating new for BR for your HR Service.

 

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

View solution in original post

Hi @Anil Lande ,

Thank you for your response. Finally I have fulfilled my requirement with your code.

 

With Regards

 

P. Sivakrishna

View solution in original post

2 REPLIES 2

Anil Lande
Kilo Patron

Hi,

You can update the when to run condition in your business rule. Keep original script as it is and update when to run condition like HR Service IS NOT 'Leave of Absence'.

Create another business rule with the script part as suggested by ServiceNow Hi team, for this Busieness rule you need to add when to run condition so that it will only run for your HR Service "Leave of Absence".

When to run condition would be:

Existing condition 

AND

HR Service IS "Leaveof Absence"

 

Changing script include is not best practice, instead you can achieve this by updating existing BR condition and creating new for BR for your HR Service.

 

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Hi @Anil Lande ,

Thank you for your response. Finally I have fulfilled my requirement with your code.

 

With Regards

 

P. Sivakrishna