Error from getting Basic Auth credentials script

Ron28
Mega Sage

Hello, 

 

I'm scripting a Flow designer action where I need to get Basic Auth credentials.
My code is a copy from the api documentation, and in a scoped app. ServiceNow documentation is here - https://developer.servicenow.com/dev.do#!/reference/api/washingtondc/server/sn_cc-namespace/standard...

The error I am getting on the getCredentialById function call:

Evaluator: com.glide.script.RhinoEcmaError: Cannot find default value for object.
Process Automation.f56e6f3b1b6a0610159e433c8b4bcb54 : Line(3) column(0)
1: (function execute(inputs, outputs) {

2: let provider = sn_cc.StandardCredentialsProvider()

==> 3: let creds = provider.getCredentialByID('0d9982751baf7a506e15c9543b4bcb85')

4: outputs.username = creds.getAttribute('user_name')

5: outputs.password = creds.getAttribute('password')

6: })(inputs, outputs)

I know the sys_id of the record is valid, so it isn't that. The error I get is the same for doing this in my scoped app as well as running the first 2 lines of the above script in "background scripts".

Any idea how to get around this?

Thanks
Ron


1 ACCEPTED SOLUTION

Ron28
Mega Sage

I gather this only works for credentials records, not for Basic Auth as used in REST messages. The REST Message V2 API has setAuthenticationProfile to add a Basic Auth config record.

View solution in original post

3 REPLIES 3

Ron28
Mega Sage

Searching the logs, there is one additional error but is not shown in the execution record:

Ron28_0-1717967986998.png

txid=cca073b71b6a GlideRecord WARNING *** WARNING *** GlideRecord newGlideRecord() called with invalid table name: Process Automation

I would think the newGlideRecord call is inside the getCredentialById() script include?

 

The plot thickens, the error appears related to table sn_nowassist_skill_config, I found the following in the logs just prior to the "invalid table name" error:

txid=cca073b71b6a GlideRecord WARNING *** WARNING *** Get for non-existent record: sn_nowassist_skill_config:047dbe24434131100b7b5586bab8f25d, initializing
txid=cca073b71b6a GlideRecord WARNING *** WARNING *** GlideRecord newGlideRecord() called with invalid table name: Process Automation
txid=cca073b71b6a SysLog WARNING *** WARNING *** Evaluator: com.glide.script.RhinoEcmaError: Cannot find default value for object.

The sn_nowassist_skill_config table has no records in our system.

Ron28
Mega Sage

I gather this only works for credentials records, not for Basic Auth as used in REST messages. The REST Message V2 API has setAuthenticationProfile to add a Basic Auth config record.