BR is not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 09:31 AM
Hi All,
I am trying below code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 10:05 AM
Are you getting an expected value in your usr infoMessage? And this value exactly matches the name field on a record on the location table, and the hardcoded value you are using in the background script? You should always declare and initialize variables outside of any loops or if blocks. As written, 'flag' is undefined in the else block
var usr=gs.getUserName();
var flag = '';
gs.addInfoMessage("usr = "+usr);
var pc=new GlideRecord("cmn_location");
pc.addQuery('name', usr);
pc.query();
if (pc.next()) {
flag=pc.name;
gs.addInfoMessage('if ' + flag);
} else {
flag='111111';
gs.addInfoMessage('else ' + flag);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 10:27 AM
Hi @Brad Bowman ,
Yes, I am getting the expected value in usr info message. And the usr is available in location table as well.
I have tried with your code as well. Still it is going else part.
In bg script it is working correctly.
In form it is going to else.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 10:55 AM
If anything I would expect the bg script to not work as the number 2000246 could be seen as not equal to the text value '2000246'. If you hardcode the BR the same way instead of getUserName does it find the location record?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 11:49 AM - edited 03-12-2024 11:50 AM
Hi @Madhavi2 ,
If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!
Thanks & Regards,
Sumanth Meda