- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2023 12:10 AM
I am trying to create a catalog and my requirement is to create 2 values in the catalog
1. a referencefield whose value will be from sys_alias table for which I have created 1 record in connection & credential alias and have provided an API key for the same
2. a lookup select field whose values will get populated onchange of the reference filed
I am trying to write a client script onchange of the first field and trying to make a rest api call in the script , but the challenge is how do I pass the api key from the first field so that I can authenticate the api and send the response .
I have tried the below option but they don't provide any useful info
alert(g_form.getDisplayValue('alias_selected'));
alert(g_form.getValue("alias_select"));
is there a way to achieve this or any other alternate that i can try
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2023 02:24 AM
@kiwi07 Okay Got it. Gliderecord to the API key table where they are stored and pass the alias name and return the API key
Example:
IF servicenow is alias
Key will be stored in below connection table
Gliderecord connection table with the name as Servicenow alias and return the API key
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2023 01:18 AM
@kiwi07 you can make use of the Client script and Script include as mentioned pervioulsy
When you are selecting the Alias pass the alias value to script include and check if the alias is the "Sample Alias" make a rest call and return value back to Client script and set.
Smiliary you can check other alias in SI using If Else loop and call the rest messgae and return value
One more clarification @kiwi07 have you configured the Rest messgaes whih you are going to invoke in Script include which will give you the API keys?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2023 01:38 AM
@Omkar Kumbhar may be i am not able to explain properly , API key is already added inside the alias, let me try to explain in a diff way, i will write the client script as below
var request = new sn_ws.RESTMessageV2();
request.setEndpoint('ENDPOINT of third party tool');
request.setHttpMethod('POST'); //mention here POST or GET
/*Use one of the below statement to set authentication*/
request.setRequestHeader('Authorization','Basic SU5UTFxBNjEzNjIzOklORllAMTAwOA==');
//Set here how you are sending the data i.e. XML or JSON
request.setRequestHeader("Accept","application/xml");
request.setRequestHeader('Content-Type','application/xml');
the question is how do I pass the API key that I have added in the alias below
request.setRequestHeader('Authorization','<sample_alias>');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2023 01:56 AM
@kiwi07 if you are wrinting this code on client side you can use and try
request.setRequestHeader('Authorization','g_form.getValue('Alias field name'));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2023 02:05 AM
@Omkar Kumbhar Tried it but this just gives the name of the alias , we have API key inside the alis is there a way to get that ?
g_form.getValue('Alias field name')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2023 02:24 AM
@kiwi07 Okay Got it. Gliderecord to the API key table where they are stored and pass the alias name and return the API key
Example:
IF servicenow is alias
Key will be stored in below connection table
Gliderecord connection table with the name as Servicenow alias and return the API key