- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2024 06:42 AM
Hello community,
I want to use a script include in my dynamic filter.
Dynamic filter looks like this:
My script include looks like this:
Use case scenario:
In other words, when a user is set as a delegate with the specified delegation rule, he/she should see his/her Controls and also Controls where the Entity owner is an user, who created a delegation.
But for some reason my script include does not work.
I also had this script include, which worked perfectly, but it had to be adjusted:
function getIAmDelegate() {
var grDelegate = new GlideRecord('sys_granular_delegate');
var now = new GlideDateTime();
grDelegate.addEncodedQuery('delegate=' + gs.getUserID() + '^starts<=' + now + '^ends>=' + now);
grDelegate._query();
var delegateArr = [];
while (grDelegate._next()) {
delegateArr.push(grDelegate.getValue('user'));
}
return delegateArr;
}
Would you know, why does not it work?
I am a bit lost and to be honest, not that experienced in scripting.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2024 08:48 AM
Ok, so the resolution is: stupid me.
It really was the way I was calling the script.
What works for me now is this: new global.getIAmDelegate().getIAmDelegate();
getIAmDelegate() worked in my previous script so I presumed it will work in this one as well.
Also, thank you for your advice about the good practice. I will rename my function.
Thanks a lot, Brian!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2024 07:20 AM
try in the script field getIAmDelegate().getIAmDelegate(). Typically you have to call the script include and the function unless you create a specific type of script include which I cannot remember the name of. Also I don't think it is good practice to have the script include and function names the same.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2024 07:33 AM
Hello Brian,
thanks a lot for your reply.
I've tried getIAmDelegate().getIAmDelegate() in the script field but it still does not work.
I have the same script as a background script and it gives me correct values.
My background script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2024 08:48 AM
Ok, so the resolution is: stupid me.
It really was the way I was calling the script.
What works for me now is this: new global.getIAmDelegate().getIAmDelegate();
getIAmDelegate() worked in my previous script so I presumed it will work in this one as well.
Also, thank you for your advice about the good practice. I will rename my function.
Thanks a lot, Brian!!