Using multiple dynamic SharePoint groups in Email

Forums General discussion Using multiple dynamic SharePoint groups in Email

This topic contains 2 replies, has 2 voices, and was last updated by  Kim West 2 weeks, 1 day ago.

  • Author
    Posts
  • #23687

    Kim West
    Participant

    Hi Alex, I read the post Use a User Group in Email and was wondering how to modify this so that I can get multiple groups into an email. I have a field where I am appending a different set of user groups depending on the selection of a multi choice field. I wasn’t sure how to pull those dynamic groups using the getFieldValue into your code below:

    var ugr = spjs.dffs.getUserCollectionFromGroup(“GroupA”);
    var emails = [];
    jQspjs.each(ugr,function(k,uo){
    emails.push(uo.email);
    });
    var useThisInToField = emails.join(“;”);

    I appreciate any help you can provide!

  • #23692

    Alexander Bautz
    Keymaster

    Are you setting the groups in a people picker, or in another field?

    If you get the user group names from a people picker you can query the users from multiple groups like this:

    var emails = [], groups = getFieldValue("NameOfYourPeoplePickerField");
    jQuery.each(groups,function(i,g){
        var ugr = spjs.dffs.getUserCollectionFromGroup(g);
        jQspjs.each(ugr,function(k,uo){
            emails.push(uo.email);
        });
    });
    var useThisInToField = emails.join(";");

    Replace “NameOfYourPeoplePickerField” with your field name.

    Alexander

  • #23696

    Kim West
    Participant

    Thank you Alexander! This worked like a charm 🙂

You must be logged in to reply to this topic.