Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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

I want logged in user's company, not the manager's company.

The logged in user's manager, company and department is the info I want.

And it looks like its working, but I still get the error saying 
Function getCompanyID is not allowed in scope sn_sc in sandbox

This is on my test instance, I have not tried this in prod yet..  I have no dev instance.

 

Hi,

Ideally getCompanyID() should be allowed in scope but since it is sn_sc scope i.e. Scope being created by ServiceNow not much sure on that.

Regards
Ankur

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

I'd probably raise this with ServiceNow (via HI).

I don't know why a default value JavaScript on a variable would be running on cart submission.


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

Did you find any update on this from ServiceNow(HI).

 

Regards,

Mihir Rathod.

LFM
Tera Contributor

Yes, I got this: 

Kindly let us know the output by making the below change . javascript:gs.getUser().getManagerName() / .getCompanyID() / .getDepartmentID() as default value. Please replace - gs.getUser() with gs.getUserID() Kindly refer similar problem request - PRB1151412 Global Search | MethodNotAllowedException: Function getUser is not allowed in scope Can you please try to replace the function getUser with getUserID ? Let us know if it resolves the warning message.

It resolved the warning message, but it didn't give me the functionality that I was aiming for, it gave me a drop-down-list to choose from. 

It's working fine as long as I use our customized service catalog, but I was trying to get it back to OOTB, but that's when I ran into this problem. I have not spent any more time on this since then.