0

I am using the below code to update the incident work notes when Problem is associated with the incident but it is not giving the deeplink/url of the Problem id to redirect to problem. It is just displaying the problem id number.

Code Snippet:

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

// Add your code here var problem = current.getDisplayValue('problem_id'); current.work_notes= "Problem " + problem + " has been associated with the Incident";

})(current, previous);

Output: Problem PRB00123 has been associated with the Incident.

Sri
  • 9
  • 2

1 Answers1

0

To get a link to the Problem form view, you should extract the sys_id and construct a URL string. I've expanded on your example below.

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

// Add your code here 
var problemSysId = current.getValue('sys_id');

var url = "https://YOURINSTANCE.service-now.com/nav_to.do?uri=%2Fproblem.do%3Fsys_id%3D" + problemSysId;

current.setValue('work_notes','Problem (' + url + ') has been associated with the Incident';

})(current, previous);

You should know that adding embedded HTML in journal fields is a security risk and not recommended by ServiceNow. However, you can enable embedded HTML in journal fields by updating the glide.ui.security.allow_codetag system property to true.

For more information on how to embed HTML links in journal field by using the code tag, see: https://docs.servicenow.com/bundle/rome-platform-administration/page/administer/field-administration/task/render-journal-field-entries-as-html.html

AirBender
  • 46
  • 3