GetFirstValueForQuery and multivalue people picker fields
AnsweredHello Matthias
I found your answer in this thread
https://my.skybow.com/hc/en-us/community/posts/360007691060--Web-GetValuesForQuery
At the end you mention how GetFirstValueForQuery works on single user fields.
i have to deal with the Multivalue People Picker.
My current code
var approvers = "";
var approversObjs = [[@Functions.GetValuesForQuery('Lists/ConfigurationEntities', '<View Scope="Recursive"><Query><Where><In><FieldRef Name="Title" /><Values MultipleValuesDelimiter="," ProviderType="FormInput"><Value Type="Text">[[EHEntities]]</Value></Values></In></Where></Query></View>', 'EHSMBXAddress')]]
approversObjs.forEach(function (approver) {
if (approver.get_email() != "") {
approvers += approver.get_email() + ";";
}
});
return approvers;
This works perfect for single value people picker settings but not on multivalue fields.
Any idea on how to work with that?
Best wishes
Dieter
0
-
Hi DieterJauslin,
since a multi people picker field returns as array, you would have to add another forEach loop on it and make sure to skip null values if no person is set:
var approvers = "";
var approversObjs = [[@Functions.GetValuesForQuery('Lists/ConfigurationEntities', '<View Scope="Recursive"><Query><Where><In><FieldRef Name="Title" /><Values MultipleValuesDelimiter="," ProviderType="FormInput"><Value Type="Text">[[EHEntities]]</Value></Values></In></Where></Query></View>', 'EHSMBXAddress')]]
approversObjs.forEach(function (approver) {
if(approver!=null) {
approver.forEach(function (singleApprover) {
if (singleApprover.get_email() != "") {
approvers += singleApprover.get_email() + ";";
}
});
}
});
return approvers;Kind regards
Matthias
1
Please sign in to leave a comment.
Comments
1 comment