- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2016 08:47 AM
I am trying to write an Entitlement Script that will allow users with a specific Business Partner to access a Record Producer Item in our Catalog. The problem is that the Business Partner field is on the Department table and I don't appear to be able to double dot walk in a Entitlement Script. Below is the Script that I have been trying to get to work but have not had any success. This is the first time I have tried to use an entitlement script and I don't really know what I am doing. Any help would be appreciated.
var gr = new GlideRecord('sys_user');
gr.get(gs.getUserID());
var dept = gr.department.getDisplayValue();
var gr1 = new GlideRecord("cmn_department");
gr1.addQuery('id', '=', dept);
while(gr1.next()) {
var bp = gr1.u_business_partner.getDisplayValue();
if (bp == "Digital"){
true;
}
else{
false;
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2016 02:28 PM
That almost got me there but I had to make a couple changes to get it to work. Thank you everyone for your help. Here is what finally worked:
var gr = new GlideRecord('sys_user');
gr.get(gs.getUserID());
var dept = gr.department;
//gs.addInfoMessage(dept);
var gr1 = new GlideRecord('cmn_department');
gr1.addQuery('sys_id', dept);
gr1.query();
while(gr1.next()) {
var bp = gr1.u_business_partner.getDisplayValue(); //remove .getDisplayValue() if this field is not a reference field
if (bp == "Digital"){
answer = true;
}
else{
answer = false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2016 02:28 PM
That almost got me there but I had to make a couple changes to get it to work. Thank you everyone for your help. Here is what finally worked:
var gr = new GlideRecord('sys_user');
gr.get(gs.getUserID());
var dept = gr.department;
//gs.addInfoMessage(dept);
var gr1 = new GlideRecord('cmn_department');
gr1.addQuery('sys_id', dept);
gr1.query();
while(gr1.next()) {
var bp = gr1.u_business_partner.getDisplayValue(); //remove .getDisplayValue() if this field is not a reference field
if (bp == "Digital"){
answer = true;
}
else{
answer = false;
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2016 02:32 PM
Hi Anthony,
If you use
var dept = gr.department.getDisplayValue() then the code I provided should have work.
BDW Glad your issue is resolved now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2016 03:01 AM
Hi Pradeep,
I'm facing a an issue with my entitlement script.I am trying to hide a catalog item based on the location/country of the user. I am trying the below script but nothing is working i believe.
Can you help me out here how to hide my catalog item for specific users. This is my first attempt at an entitlement script.
var country = gs.getUser().getCountry();
if(country=='IN'){
answer= true;
}
else
{
answer = false;
}