Pull email recipients from second list

Forums Dynamic Forms for SharePoint Pull email recipients from second list

This topic contains 4 replies, has 2 voices, and was last updated by  Mike 1 week, 3 days ago.

  • Author
    Posts
  • #22720

    Mike
    Participant

    The “E-Mail templates for use with DFFS rules” section will work great if I can pull the email recipients from another list (List B) where they are maintained in two multiple value people-picker fields (TO column and CC column) by an end user. This same user will then submit the email from the List A Display form.

    It looks like this approach from the on screen help would be the way to go:

    You can use a variable by inserting the variable name in this format:
    {var:NameOfVariable}
    You must ensure this variable is available in the page.

    I’ve inspected the spjs-utility posts for help in this area but can’t quite determine if that is the way to go to get my email recipients from List B into two variables (TO and CC fields) on List A. Am I on the right track? Any help is much appreciated.

    Mike

  • #22738

    Alexander Bautz
    Keymaster

    Yes, this should be pretty easy with some custom js, but what is the search criteria used to locate the correct item in list B? – I guess it will be based on a value from your current list item in list A?

    Alexander

  • #22743

    Mike
    Participant

    The items in List B are the same for all items in List A, i.e., every item in List A will always send DFFS-generated emails to the same recipients found in the one row List B.

  • #22749

    Alexander Bautz
    Keymaster

    Look at this sample snippet and see if you can adapt it to fit your needs. Change PeoplePicker1 and PeoplePicker2 with your field names.

    var pp1Var = "";
    var pp2Var = "";
    var listB_item = spjs.utility.getItemByID({
    	"listName":"ListB_DisplayName_or_GUID",
    	"id":Item_ID_in_listB,
    	"viewFields":["PeoplePicker1","PeoplePicker2"]
    });
    // Peoplepicker 1
    if(listB_item.PeoplePicker1 !== null){
    	var arr = [];
    	jQuery.each(listB_item.PeoplePicker1.split(";#"),function(i,v){
    		if(i%2===0){
    			var email = spjs.utility.userInfo(v).EMail;
    			if(email !== null){
    				arr.push(email);
    			}
    		}
    	});
    	pp1Var = arr.join(";");
    }
    // Peoplepicker 2
    if(listB_item.PeoplePicker2 !== null){
    	var arr = [];
    	jQuery.each(listB_item.PeoplePicker2.split(";#"),function(i,v){
    		if(i%2===0){
    			var email = spjs.utility.userInfo(v).EMail;
    			if(email !== null){
    				arr.push(email);
    			}
    		}
    	});
    	pp2Var = arr.join(";");
    }

    Use these variables in your To and Cc.

    Alexander

  • #22768

    Mike
    Participant

    Worked great! Thank you.

You must be logged in to reply to this topic.