Dot Walking with script variables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-26-2023 02:00 AM
Hi together I have a script in which I have a current object which is for example an approval and would like to have the dot walking path built dynamically in the script. For this I already have variables that give me the path as a string and so I thought I could just set this path after the current. Unfortunately this does not work, I get an undefined.
Does anyone have an idea how to solve this cleverly?
if (recipients_fields) {
for (var k = 0; k < recipients_fields.length; k++) {
if (show_button) {
//Handle dot walked recipients fields
var user3 = new GlideRecord("sys_user");
if(recipients_fields[k].indexOf(".")!=-1){
var split = recipients_fields[k].split('.');
var dotWalkedPart = split[0].toString();
var field = split[1].toString();
if (user3.get("sys_id", current.dotWalkedPart.getValue(field))) {
if (user3.getValue("locked_out").toString() == "1")
show_button = false;
}
}else{
if (user3.get("sys_id", current.getValue(recipients_fields[k]))) {
if (user3.getValue("locked_out").toString() == "1")
show_button = false;
}
}//End handle dot walked fields
} else
break;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2023 07:24 AM
Hi Florian, did you worked this out?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2023 07:30 AM
I have something like:
var variableName = "name";
var field = "current.variables." + variableName;
field will return a string -> "current.variables.name" , but I want to achieve the sys_id which would return if I just write the dot-walk normally.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2023 07:46 AM
You don't need getValue server side or the field name "sys_id" when using get.
Instead of
if (user3.get("sys_id", current.dotWalkedPart.getValue(field))) {
Try this
if (user3.get(current.field_name)) {//this would be the value of the field...you'll get a sys_id when it's a reference field.
}