Controlling Activity Configuration being visible on the widget using User Criteria script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2025 08:14 AM
Hi all,
We've added a couple of custom activities to the My Items widget on our Employee Centre. They're working perfectly fine however we only want the one highlighted, 'Device Needing Certification', to appear if the user has a device that requires them to respond confirming that the device is theirs. As you can see below I have one that I need to respond to so it shows 1, however if it were to be 0 I would want it to be hidden.
It seems obvious that I can control this using the user criteria module however I'm having trouble with the script I'm using and I'm wondering if anyone has done something similar in the past that could help.
My current script is as below. Essentially I want to lookup the cert_follow_on_task to see if there is an open task where the user in the u_info_required_from field is the current logged in user, and that the u_confirm_posession_device is 'pending response'.
I'm sure the dynamic user for u_info_required_from isn't going to work as I copied it from somewhere else where we use it an it works but I'm unsure how we can query this correctly.
(function() {
var answer = false; // Default to false
var gr = new GlideRecord('cert_follow_on_task'); // Ensure this is the correct table name
gr.addQuery('state', '1');
gr.addQuery('u_info_required_from', 'DYNAMIC90d1921e5f510100a9ad2572f2b477fe');
gr.addQuery('u_confirm_possession_device', 'pending response');
gr.query();
if (gr.hasNext()) {
answer = true;
}
return answer;
})();
Thank you in advance!