Scenario:
I am trying to create a group mailto function for one of my SharePoint pages. The idea is that the user can select the groups they wish to bulk e-mail within our organisation. They click a button and this gathers the e-mails before opening the default e-mail application.
The mailto list (LU_Mailto) has the fields [Title] and [Mailto]. [Mailto] contains a string of e-mail addresses separated by semi colons (;). For example;
"Head of School", "[email protected]; [email protected]"
I have placed the list as a WebPart on a page;
I have created JS code that gets the list items that have been selected when the E-mail Selected button is pressed.
function clickMethod_Mailto() {
var ctx = SP.ClientContext.get_current();
var listId = SP.ListOperation.Selection.getSelectedList(); //selected list Id
var items = SP.ListOperation.Selection.getSelectedItems(ctx); //selected Items Ids
var list = ctx.get_web().get_lists().getById(listId);
var mySeletedItems = '';
var mailto = '';
var titles = '';
var i;
for (i in items)
{
row = list.getItemById(items[i].id);
mySeletedItems += '|' + items[i].id; // this proves the selected IDs are being found
titles = titles + row.get_item('Title'); // this line is not working
// titles = titles + row.get_item('Name'); // this line is not working
// mailto = mailto + row.get_item('Mailto'); // this line is not working
}
alert (mySeletedItems, titles, mailto);
}
If I comment out the "titles = titles + row.get_item('Title');" the function correctly returns a list of the selected item IDs. The [row] variable appears to be picking up an object but I am unable to get any column data from it. I am unsure whether I am referencing the column data correctly.
I have also tried "titles = titles + row.get_item('Name');" since the Title column was re-named. However, I have checked the column name and it is still Title internally and Name is just an alias.
If I can demonstrate that I can pull the Name of selected items in the WebPart then I can move onto the Mailto field. However, I am not sure if it has to be visible in the WebPart to be referenced?
Application: This is using SharePoint 2013
Any help and guidance gratefully appreciated.