Embed Links to Additional Comments in Flow Designer

josgarcia
Tera Expert

Hello, I am trying to embed a link to a message within Flow Designer. I was following this form but that wasn't working so I tried this below:

(function executeRule() {
    // Get the sys_id from the Flow Designer's fd_data
    var sysId = fd_data.trigger.request_item.sys_id;

    // Make sure sysId is available
    if (sysId) {
        var tableName = 'sc_req_item';  // Table name for the RITM
        var number = fd_data.trigger.request_item.number;  // Assuming you have access to the RITM number
        var baseUrl = gs.getProperty('glide.servlet.uri');  // Get the base URL of the instance
        
        // Construct the URL
        var url = '<a href="https://compass.sofi.com/esc?id=kb_article&table=kb_knowledge&sysparm_article=KB0010302">Windows 365 Cloud PC</a>';
        
        // Create the comment with the embedded link
        var comment = 'Your Windows 365 Cloud PC request has been approved. See ' + url + ' for instructions on accessing it. Please allow 60 minutes for it to complete deployment.';
        
        // Update the comments field with the constructed comment
        var gr = new GlideRecord(tableName);
        if (gr.get(sysId)) {
            gr.comments = comment;
            gr.update();
        }
    } else {
        gs.error('No sys_id found for the current record.');
    }
})();

 I am able to get the message posted but it doesn't embed the link into the comment. Can someone help enlighten me on what I am missing here?

 

Results:

josgarcia_0-1719328293400.png

Thank you

1 ACCEPTED SOLUTION

Kristen Dettman
Kilo Sage

I believe you need to add [CODE]<your html tag here>[/CODE] in order to get the comments field to recognize your HTML. Without that, it's representing your code as plain text.

View solution in original post

6 REPLIES 6

@josgarcia Thanks for this info. but when I tried, the whole "[code] "is also populated in work notes. 

Code: 

var link = fd_data._7__create_record.record.getLink();

var url = '<a href='+'https://xxxxxxx.service-now.com/'+link+'></a>';

var shortDes = 'Here is the link'+ [CODE]+url+[/CODE];

return shortDes;

Output:

Here is the link [CODE]<a href=https://xxxxxx.service-now.com/change_request.do?sys_id=fdb86d0093fe76d0571db9547aba10cd&sysparm_sta...></a>[/CODE]

 

Where am I going wrong?

I got it resolved and fix was simple.

Where it went wrong: 

var shortDes = 'Here is the link'+ [CODE]+url+[/CODE];

return shortDes;

Correct way:

 

return 'Here is the link: [CODE]'+url+'[/CODE]';

Instead of variable + [CODE], adding it together in a single quote worked for me (I guess, separating/adding [CODE] made the instance not to realize to wrap it as a link.