Hr criteria for widget

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2023 06:07 AM
I need to display a link in the footer of a portal the visiblity of the footer is based on the hr criteria so i have written below code but it is not working. Can anyone help me with this.
on html:
<div ng-if="data.checkingFooter=='true'">
<h>test<h>
<div>
server side:
data.checkingFooter='false';
var sa=gs.getUserDisplayName();
var wb = new GlideRecord('sn_hr_core_profile');
wb.addEncodedQuery('active=true');
wb.query();
while(wb.next()){
var abUser=wb.getValue('user');
if(abUser==sa){
data.checkingFooter='true';
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2023 06:17 AM
Hi @Community Alums ,
Below is corrected version of your code:
-HTML : (assuming you have a widget with the server script and want to conditionally display the footer based on the checkingFooter
variable):
<div ng-if="data.checkingFooter === 'true'">
<h>test</h>
</div>
-Server Script (assuming this is server-side script within your widget):
data.checkingFooter = 'false';
var sa = gs.getUserDisplayName();
var wb = new GlideRecord('sn_hr_core_profile');
wb.addEncodedQuery('active=true');
wb.query();
while (wb.next()) {
var abUser = wb.getValue('user');
if (abUser == sa) {
data.checkingFooter = 'true';
break; // Exit the loop once a match is found
}
}
Thanks,
Ratnakar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2023 06:22 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2023 06:36 AM
Hi @Community Alums ,
Ohh, Let's troubleshoot further.
Here are some steps to help identify and resolve the issue:
-
Verify Data: Double-check that your HR criteria and user matching logic in the server script are correct. Ensure that there are HR profiles with the
active
field set totrue
and that your user's display name (sa
) matches theuser
field in the HR profiles exactly. -
Debugging: To pinpoint the issue, add some debugging statements to your server script. For example, you can use
gs.log
to log messages. Add log statements before and after theif
condition to see if it's being triggered:data.checkingFooter = 'false'; var sa = gs.getUserDisplayName(); var wb = new GlideRecord('sn_hr_core_profile'); wb.addEncodedQuery('active=true'); wb.query(); while (wb.next()) { var abUser = wb.getValue('user'); gs.log('Comparing: ' + abUser + ' === ' + sa); if (abUser == sa) { data.checkingFooter = 'true'; break; // Exit the loop once a match is found } } gs.log('Footer visibility: ' + data.checkingFooter);
After adding the logging, review the system logs to see if the condition is working as expected.
- HTML Debugging: To verify the HTML part, you can add some temporary text to the footer to check if it's being displayed at all. For example:
<div ng-if="data.checkingFooter === 'true'"> <h>test</h> <p>Footer is displayed</p> <!-- Add this line for testing --> </div>
If you see the "Footer is displayed" message, it means the condition is met, and the issue might be related to the content you're trying to display in the footer.
-
Browser Developer Tools: Use your browser's developer tools to inspect the HTML and AngularJS bindings. Check the browser console for any JavaScript errors that might be affecting the behavior.
-
Cache Clearing: If you made changes to the code, clear your browser's cache to ensure that you're seeing the most up-to-date version of the portal.
Thanks,
Ratnakar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2023 01:25 PM
@Ratnakar7 i have tried to debug the code but didnt find where the error was going as i used gs.info in else part of server side it is constantly executing else part
Can i use the hr criteria as below but still these also i was not able to get
var userCriterias = ['6b6df061ff2121009b20ffffffffff44','0b5b0e6453631300afffddeeff7b1201']; var userMatches = sn_uc.UserCriteriaLoader.userMatches(gs.getUserID(), userCriterias); gs.info(userMatches);