insert clickable link to RITM in TASK info message

will_smith
Mega Guru

I am trying to implement a clickable link to the RITM# in a catalog task. What is the general syntax around this? I've read up on the wiki.

function onDisplay(current, g_scratchpad) {

  //This function will be automatically called when this rule is processed.

  var ritmAttachments = new GlideRecord('sc_req_item');

  ritmAttachments.addQuery('sys_id', current.request_item.sys_id);

  ritmAttachments.query();

  while (ritmAttachments.next()){

  if(ritmAttachments.hasAttachments()){

  gs.addInfoMessage('Please see ' + current.request_item.getDisplayValue() + ' for attachments related to this task.'); //Wanting to make THIS clickable

  gs.addInfoMessage('You can track status from the <a href="home.do" class="breadcrumb" >Home Page</a>'); //What goes here to put the URL for the parent record????

  }

  }

}

1 ACCEPTED SOLUTION

Brian Dailey1
Kilo Sage

Hi William,



Try using something like this:



        var url = 'sc_req_item.do?sys_id=' + current.request_item.sys_id;


        var msg = 'Please see ' + current.request_item.getDisplayValue() + ' for attachments related to this task.'


        gs.addInfoMessage("<a href='" + url + "'>" + msg + "</a>");




Thanks,


-Brian


View solution in original post

4 REPLIES 4

Brian Dailey1
Kilo Sage

Hi William,



Try using something like this:



        var url = 'sc_req_item.do?sys_id=' + current.request_item.sys_id;


        var msg = 'Please see ' + current.request_item.getDisplayValue() + ' for attachments related to this task.'


        gs.addInfoMessage("<a href='" + url + "'>" + msg + "</a>");




Thanks,


-Brian


will_smith
Mega Guru

That is very helpful, thank you Brian!



I adopted your code a bit and used the following, as I think it looks a bit cleaner with only the RITM# highlighted. Thanks for the quick response.



function onDisplay(current, g_scratchpad) {


  //This function will be automatically called when this rule is processed.


  var ritmAttachments = new GlideRecord('sc_req_item');


  ritmAttachments.addQuery('sys_id', current.request_item.sys_id);


  ritmAttachments.query();


  while (ritmAttachments.next()){


  if(ritmAttachments.hasAttachments()){


  var url = 'sc_req_item.do?sys_id=' + current.request_item.sys_id;


  var ritmNum = current.request_item.getDisplayValue();


  //var msg = 'Please see ' + ritmNum + ' for attachments related to this task.';


  //gs.addInfoMessage("<a href='" + url + "'>" + msg + "</a>");


  gs.addInfoMessage('Please see '+"<a href='" + url + "'>" + ritmNum + "</a>" + ' for attachments related to this task.');


  //gs.addInfoMessage('You can track status from the <a href="home.do" class="breadcrumb" >Home Page</a>');


  }


  }


}


Hi William,



Here How I achieved a similar query to yours, Every time I send an email to our users, they've got the incident/request/req_item/task number into the email which is clickable and redirect them to the appropriate form,



Here is an example of incident, you can customize it as your requirement :


Under you email notification :


insert this following row : Call : (${URI_REF}/${nameOfYourField})



Kind regards,


ZA



Do not feel shy to mark correct or helpful answer if it helps or is correct


Sure, no problem.   Please mark as correct if it was a solution.  



Thanks,


-Brian




Edit:     *Thanks*