Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Need request number of a catalog item in worknote of another catalog item

Cindy Sim
Tera Expert

I have 2 catalog items catalog items A and B. Cat item B is autogenerated from cat item A. I need to get Clickable request number for item A in the worknote of cat B. Any Suggestions?

1 ACCEPTED SOLUTION

Hi @Cindy Sim you need to use below code while updating worknotes to make clickable

 

[code]New request created: <a href="/sc_request.do?sys_id="+current.sys_id target="_blank">click here</a> <br/>
[/code]

Regards
Harish

View solution in original post

6 REPLIES 6

Maddysunil
Kilo Sage

@Cindy Sim 

Before Insert Business rule on sc_cat_item table, adjust the below code template:

 

(function executeRule(current, previous /*null when async*/) {

    // Check if the current record is a newly inserted record
    if (current.operation() == 'insert') {

        // Get the Request Number from the parent record (Catalog Item A)
        var parentRequestNumber = current.parent.getDisplayValue();

        // Generate the clickable link
        var clickableLink = "<a href='" + gs.getProperty('glide.servlet.uri') + "sc_request.do?sys_id=" + current.parent + "'>" + parentRequestNumber + "</a>";

        // Append the clickable link to the work notes of Catalog Item B
        current.work_notes = "Linked to Request: " + clickableLink + "\n" + current.work_notes;
    }

})(current, previous);

 

Above example  assumes that the reference field linking Catalog Item B to Catalog Item A is named "parent" in the "sc_cat_item" table. Adjust the script according to your actual field names.

 

Kindly mark helpful/accepted if it helps you.

Thanks

 

 @Maddysunil

Thank you for the reply. This script is working in bringing the request number. But I am still not able to create the clickable link to the Request. Do you have any suggestions on that?

 

@Cindy Sim 

I have updated the code little bit..Can you try once

 

(function executeRule(current, previous /*null when async*/) {

    if (current.operation() == 'insert') {
        // Get the Request Number from the parent record (Catalog Item A)
        var parentRequestSysId = current.parent;
        var parentRequestNumber = new GlideRecord('sc_request');
        if (parentRequestNumber.get(parentRequestSysId)) {

            var linkURL = gs.getProperty('glide.servlet.uri') + "sc_request.do?sys_id=" + parentRequestSysId;
            var clickableLink = "<a href='" + linkURL + "'>" + parentRequestNumber.getValue('number') + "</a>";

            // Append the clickable link to the work notes of Catalog Item B
            current.work_notes = "Linked to Request: " + clickableLink + "\n" + current.work_notes;
        }
    }

})(current, previous);

 

Please Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks

Harish KM
Kilo Patron
Kilo Patron

Hi @Cindy Sim how are you generating the Cat Item B? is it through flow designer?

Regards
Harish