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

@Manikantahere 

I believe if you are getting the correct output then it should be fine.

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
Tera Patron
Tera Patron

@Manikantahere 

Would you mind closing your earlier questions by marking appropriate response as correct?

Members have invested their time and efforts in helping you.

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

_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);

 

terrillc
Tera Contributor

were