Pass an array of multiple email addresses to a field in another model

  • 1
  • Question
  • Updated 8 months ago
  • Answered
I have been challenged with incorporating Outlook into our Salesforce using Skuid.  I was able to connect our Microsoft server and have succeeded in creating new single emails using the Outlook Draft object, pretty cool.   

I am now stuck on allowing the user to select multiple Contacts (mass email).  I currently have the Outlook Contacts as a table to select the records to grab the email addresses and am using a snippet from another post to create a semi-colon seperated array.  This works great, but I need to pass the email addresses to the Recipients field in a model called NewDraft that is opened via PopUp that is used to create the new email.  So I need to replace the yellow highlighted code below with this functionality.

Any direction on this would be greatly appreciated

Thanks!
Ann

Photo of Ann Kukich

Ann Kukich

  • 1,316 Points 1k badge 2x thumb

Posted 8 months ago

  • 1
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
I'm not 100% sure this will work, but its worth a try. 

1. Your snippet should take the resulting array and update a field in a UI Only model with that value  (Look for the documentation on updateRow here )

2.  Use the DataSource action for your Outlook data source that sends a message.  The "TO" property will take a semicolon separated list of email addresses.  If your UI Only field has that list you can use merge syntaxt to pass it in. Somthing like this:  {{$Model.UiModelName.data.0.EmailAddressesFieldName}} 




Good luck with this!  
Photo of Ann Kukich

Ann Kukich

  • 1,316 Points 1k badge 2x thumb
I was able to get this working, thank you Rob for your direction!   Here's a brief summary where I landed up to get it working:


  •   Created a UI Model with UI Field.
  •   Created global action that runs the Email Array snippet to populate the UI Model/Field, and     then creates new row in Draft model via PopUp- populating the "ToRecipients" field with the     string in the UI Field.  Subject and Body fields are editable for user input
  •   Added a button to the Draft model PopUp that saves Draft and runs an Outlook 365 Action:  Send Draft

Snippet:  

// Get the Email of the selected items as an Array
var emailArray = skuid.$.map(arguments[0].list.getSelectedItems(),function(item){ 

   return item.row.Email; 

});

// Convert array to String

var emailString = emailArray.join(';');
var $ = skuid.$,
     model = skuid.model.getModel('UIEmAd'),
     row = model.getFirstRow();
     model.updateRow(row, {emadr:emailString});


Run Snippet and Create Rows Action Framework:



Send Button Action Framework:


Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Thanks for documenting your solution back to the community.  Sharing the riches!!!