Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Function getCompanyID is not allowed in scope sn_sc in sandbox

LFM
Tera Contributor

I've created a variable set to use on my Request items

I want the variable set to provide logged in users manager, company and department, so I added javascript:gs.getUser().getManagerName() / .getCompanyID() / .getDepartmentID() as default value.

When checking out the order, I get an error; saying Function getCompanyID is not allowed in scope sn_sc in sandbox.

But it looks like every thing is working as intended, the information that I wanted is provided in the requested item, and the request is submitted.

But I don't like having an error message showing up every time somebody order something, and I have no clue on where to start fixing this.

 

11 REPLIES 11

paulmorris
Giga Sage

Hey,

Can you clarify this part:

" scope sn_sc in sandbox."

According to the Product Documentation, getCompanyID() is a valid function of GlideUser in an Application Scope.

The only way I know of to run code in scope is in Sandbox Mode via Background Scripts.

 


ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

LFM
Tera Contributor

I'm sorry, I cannot clarify - it's the message that's pops up, I have no idea what it means.

find_real_file.png

jsanjuan
ServiceNow Employee

You can also check if a "Dynamic Filter Option"/sys_filter_option  calls gs.getUser().getCompanyID(). Deactivating it may resolve the message.

Ankur Bawiskar
Tera Patron

Hi,

getManagerName() is not a function which is available. Possibly it is breaking at that point.

getManagerID - is not allowed in scope
getCompanyID - is allowed in scope

In order to get logged in user's manager's company etc you can use script in the default value

javascript: var company; var rec = new GlideRecord('sys_user'); rec.get(gs.getUserID()); var manager = new GlideRecord('sys_user'); manager.get(rec.manager); company = manager.company; company;

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader