How to create a hyper link in the text message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2023 08:15 AM
How to create a hyper link when ever user click on VRA number it should be redirect to that page. How to achieve this requirement.
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2023 10:20 AM
Hello @subbarayudu ,
Have a look this post https://www.servicenow.com/community/itsm-forum/how-to-add-hyperlink-in-additional-comments-field-in...
I just wanted to conform, How to Additional Comment added?
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2023 05:35 AM
Additional comments are coming from Business rule, When ever Vendor risk assessment state becomes to 'response received' then we are setting the automated comments in the core_company table.
The following code is using for setting automated comments
(function executeRule(current, previous /*null when async*/ ) {
var parentVendor = current.vendor;
var vdr = current.vendor.name;
var core = new GlideRecord('core_company');
core.addQuery('sys_id', parentVendor);
core.query();
if (core.next()) {
var cdate = new GlideDateTime();
var num = current.number;
var suppid = current.vendor.u_supplier_id;
var str = cdate + ' ' + vdr + ' ' + num + ' Supplier ID: ' + suppid + ' Vendor Submitted Vendor Risk Assessment';
core.u_automated_comments = str;
core.update();
}
})(current, previous);
So i want that number field as a hyperlink.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2023 11:36 AM - edited 03-23-2023 11:38 AM
You haven't shared, how your Automated Comments field is getting populated, so I am giving you a couple of samples to try (later in the post), but first I will give a general idea of how that's done.
General idea:
In a journal entry field (for example, the out of the box Work notes field in an incident record), you'd need to enter the [code][/code] tags around the code you wish to render as HTML.
Here's what I mean by that:
Work notes field image below of an incident record:
Next, in the Work notes field, if I wrote, the code:
The same code written below, as it is in the above picture:
[code]
<a href='https://www.service-now.com' target='blank'>ServiceNow</a>
[/code]
Then, after saving the record, I will get this output, see the Activities which I marked with an arrow.
If I click on that link, I will be redirected to this web page on a new tab.
So that's the general idea.
Now, as I mentioned above, I will give you you a couple of samples to try, and here they are:
Sample 1:
Here, as an example, I will use a before (update) business rule, to update the Work notes field, when the Problem field is not empty.
The Script in the above picture is written below:
(function executeRule(current, previous /*null when async*/) {
var problemSysId = current.problem_id;
var problemNumber = current.problem_id.getDisplayValue();
var message = gs.getMessage("[code] Click --> <a href='/problem.do?sys_id={0}' target='_blank'> {1}</a> to redirect to the problem record.[/code]", [problemSysId, problemNumber]);
current.work_notes = message;
})(current, previous);
On my Incident record, under the Related Records related list, I have the PRB0040001, in the Problem field.
Next, if I update the incident record, I will see the following has been updated by using the Work notes field and can be seen in the Activities.
If I click on that link, I will be redirected to the problem record on a new tab.
Sample 2:
If I'd write, in the work notes field directly, I will get the similar results, as shown in Sample 1.
[code]
Click --> <a href='/problem.do?sys_id=77861465970311107b51b4b3f153afda' target='_blank'>PRB0040001</a> to redirect to the problem record.
[/code]
So, these are samples to get a feel or idea on how to do that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2023 05:42 AM
Additional comments are coming from Business rule, When ever Vendor risk assessment state becomes to 'response received' then we are setting the automated comments in the core_company table.
The following code is using for setting automated comments
(function executeRule(current, previous /*null when async*/ ) {
var parentVendor = current.vendor;
var vdr = current.vendor.name;
var core = new GlideRecord('core_company');
core.addQuery('sys_id', parentVendor);
core.query();
if (core.next()) {
var cdate = new GlideDateTime();
var num = current.number;
var suppid = current.vendor.u_supplier_id;
var str = cdate + ' ' + vdr + ' ' + num + ' Supplier ID: ' + suppid + ' Vendor Submitted Vendor Risk Assessment';
core.u_automated_comments = str;
core.update();
}
})(current, previous);
So i want that number field as a hyperlink in the automate comments, so hoe i can write the business rule.