Redirect by Group in Custom Routing

@Nikita_Kurguzov
I want to find all groups (3-5, maybe with time more) in which title begins with name like adminGroupDAC, adminGroupDAES, and etc. And after i get that groups to set the field PeoplePicker with find groups: fd.field('PeoplePicker').value= //groups with beginig admin (3,5 and more)

and have one error:
image
It like: The specified view is invalid
Probably it is because of returning many groups that can't be show in alert view

Dear @ixxxl,
You can try the following:

pnp.sp.web.siteGroups.get().then(function(data) {
   var groups = [];
   for (var i = 0; i < data.length; i++) {
       if(data[i].Title.indexOf('Admin') >= 0){
         groups.push(data[i].Title);
      }
   }
   fd.field('PersonsFieldName').value = groups;
});

@Nikita_Kurguzov
I put an alert and it find as i need groups
image
But it can set field value PeoplePicker -
image
people picker is set to multiple values and permit groups
image

Dear @ixxxl,
The error tells you that there is no property value of undefined - that's because the field is not found on the form. You need to use Internal Name of your field, instead of PersonsFieldName, cneck it in the editor by selecting the field and checking its Name property:

@Nikita_Kurguzov

Dear @ixxxl,
Don't forget to wrap your code inside an appropriate event, as all code should be:

fd.spRendered(function(){
  pnp.sp.web.siteGroups.get().then(function(data) {
   var groups = [];
   for (var i = 0; i < data.length; i++) {
       if(data[i].Title.indexOf('Admin') >= 0){
         groups.push(data[i].Title);
      }
   }
   fd.field('User2').value = groups;
  });
});
1 Like

@Nikita_Kurguzov
Now it works! Thank you so much!!!

1 Like