Flow designer - send email action with a request link

Snowman15
Tera Expert

Hi all, In flow designer I am trying to send an email via "send email" action, and I would like to know how I can include the request link within the email body for users to open it when they receive the email. I have checked the various existing posts but couldn't find/understand what to do. 

Thanks

Snowman15_0-1696603109761.png

 

4 REPLIES 4

Hemanth M1
Giga Sage
Giga Sage

Hi @Snowman15 ,

 

I have created a ServiceNow utilty for this on ServiceNow Share, you can download and import to your instance , it comes as action and you can use before your notification cation and have a link in the Send email action.

 

https://developer.servicenow.com/connect.do#!/share/contents/5982429_get_record_url_action_in_the_fl... 

 

let me know if additional details required.

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

Hi @Hemanth M1

I have done as you suggested, but didn't work, below the steps I took, please check if I missed something:

Action input: requested item table 

Snowman15_0-1696844724120.png

Script with input and  output

Snowman15_1-1696844806331.png

Output

Snowman15_2-1696844855228.png

Then I incorporated the action within the subflow and called it within email body

Snowman15_3-1696844947274.png

 

results: empty 

Snowman15_4-1696844982719.png

 

Hi @Snowman15 ,

 

Did you pass the sys_id of the RITM or Number as explained, Please check flow context 

 

As input select sc_req_item table and pass sys_id/RITM number from the datapill or as an input from the flow

 

HemanthM1_0-1697016778035.png

 

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

@Snowman15  Use the below script and it should work

(function execute(inputs, outputs) {
  var table = inputs.table;
  var number = inputs.number;
  var id = inputs.id;
  var display = inputs.linkdisplay;
  var record;

  if (!display) {
    display = "RecordLink";
  }

  // If sys_id is given
  if (id) {
    // Verify valid sys_id
    var validID = new GlideRecord(table);
    if (validID.get(id)) {
      record = '<a href="' + gs.getProperty('glide.servlet.uri') + table + '.do?sys_id=' + id + '">' + display + '</a>';
    } else {
      record = "Please provide a valid sys_id to get the URL";
    }
  }
  // If number is given
  else if (number) {
    // Get sys_id from the number
    var out = "";
    var findID = new GlideRecord(table);
    findID.addQuery("number", number);
    findID.setLimit(1);
    findID.query();
    if (findID.next()) {
      out = findID.getValue("sys_id");
      record = '<a href="' + gs.getProperty('glide.servlet.uri') + table + '.do?sys_id=' + out + '">' + display + '</a>';
    } else {
      record = "Not a valid Number, Please verify";
    }
  } else {
    record = "No sys_id and Number provided to get the record URL";
  }

  outputs.url = record;

})(inputs, outputs);


/*
(function execute(inputs, outputs) {
  // ... code ..
  var table =inputs.table;
  var number =inputs.number;
  var id =inputs.id;
  var display =inputs.linkdisplay;
  var record;
  
 if(!display){
 display ="RecordLink"
 }
  
  
  //if sys_id is given.
  if(id){
    //verify valid sys_id
    var validID = new GlideRecord(table);
    if(validID.get(id)){
     record = '<a href="https://' + gs.getProperty('instance_name') + '.service-now.com/nav_to.do?uri='+table+'.do?sys_id=' +id+ '">' +display + '</a>';
    }
    else{
      record = "Please provide valid sys_id to get the URL";
    }
  }
  //if numner is given
  else if(number){
    //get sys_id from the number 
    var out ="";
    var findID = new GlideRecord(table);
    findID.addQuery("number", number);
    findID.setLimit(1);
    findID.query();
    if(findID.next()){
      out =findID.getValue("sys_id");
        record = '<a href="https://' + gs.getProperty('instance_name') + '.service-now.com/nav_to.do?uri='+table+'.do?sys_id=' +out+ '">' + display + '</a>';
    }
    else{
    record = "Not a valid Number, Please verify";
    }
  }
    else{
      record ="No sysid and Number provided to get the record URL";
    }

    outputs.url =record;

  })(inputs, outputs);
*/