Issue while inserting hyper link in worknotes

charanpatnala
Tera Contributor

When task is created we are trying to update worknotes on case with task hyperlink by using this script

var task = "[code]<a href='/"+current.sys_class_name+".do?sys_id="+current.sys_id+"'>"+current.number+"</a>[/code]";

 

parentcase.work_notes = gs.getMessage("Case Task (0) has been created", task);

 

 

But we are getting output as

Case Task <a href='*******'>PROT0001261</a> has been created

 

Instead of hyperlink to the number we are getting like above. Please provide steps to fix it.

7 REPLIES 7

Tanushree Maiti
Kilo Patron

Hi @charanpatnala 

 

Your servicenow domain name was missing in URL.

Try with this :

 

parentcase.work_notes = 'Case Task [code]<a href="'+gs.getProperty('glide.servlet.uri')+'nav_to.do?uri='+current.sys_class_name+'.do?sys_id='+current.sys_id+'" target="_blank">'+current.number+'</a>[/code] has been created.';

 

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

Hi @Tanushree Maiti, thanks for your response.

I used the script given but this is the output I'm getting 

 

Case Task <a href="******" target="blank">PROT0001269</a> has been created.

 

Can you suggest any other option to fix it. 

Hi @charanpatnala 

Check Parentcase work notes field  is Journal field or not. Code tag works on Journal field .

 

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

AlfrinAJ
Tera Guru

Hello @charanpatnala, Try this below code...

var task = '[code]<a href="' + gs.getProperty('glide.servlet.uri') + '/'+ current.sys_class_name + '.do?sys_id=' + current.getUniqueValue() + '" target="_blank">' + 'Case Task '+current.number+' has been created.' + '</a>[/code]';
Parentcase.work_notes = task;
parentcase.update();

 

Please mark the answer helpful if the above code helps you!