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

Juhi Poddar
Kilo Patron

Hello @ratnaj 

You can try this script to meet your requirements:

// Create a new record in basic_auth_credentials
var basicAuthCred = new GlideRecord('basic_auth_credentials');
basicAuthCred.initialize();
basicAuthCred.name = 'MyBasicAuthCredential'; // Credential name
basicAuthCred.username = 'your_username'; // Basic Auth username
basicAuthCred.password = 'your_password'; // Basic Auth password
basicAuthCred.comment = 'This is a Basic Auth credential for API integration'; // Optional description

// Insert the record
basicAuthCred.insert();

 

"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

Harish Bainsla
Kilo Patron
Kilo Patron

Hi @ratnaj please check below code and fill details as per your need i kept field empty

var credential = new GlideRecord('basic_auth_credentials');
credential.initialize();
credential.name =' ';
credential.user_name =' ';
credential.password =' ';
credential.insert();
I will check it in pdi its working and create credentials check below scrrenshot
HarishBainsla_0-1734517117646.png
HarishBainsla_1-1734517129748.png

 

if my answer helps you mark helpful and accept 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

For that you can post new question and if my previous answer helps you please mark helpful and accept solution