Why RITM URL is not populating as a output?

Manikantahere
Tera Contributor


I need to send the RITM number appended link to it as a parameter but before it I am just checking whether its coming as a output or not? I got no luck. What went wrong in ritm_url variable value??

 

(function execute(inputs, outputs) {

var ritm_url = '<a href=" ' + gs.getProperty('glide.servlet.uri') +inputs['ritmTableName']+'.do?sys_id=' + inputs['ritmSysId'] +'">' + inputs['requestNumber'] + '</a>';

outputs.url = ritm_url;



})(inputs, outputs);

 

url -2.png

2 ACCEPTED SOLUTIONS

@Manikantahere 

try this, I could see you are getting the sysId and request number correct

you cannot get the value using this syntax inputs['ritmTableName']

there was an extra space before href

(function execute(inputs, outputs) {

    var ritm_url = '<a href="https//' + gs.getProperty("glide.servlet.uri") + '/' + inputs.ritmTableName + '.do?sys_id=' + inputs.ritmSysId + '">' + inputs.requestNumber + '</a>';
    outputs.url = ritm_url;

})(inputs, outputs);

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

_ukasz Rybicki
Giga Guru

Your anchor tag has two issues:

  1. Extra space in the href
    You wrote '<a href=" ' + … which outputs <a href=" https://…">. That leading space breaks the URL.

  2. Wrong input key
    If inputs['ritmTableName'] isn’t defined, you end up with undefined.do?sys_id=…. Make sure the input name in your Flow Action exactly matches (e.g. inputs.ritmTableName vs inputs.ritm_table_name).

Fixed version (no stray space, correct inputs):

(function execute(inputs, outputs) {
  // ensure glide.servlet.uri ends with '/'
  var base  = gs.getProperty('glide.servlet.uri');
  var table = inputs.ritmTableName;    // must match your defined input name
  var id    = inputs.ritmSysId;
  var num   = inputs.requestNumber;

  var ritm_url = 
    '<a href="' + base + table + '.do?sys_id=' + id + '">' +
    num +
    '</a>';

  outputs.url = ritm_url;
})(inputs, outputs);

 

View solution in original post

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

@Manikantahere 

I could see sysId getting replaced correctly

Is the next part not getting reflected correct i.e. number?

share what input you are passing and what came in log for inputs?

try this

(function execute(inputs, outputs) {

var ritm_url = '<a href=" ' + gs.getProperty('glide.servlet.uri') +inputs['ritmTableName']+'.do?sys_id=' + inputs['ritmSysId'] +'">' + inputs.requestNumber + '</a>';

outputs.url = ritm_url;

})(inputs, outputs);

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Thanks for reply @Ankur Bawiskar 
Please ignore extra inputs as I need them for further rest call to third party.

How it came as out put I have share the pic in main post itself and you can see the inputs and log as well.

url-1.pngurl-2.pngurl-3.png

@Manikantahere 

try this, I could see you are getting the sysId and request number correct

you cannot get the value using this syntax inputs['ritmTableName']

there was an extra space before href

(function execute(inputs, outputs) {

    var ritm_url = '<a href="https//' + gs.getProperty("glide.servlet.uri") + '/' + inputs.ritmTableName + '.do?sys_id=' + inputs.ritmSysId + '">' + inputs.requestNumber + '</a>';
    outputs.url = ritm_url;

})(inputs, outputs);

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

@Ankur Bawiskar  this is what I am getting even after keeping as it is as you suggested?

result-1.png

 

When I click on it I am getting as below and when I went to Rendered HTML I am getting RITM number and if I click on it it is navigating to requested Item as expected.

However coming output as above is expected behaviour or we can do anything directly returning as Rendered HTML Content.


Please refer below image for more clarity.
result-2.png