Is there any script to add a credential alias? i want to add a credential alias of type basic auth

ratnaj
ServiceNow Employee
ServiceNow Employee
 
1 ACCEPTED SOLUTION

Thanks i got till here. This worked but i also need to create an credential alias for this to use it from flow rest action. How can i create a credential alias?

 

Thanks

Ratna

View solution in original post

8 REPLIES 8

Hello @ratnaj 

Create a new record in sys_alias table. This is the table that store credential alias.

This is how the form looks like:

JuhiPoddar_0-1734584508832.png

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps others find the solution more easily and supports the community!"

 

Thank You
Juhi Poddar

 

 

 

ratnaj
ServiceNow Employee
ServiceNow Employee

How do i write a script  and automate this using a script?

Hello @ratnaj 

Here is the script to create credential alias

var aliasGR = new GlideRecord('sys_alias');
// Initialize a new record
aliasGR.initialize();
// Set field values
aliasGR.name = 'my_custom_alias';         // Set the alias name
// Insert the record into the table
aliasGR.setValue('type', 'connection');     
var aliasSysId = aliasGR.insert();
if (aliasSysId) {
    gs.info('Alias record created successfully with Sys ID: ' + aliasSysId);
} else {
    gs.error('Failed to create alias record');
}

Result:

JuhiPoddar_0-1734593207612.png

Hope this helps!

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps others find the solution more easily and supports the community!"

 

Thank You
Juhi Poddar

ratnaj
ServiceNow Employee
ServiceNow Employee

Thanks Juhi . What I want to have is a an alias that links to credential record using script something like the one attached. 

 

Thanks

Ratna