- 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
10-30-2016 10:45 PM
Hi Sudaporn,
Before you seek assistance for your scripts, I would suggest you if you could have a look at these pages for references first:
- GlideRecord Query Cheat Sheet - ServiceNow Guru
- http://wiki.servicenow.com/?title=GlideRecord#gsc.tab=0
Let me know how you go.
Thanks,
Samiul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2016 12:10 AM
var Entitle = new GlideRecord('alm_entitlement_user');
Entitle.initialize();
Entitle.assigned_to = current.variable.requested_for1;
Entitle.allocated_to = current.variable.sw_asset1;
Entitle.insert();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2016 02:56 PM
did it work?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2016 07:55 PM
Now i use this script below.
gs.log("test1");
try {
var Entitle = new GlideRecord('alm_entitlement_user');
Entitle.initialize();
Entitle.assigned_to = current.variable.requested_for1;
Entitle.licensed_by = current.variable.sw_asset1;
Entitle.insert();
gs.log("test10");
} catch(err) {
gs.log("Error");
}
Then
Can create record to "user entitlement" but the new record on user entitlement did not show data information. (picture1)
the data form variables (picture 2) I don't know,Why
picture 1
picture 2