- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2022 02:50 AM
I have a requirement to make a variable value "Number" to be added to work notes(this part is working)
Second part is whenever user clicks on "demand number" from work notes they should be redirected on the service portal where this demand task exists so that non ITIL users can view the demand task.
Attached is the screenshot of business rule script:
As shown above need to make this Demand task number a hyperlink.
Solved! Go to Solution.
- Labels:
-
Application Portfolio Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2022 11:09 AM
To create a hyperlink in the work notes, you can use the following:
gr.work_notes = '[code]<a href="' + gs.getProperty("glide.servlet.uri") + 'sp?id=ticket&table=dmn_demand&sys_id=' + current.getValue("sys_id") + '">' + current.getValue("number") + '</a> [/code]' + '\n Short Description: ' + current.getValue("short_description");
Keep in mind, also, for the above, you'd have to allow the [code] tag within your journal fields via this system property being set to: true
glide.ui.security.allow_codetag
You'd need to replace "sp" above in the code with the abbreviation for your service portal that you want to direct them to (if different).
Example of result:
and clicking link goes to:
Please mark reply as Helpful, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2022 02:59 AM
Hi Talha,
Check the below links it will help you.
https://community.servicenow.com/community?id=community_question&sys_id=2a345bc9db5e1c90190b1ea66896193d
https://community.servicenow.com/community?id=community_question&sys_id=0cad1bc31bcbf8d49a53ece7624bcb43
Please Mark the answer if correct/helpful , if it helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2022 03:08 AM
Hi Talha,
Refer to these threads :
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2022 03:45 AM
Hi
You can follow the links provided by
You can also follow Formatting Journal Field, which provides the knowledge of Tags that can be used in Journal fields.
For your requirement you need to make slight changes to your business rule:
var msg = '';
//Directly get the Parent GlideRecord Object
if(current.parent) {
var parentGr = current.parent.getRefRecord();
var htmlStart = '[code]',
htmlEnd = '[/code]',
baseUrl = '/portal_name?id=demand_page_name&sys_is=';
msg += htmlStart + '<a href=">' + baseUrl + parentGr.getValue('sys_id') + '" target="_blank">' + parentGr.getValue('number') + '\n';
msg += 'Short Description: ' + current.getValue('short_description') + '\n';
msg += 'Description: ' + current.getValue('description') + '\n';
msg += 'Created By: ' + current.getValue('sys_created_by');
//Add all the required details
msg += .
.
.
.
.
//Make sure to close the End tag
msg += htmlEnd;
}
if(msg) {
gr.work_notes = msg;
gr.update();
}
Please mark my answer as correct if this solves your issues!
If it helped you in any way then please mark helpful!
Thanks and regards,
Kartik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2022 09:34 PM
Hi
There is a miss in my code, please find the updated code below:
var msg = '';
//Directly get the Parent GlideRecord Object
if(current.parent) {
var parentGr = current.parent.getRefRecord();
var htmlStart = '[code]',
htmlEnd = '[/code]',
baseUrl = '/portal_name?id=demand_page_name&sys_is=';
//Closing Anchor tag was missed earlier
msg += htmlStart + '<a href=">' + baseUrl + parentGr.getValue('sys_id') + '" target="_blank">' + parentGr.getValue('number') + '</a>\n';
msg += 'Short Description: ' + current.getValue('short_description') + '\n';
msg += 'Description: ' + current.getValue('description') + '\n';
msg += 'Created By: ' + current.getValue('sys_created_by');
//Add all the required details
msg += .
.
.
.
.
//Make sure to close the End tag
msg += htmlEnd;
}
if(msg) {
gr.work_notes = msg;
gr.update();
}
Please try this code and it will work for you.
Please mark my answer as correct if this solves your issues!
If it helped you in any way then please mark helpful!
Thanks and regards,
Kartik