Entitlement Scripts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2010 02:35 AM
Hi All
Can you get to the 'current' record within an entitlement script?
I'm using gs.log('Item removed:'+current.sys_id); as a starter, but would like to dotwalk from the sc_cat_item to another table to determine if the cat item is valid or not.
current.sys_id returns null.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2010 06:16 AM
When you are writing an entitlement script, you are writing that script on a particular record already, therefore there is no concept of "current".
So, if you are querying the sys_id, you should already know it when you are writing the script. The sys_id of the item is the same as the sys_id of the item that you are setting the entitlement script on.
For example, if you go to "Service Catalog->Maintain Items", then select an item such as the "Sales Laptop". You personalize the form on that item so that it shows the entitlement script.
in the entitlement script itself, you can get the URL of the sales laptop from clicking on the form and do "Copy SysID" or "Copy URL".
Then, in order to get the sc_cat_item record for the sales laptop, you can do this:
var gr = GlideRecord("sc_cat_item");
gr.get("e212a942c0a80165008313c59764eea1");
gr.query();
gr.next();
gs.log("SysID: " + gr.sys_id);
Please note, you already know the sys_id because it is on the record where you are typing the entitlement script. You can use that sys_id to get the record and then perform additional queries against the system if you need to.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2010 06:42 AM
Hi John
Thanks for your response...
for testing my entitlement script only has
gs.log('Removed:'+current.sys_id);
I have tried without the current without any joy...received the following error
org.mozilla.javascript.EcmaError: "sys_id" is not defined.
Caused by error in <refname> at line 1
==> 1: gs.log('Removed:'+sys_id);
2: false;
My end goal is to dotwalk to another table, something like u_assignment_rules_request.u_company;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2010 06:45 AM
Correct, there is no "current" object in an entitlement script. The only way to get something like "current" is to use the GlideRecord object with the script I provided to you. You already know the sys_id because it is the sys_id of the record where you are writing the entitlement script. You would have to copy and paste it into the script (hardcoded fashion).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-10-2012 03:32 PM
The "current" object is available, however it is not the GlideRecord of the sc_cat_item
It is an instance of the com.glideapp.servicecatalog.CatalogItem class
Specifically what you get from doing
Packages.com.glideapp.servicecatalog.CatalogItem.get(sys_id)
If you want the sys_id of the "current" catalog item in a Entitlement Script you can use
current.getID()