Reference Qualifier not working

gautam_dhamija
Tera Contributor

This is my reference qualifier its not working:

gautam_dhamija_0-1736934903158.png

"I am calling the Script Include, and it is returning the correct value, as verified in the background script. Can someone please assist?"

Script Include:

gautam_dhamija_1-1736934979976.png

 

1 ACCEPTED SOLUTION

MackI
Kilo Sage

hi @gautam_dhamija 

 

I hope you are well and good.

 

Okay, I've analyzed the Script Include code you've provided. Here's a breakdown of the issues and how to fix them, along with explanations:

Issues and Corrections

Incorrect Return Value in getVendorFilter():

Problem: The getVendorFilter() function is returning vendorcode which is just the code, not the encoded query to filter the Original Purchase Order.
Solution: You need to return an encoded query string that can be used by the reference qualifier to filter records. The format should be 'vendor_code=' + vendorcode.

 

getVendorFilter: function(userId) {
    // ... (rest of your code) ...

    if (vendorGR.next()) {
        var vendorcode = vendorGR.vendor_code.toString(); 
        gs.info("Vendor Code: " + vendorcode); // Log for debugging

        // Return the encoded query string
        return 'vendor_code=' + vendorcode;
    }
    // Return an empty string or a default query if no vendor is found
    return ''; // Or return a query like 'vendor_code=INVALID';
},

 

If you like this opinion and your problem is resolved after reviewing and applying it. Please kindly mark this your best answer‌(Accepted Solution) 🌠‌ OR  mark it  Helpful ‌‌ if you think that you get some insight from this content relevant to your problem and help me to contribute more to this community

MackI | ServiceNow Developer | 2 *Mainline Certification | LinkedIn Top IT Operation Voice 2023 | Sydney,Australia

View solution in original post

2 REPLIES 2

Juhi Poddar
Kilo Patron

Hello @gautam_dhamija 

Are you able to get the vendorcode in syslog table?

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"

 

Thank You
Juhi Poddar

MackI
Kilo Sage

hi @gautam_dhamija 

 

I hope you are well and good.

 

Okay, I've analyzed the Script Include code you've provided. Here's a breakdown of the issues and how to fix them, along with explanations:

Issues and Corrections

Incorrect Return Value in getVendorFilter():

Problem: The getVendorFilter() function is returning vendorcode which is just the code, not the encoded query to filter the Original Purchase Order.
Solution: You need to return an encoded query string that can be used by the reference qualifier to filter records. The format should be 'vendor_code=' + vendorcode.

 

getVendorFilter: function(userId) {
    // ... (rest of your code) ...

    if (vendorGR.next()) {
        var vendorcode = vendorGR.vendor_code.toString(); 
        gs.info("Vendor Code: " + vendorcode); // Log for debugging

        // Return the encoded query string
        return 'vendor_code=' + vendorcode;
    }
    // Return an empty string or a default query if no vendor is found
    return ''; // Or return a query like 'vendor_code=INVALID';
},

 

If you like this opinion and your problem is resolved after reviewing and applying it. Please kindly mark this your best answer‌(Accepted Solution) 🌠‌ OR  mark it  Helpful ‌‌ if you think that you get some insight from this content relevant to your problem and help me to contribute more to this community

MackI | ServiceNow Developer | 2 *Mainline Certification | LinkedIn Top IT Operation Voice 2023 | Sydney,Australia