- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 04:49 AM
Hi everyone, how are you?!
In order for me to be able to get the value of the "email" field, I initialize it using the form in the first
table (cmdb_cit_business) then I need to do a dot walk, in two different tables, because the field is a reference (Business Parnet Department) PRINT_1:
Within this field there is another table (cmn_department) where there is the "Holder" field (which is also a reference field) PRINT_2
In turn, there is another table (sys_user), this will have the email field, which I need to get the value of. PRINT_3
I tried to do it this way, but it's not working, does anyone have any suggestions?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 06:11 AM - edited 11-16-2023 06:17 AM
Here i have taken example of incident table.
It has Configuration item Reference field. then the table contains a Owned by field, which refers to sys_user table where the Mail field is present.
Check the below script to find mail .
var grCmdbInc = new GlideRecord('incident');
grCmdbInc.addEncodedQuery('cmdb_ciISNOTEMPTY^active=true^sys_id='+recordsysId);
grCmdbInc.query();
while (grCmdbInc.next()){
if(grCmdbInc.cmdb_ci.owned_by&&grCmdbInc.cmdb_ci.owned_by.email){
gs.info(grCmdbInc.cmdb_ci.owned_by.email);
}
}
Make the changes as per your requirement and you should be able to get the data.
Just to point out, in your script, in while loop, you have written gr.next(), instead of grCmdb.next()
Please mark as correct if it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 08:32 AM
Check this article https://developer.servicenow.com/dev.do#!/learn/learning-plans/tokyo/servicenow_administrator/app_st...
In condition field, it will evaluate for the condition to send the mail, so this field will only return true/false. nothing else. Is that the same purpose you are using the script?
By recordsysid, i meant sysid of a specific record, for testing purpose.
What exactly you want to achieve from that script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 02:17 PM
Check the article below. In gs.eventqueue method, in the parameters you can pass the recipient as one of the parameters. So this should solve your issue.
It'll be like, gs.eventQueue('eventname',current,holderName);
You are already getting the holderName from the previous script that I had shared. So you should be good to go.
Please mark as helpful if it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 06:11 AM - edited 11-16-2023 06:17 AM
Here i have taken example of incident table.
It has Configuration item Reference field. then the table contains a Owned by field, which refers to sys_user table where the Mail field is present.
Check the below script to find mail .
var grCmdbInc = new GlideRecord('incident');
grCmdbInc.addEncodedQuery('cmdb_ciISNOTEMPTY^active=true^sys_id='+recordsysId);
grCmdbInc.query();
while (grCmdbInc.next()){
if(grCmdbInc.cmdb_ci.owned_by&&grCmdbInc.cmdb_ci.owned_by.email){
gs.info(grCmdbInc.cmdb_ci.owned_by.email);
}
}
Make the changes as per your requirement and you should be able to get the data.
Just to point out, in your script, in while loop, you have written gr.next(), instead of grCmdb.next()
Please mark as correct if it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 07:16 AM
Hi @Dibyaratnam !
I intend to use this script within the Schedule Report (PRINT_1), as a notification
must be sent to the Group Holder’s email.
Because of this, I thought about the possibility of doing the GR and accessing the email via dot walk.
Note: I just don't understand "sys_id='+recordsysId", when I use it in the background script (PRINT_2)
it doesn't work, when I remove it it only brings up a specific email several times, even though I include it
grCmdbInc.setLimit(1);
Note: I did the test with INC, to see if it worked, then I will make the necessary changes.
Thank you very much for your feedback and attention, I am very grateful!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 08:32 AM
Check this article https://developer.servicenow.com/dev.do#!/learn/learning-plans/tokyo/servicenow_administrator/app_st...
In condition field, it will evaluate for the condition to send the mail, so this field will only return true/false. nothing else. Is that the same purpose you are using the script?
By recordsysid, i meant sysid of a specific record, for testing purpose.
What exactly you want to achieve from that script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 11:15 AM - edited 11-16-2023 11:21 AM
Hi @Dibyaratnam , how are you?!
I am very grateful for your attention and assistance!!!
I researched and studied a little, and I believe that the most efficient way in this case is
using and creating an "Event", "BR" and "Email Notification", I managed to perform some tests
and I can receive Notifications (by my user) in sys_email, however
the notification must be sent to the "Holder" which is a reference field of the "Business Partner Department"
(Print_7) and (Print_8_1)
get the holder field (u_holder) so that it receives the notification, that's why I thought about dot walk.
I created an event (print_9) and included the "Business Partner Department" (print_10) in the Group, however this notification DOES NOT have to be sent to all members, but ONLY to the "Holder"
Could you tell me if there is a way to do this within the Business Rules TAB Advanced?