Hi Supriya,

Great job splitting the scripts! Your code logic for the Server-side Script Include (getBusinessUnit) is now perfectly structured for a filter.

Since it is still returning NULL, the issue is no longer the code itself, but likely a naming mismatch or access issue. The filter cannot "find" your class.

Let's debug this in 1 minute using "Scripts - Background":

The filter is just a UI wrapper. To find the root cause, we need to run the script directly on the server.

  1. Navigate to System Definition > Scripts - Background.

  2. Paste the exact line you are trying to use in the filter and wrap it in a print statement:

    JavaScript
     
    gs.info('Test Result: ' + new global.getBusinessUnit().businessunit());
  3. Click Run script.

Scenario A: You see an Error (e.g., "is not a function" or "undefined")

Cause: The system cannot find the Script Include. Fix: Check the Name field on the Script Include record.

  • The record Name in the list view MUST be exactly getBusinessUnit.

  • If the record is named GetBusinessUnit (Capital G) but your script says var getBusinessUnit (lowercase g), it will fail. They must match case-sensitively.

  • Ensure the API Name is indeed global.getBusinessUnit.

Scenario B: It prints the ID (Test Result: ac26...)

Cause: The Script Include works, but the Filter syntax is slightly off. Fix:

  • Remove the semicolon ; from the end of your filter string.

  • Try removing the global. prefix if you are operating in the Global scope.

    • Try: javascript:new getBusinessUnit().businessunit()

Summary: If Scripts - Background cannot see it, the Filter definitely won't. Please run that test and let me know the result!

If this helps you isolate the issue, please mark it as Accepted Solution.

Best regards, Brandão.