How to get URL of a record from flow designer?

Meghant Rai
Kilo Guru

I have a requirement where I have to mention the incident number in worknotes/Additional comments section in form of Hyperlink.

I can do it via [code]<a href="https://www.servicenow.com">ServiceNow.com</a>[/code], but the question is how can I get the URL of the incident. 

There are no data pills available to fetch URL of incident to re-direct on click.

1 ACCEPTED SOLUTION

Hi,

so what is pending?

you can get current record sys_id inside the f(x) script like this

var sysId = fd_data.trigger.current.sys_id;

That would help you form the URL to the record

like this; it would add link to current record on which flow is running

var tableName = fd_data.trigger.current.sys_class_name;

var sysId = fd_data.trigger.current.sys_id;

var url = '[code]<a href="' + gs.getProperty('glide.servlet.uri') + '/nav_to.do?uri=' + tableName + '.do?sys_id=' + sysId + '">' + 'My Record' + '</a>[/code]';

return url;

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

12 REPLIES 12

Hi Ankur,

 

It created a hyperlink, however when I try to click it the page again gets re-directed to homepage. Whereas if I try to open link in new tab or new window it is working perfectly.

 

Any reasons why its not working on normal click?

try now, no to do use nav_to.do

 

eg:

 

var tableName = fd_data.trigger.current.sys_class_name;

var sysId = fd_data.trigger.current.sys_id;

var url = '[code]<a href="' + gs.getProperty('glide.servlet.uri') + '/' + tableName + '.do?sys_id=' + sysId + '">' + 'My Record' + '</a>[/code]';

return url;

 

If my answer helped you, kindly mark it as correct and helpful.

 

@Meghant Rai 

To open in new window, please try with below updated script: 

 

var tableName = fd_data.trigger.current.sys_class_name;

var sysId = fd_data.trigger.current.sys_id;

var url = '[code]<a href="' + gs.getProperty('glide.servlet.uri') + '/' + tableName + '.do?sys_id=' + sysId + '"target="_blank">' + 'My Record' + '</a>[/code]';

return url;

 

Note: I have tested and working fine in my personal instance. 

 

If my answer helped you, kindly mark it as correct and helpful.

It worked

@Meghant Rai 

 

Glad it worked. 

Did you accidently mark other answer as correct? kindly select the correct answer and working script.