- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2016 10:16 PM
I want to create the automation of user entitlements or device entitlements
Can i used workflow scripting on RITM table. this my script but not working . please recommence me
try {
var gr = new GlideRecord("alm_entitlement");
var counter = new GlideRecord("sam_sw_counter");
counter.addQuery("sys_id", "=", current.variables['model.display_name']);
gr.query();
if (counter.next()){
current.variable.requested_for1=counter.display_name;
gs.addErrorMessage(gs.getMessage('current.variable.requested_for1'));
}
if (gr.next()){
var gr = new GlideRecord('alm_entitlement');
//gr.allocated_to = device.sys_id;
gr.assigned_to = current.variable.requested_for1;
gr.insert();
}
} catch(err) {
gs.log("Error");
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2016 08:45 PM
Hi Sudaporn,
I'm guessing you should change the reference of the variable "Sw_asset1" from "Software counter" to "Software Licenses [alm_license]".
I have just tried using the below code in my test-instance, record inserted correctly:
var user_entitlement = new GlideRecord('alm_entitlement_user');
user_entitlement.initialize();
user_entitlement.assigned_to = current.variables.Requested_for1;
user_entitlement.licensed_by = current.variables.Sw_asset1;
user_entitlement.insert();
Please tweak and test as you require.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2016 01:38 AM
Many thank you samiul , Now I can insert user entitlement but on device entitlement not have data in the allocate_to filed
This is My script
var user_entitlement = new GlideRecord('alm_entitlement_asset');
user_entitlement.initialize();
user_entitlement.allocated_to=current.variables.asset_tag1;
user_entitlement.licensed_by= current.variables.sw_asset1;
user_entitlement.insert();
var gr = new GlideRecord('alm_entitlement_user');
gr.initialize();
gr.assigned_to=current.variables.requested_for1;
gr.licensed_by= current.variables.sw_asset1;
gr.insert();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2016 04:30 AM
Does the variable - "asset_tag1" has any value?
How is it referenced? to which table?
You can test using background-script or gs.log or gs.addInfoMessage whether the "asset_tag1" variable contains any values.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2016 07:28 PM
Ohhh Yes, Samiul I check "asset_tag1" variable from "alm_hardware" table but allocated_to from "cmdb" table
