Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2023 12:55 AM
How about when you need to go deeper in the dotWalk?
//variables definition
var bioQueryStr = 'sys_updated_onNOTONLast 6 months@javascript:gs.beginningOfLast6Months()@javascript:gs.endOfLast6Months()^u_user.active=true';
var arr = [];
//function call
var userBio1 = fillArr(bioQueryStr, 'u_user', 'u_user.department.sys_id');
//function definition
function fillArr(nameQueryStr, nameGroupByStr, nameRef){
var arr = [];
var bioGR = new GlideAggregate("u_cv_portal_bio");
bioGR.addEncodedQuery(nameQueryStr);
bioGR.groupBy(nameGroupByStr);
bioGR.query();
while (bioGR.next() && bioGR[nameRef].getValue()) {
arr.push(bioGR[nameRef].getValue());
}
return arr;
}
this doesn't work, found a workaround:
//variables definition
var bioQueryStr = 'sys_updated_onNOTONLast 6 months@javascript:gs.beginningOfLast6Months()@javascript:gs.endOfLast6Months()^u_user.active=true';
var arr = [];
//function call
var userBio1 = fillArr(bioQueryStr, 'u_user', 'u_user', 'sys_id');
//function definition
function fillArr(nameQueryStr, nameGroupByStr, nameRef, nameRef2){
var arr = [];
var bioGR = new GlideAggregate("u_cv_portal_bio");
bioGR.addEncodedQuery(nameQueryStr);
bioGR.groupBy(nameGroupByStr);
bioGR.query();
while (bioGR.next() && bioGR[nameRef].getValue()) {
if(nameRef2){
arr.push(bioGR[nameRef][nameRef2].getValue());
}else{
arr.push(bioGR[nameRef].getValue());
}
}
return arr;
}
The question is, can it be done more cleanly, like in the first example? What am I missing?