I want to add the clickable record link in the worknote

Sudhir10
Tera Contributor

Hello

 

I want to add the clickable link of the newly created record through an UI Action in the worknote. How we can write a code for this?

 

Thanks.

2 ACCEPTED SOLUTIONS

Prathamesh G
Kilo Sage
Kilo Sage

Hello @Sudhir10,

 

I have implemented the same functionality in my previous use cases. Below I am sharing the code for that. 

 

//Create a Request from HR Case
var grRequest = new GlideRecord('sc_request');
grRequest.initialize();
grRequest.opened_by = gs.getUserID(); //set Opened by field on Request to the current user
grRequest.requested_for = grCase.opened_for; // set Requested by field on Request
grRequest.insert();

//create RITM from Request
var grRITM = new GlideRecord("sc_req_item");
grRITM.initialize();
grRITM.request.requested_for = grCase.opened_for; //set Requested for field on RITM
grRITM.cat_item.setDisplayValue(grCase.hr_service.getDisplayValue()); //set Item field on RITM
grRITM.assignment_group.setDisplayValue(grCase.assignment_group.getDisplayValue()); //set Assignment Group field on RITM
grRITM.assigned_to.setDisplayValue(grCase.assigned_to.getDisplayValue()); //set Assigned to field on RITM
grRITM.parent.setDisplayValue(grCase.number.getDisplayValue()); //set Parent field on RITM
grRITM.request.setDisplayValue(grRequest.number.getDisplayValue()); //set Request field on RITM
grRITM.state = '9'; //set State to New
grRITM.approval = 'approved'; //set Approval Status field on RITM
grRITM.stage = 'Approved';
grRITM.priority = grCase.priority; //set Priority field on RITM
grRITM.description = description; //set Description field on RITM

var hrLink = '<a href="/' + task_table_name + ".do?sys_id=" + task_sys_id + '">' + grCase.number + '</a>'; //Link for the HR case with number
grRITM.work_notes = "[code]Record created from HR Case " + hrLink + '[/code]'; //Add worknote to the RITM ticket with the HR case number attached with link
var ritmID = grRITM.insert();
var link = '<a href="/sc_req_item.do?sys_id=' + ritmID + '">' + grRITM.number + '</a>'; //Link for the RITM ticket
grCase.work_notes = "[code]Requested item " + link + " has been created[/code]"; //Add worknote to the HR case ticket with the RITM number attached with link

 

Please use this logic for your requirement. You can modify it as per your requirement. 

 

If the above solution resolve your issue, Please mark the solution as 'Accepted Solution' and also mark it as 'Helpful'.

 

Thank You.

View solution in original post

Hi @Sudhir10 

okay, I got your point.

Please refer to the following video to understand how clickable links can be added to the work notes: https://www.youtube.com/watch?v=bB76PWXWBXI 

Thanks
Maik

View solution in original post

7 REPLIES 7

Prathamesh G
Kilo Sage
Kilo Sage

Hello @Sudhir10,

 

I have implemented the same functionality in my previous use cases. Below I am sharing the code for that. 

 

//Create a Request from HR Case
var grRequest = new GlideRecord('sc_request');
grRequest.initialize();
grRequest.opened_by = gs.getUserID(); //set Opened by field on Request to the current user
grRequest.requested_for = grCase.opened_for; // set Requested by field on Request
grRequest.insert();

//create RITM from Request
var grRITM = new GlideRecord("sc_req_item");
grRITM.initialize();
grRITM.request.requested_for = grCase.opened_for; //set Requested for field on RITM
grRITM.cat_item.setDisplayValue(grCase.hr_service.getDisplayValue()); //set Item field on RITM
grRITM.assignment_group.setDisplayValue(grCase.assignment_group.getDisplayValue()); //set Assignment Group field on RITM
grRITM.assigned_to.setDisplayValue(grCase.assigned_to.getDisplayValue()); //set Assigned to field on RITM
grRITM.parent.setDisplayValue(grCase.number.getDisplayValue()); //set Parent field on RITM
grRITM.request.setDisplayValue(grRequest.number.getDisplayValue()); //set Request field on RITM
grRITM.state = '9'; //set State to New
grRITM.approval = 'approved'; //set Approval Status field on RITM
grRITM.stage = 'Approved';
grRITM.priority = grCase.priority; //set Priority field on RITM
grRITM.description = description; //set Description field on RITM

var hrLink = '<a href="/' + task_table_name + ".do?sys_id=" + task_sys_id + '">' + grCase.number + '</a>'; //Link for the HR case with number
grRITM.work_notes = "[code]Record created from HR Case " + hrLink + '[/code]'; //Add worknote to the RITM ticket with the HR case number attached with link
var ritmID = grRITM.insert();
var link = '<a href="/sc_req_item.do?sys_id=' + ritmID + '">' + grRITM.number + '</a>'; //Link for the RITM ticket
grCase.work_notes = "[code]Requested item " + link + " has been created[/code]"; //Add worknote to the HR case ticket with the RITM number attached with link

 

Please use this logic for your requirement. You can modify it as per your requirement. 

 

If the above solution resolve your issue, Please mark the solution as 'Accepted Solution' and also mark it as 'Helpful'.

 

Thank You.

Hello @Prathamesh G ,

 

I have copied the selected line of code from your code which is responsible for adding the worknote with clickable link and pasted it in my code. And it work perfectly. I give me the clickable link in the worknote.

 

Thank you so much for sharing it with me.

Prathamesh G
Kilo Sage
Kilo Sage

Hello @Sudhir10,

 

Continued from my previous response, Below is output of the code after creating the new record using the UI action. 

 

Worknote.png

 

If the above solution resolve your issue, Please mark the solution as 'Accepted Solution' and also mark it as 'Helpful'.

 

Thank You.