- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2022 07:48 AM
I integrated AWS successfully with ServiceNow and am able to read the AWS catalogs .I am able to see all the parameters and provide some values and successfully ivoke aws.
Problem: I want to automatically pass the values to the aws parameters from servicenow ' sys_user ' table based on 'requested_for' variable. I am able to pull all required information from sys_user but not able to find the parameter fields in catalog item to pass it from client script.
Wanted some help here how can we access aws parameters( Department, CostCenter). I could find a table 'Aws Service Catalog Product'(Attached) which has the data, able to glide it and pass the Product_sys_ID as well but no luck in setting parameter values.
Client Script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var reqsysID= g_form.getValue('ProvisionedProductName');
alert(reqsysID);
var reqgr= new GlideRecord('x_126749_aws_sc_cmdb_ci_pp');
reqgr.addQuery('name', reqsysID);
reqgr.Query();
while (reqgr.next()){
g_form.setValue('cost_center', '123'); // will fetch this from sys_user and pass it, but the // g_form don't pick the cost_center which is an // aws parameter from
//'x_126749_aws_sc_cmdb_ci_pp' Table
}
}
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2022 10:12 AM
So this line
var pp = [];
if(current.variables.ProvisioningParameters)
pp = JSON.parse("" + current.variables.ProvisioningParameters.getDecryptedValue());
is of no help to look at the format had how you may be able to change it to ad or change the information being passed?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2022 08:26 AM
Is you use the AWS Service Management Connector they store all of that in one of the variables in a JSON format if I remember correctly. There is a UI policy to hide that variable. So what I did to pass more information in tags was to update the workflow to add a script activity that would add the additional information. Here is the code I used for adding tags to a workspace.
//Add custom Tags
var tags = [];
if(current.variables.Tags)
tags = JSON.parse("" + current.variables.Tags);
tags.push({
Key: "Requested On",
Value: current.getDisplayValue("sys_created_on")
});
var pp = [];
if(current.variables.ProvisioningParameters)
pp = JSON.parse("" + current.variables.ProvisioningParameters.getDecryptedValue());
//Check to see if there is a User Name and if so look up that value in the LAN ID column on the user table.
//If found then add the user data tags.
var lanID = "";
if(pp.length > 0){
for(var i in pp){
if(pp[i].Key == "UserName"){
lanID = pp[i].Value;
break;
}
}
}
var costCenterName = "Not Found";
var timeZoneName = "Not Found";
var buName = "Not Found";
if(lanID){
var user = new GlideRecord("sys_user");
if(user.get("u_lan_id", lanID)){
//Since we found a user record set values for the tags save the sys_id for later
workflow.scratchpad.assigned_to = user.getValue("sys_id");
//Business Unit
var buID = (new global.BusinessUnitHelper()).getUserTopLevelBU(user.getValue("sys_id"));
var bu = new GlideRecord("business_unit");
if(bu.get(buID)){
buName = bu.getDisplayValue();
}
//Cost Center
costCenterName = user.cost_center.account_number.toString();
//Time Zone
timeZoneName = user.getDisplayValue("time_zone");
}
}
tags.push({
Key: "Business Unit",
Value: buName
});
tags.push({
Key: "Cost Center",
Value: costCenterName
});
tags.push({
Key: "Time Zone",
Value: timeZoneName
});
current.variables.Tags = JSON.stringify(tags);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2022 09:24 AM
Thanks but sadly, this approach don't work. I am able to create tags and pass values directly but not to the paramaters.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2022 10:12 AM
So this line
var pp = [];
if(current.variables.ProvisioningParameters)
pp = JSON.parse("" + current.variables.ProvisioningParameters.getDecryptedValue());
is of no help to look at the format had how you may be able to change it to ad or change the information being passed?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-22-2022 03:39 AM
Hi Drew,
Thank you very much. After understanding the architecture of AWS and trying the below from my workflow, I could generate tags and send the variables over to AWS using AWS service Management Connector.
If this might help someone:
- Create your variables or variables set in Servicenow and you can pass the values over tags from the run script in the workflow.
var tags = [];
if(current.variables.Tags)
tags = JSON.parse("" + current.variables.Tags);
tags.push({
Key: "Requested On",
Value: current.getDisplayValue("sys_created_on")
});
Thanks,
Kishan