Mass Action - Inline javascript on related list for Drawloop mass mail merge?

  • 1
  • Question
  • Updated 5 years ago
  • Answered
Hello!

Outside Skuid I have an OnClick Javascript button on a list view which passes selected records for a mass mail merge using Drawloop.

Does anyone know would I incorporate this into inline javascript to use in Skuid's mass actions on a related list table where the parent is an account and the children are Installation__c?

Thanks for any help!

Here's the code for the button:

{!REQUIRESCRIPT("/soap/ajax/16.0/connection.js")}

var ids = {!GETRECORDIDS($ObjectType.Installation__c)};
if (!ids || ids.length < 1)
alert("Please select at least one record.");
else
{
var url = "/apex/loop__masslooplus?contactfield=Primary_Contact__c&sessionId={!$Api.Session_ID}&retURL="
+ encodeURI(window.location.pathname+window.location.search);
url += "&recordIds="+ids.join(",");
window.location.href = url;
}
Photo of Louis Skelton

Louis Skelton

  • 4,878 Points 4k badge 2x thumb

Posted 5 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Hi Louis,

Follow this tutorial, How to add Marketo Send Email mass action to a Skuid table, but for the "Snippet Body", use this instead (I've just adapted it to use the Drawloop URL:



// Get the Ids of the selected items as an Array
var idsArray = skuid.$.map(arguments[0].list.getSelectedItems(),function(item){
return item.row.Id;
});
// Convert this array to a comma-separated String
var idsString = idsArray.join(',');

// Redirect to Drawloop
window.top.location = "/apex/loop__masslooplus?contactfield=Primary_Contact__c&sessionId=" + skuid.utils.userInfo.sessionId + "&retURL="
+ encodeURI(window.location.pathname+window.location.search) + "&recordIds="+idsString;


Photo of Peter Bender

Peter Bender, Champion

  • 6,246 Points 5k badge 2x thumb
Zach, I'm trying to get this to work as well, but it seems to fail on the first line of code. My list view is actually from an aggregate model - does that make a difference? I do have the Id of the records in the "groupings" section of the model.
(Edited)
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Yeah that would make a difference --- rows in an Aggregate Model do have an "Id" field, but it's not going to be at all helpful for you. You'll want to change this line:

return item.row.Id;

so that instead of "Id" you are retrieving the grouping/aggregation field that you are interested in, by its Alias Name. e.g. if you are grouping Opportunities by AccountId, the alias name might be something like "accountId", so you'd want to do

return item.row.accountId;


Photo of Peter Bender

Peter Bender, Champion

  • 6,246 Points 5k badge 2x thumb
OK, I've made that change, but still not getting past that first line it seems.
var idsArray = skuid.$.map(arguments[0].list.getSelectedItems(),function(item){ 
   return item.row.classId; 
});
alert('here it is');
The alert doesn't occur.
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Can you check the JavaScript console for an error message coming up before that? Try putting the following at the start of your snippet, and then let us know what comes up:

console.log(arguments[0);
console.log('List');
console.log(arguments[0].list);

Photo of Peter Bender

Peter Bender, Champion

  • 6,246 Points 5k badge 2x thumb
Argh! In fact it seems to have been a spelling error between the snippet I was calling and the actual name of the snippet - sorry for the alarm. Thanks for the help. Now I just have to figure out a way not to display the ugly page that the Drawloop system puts up when I do this. Maybe I need to be using their API instead - damn.

As an aside, it would be nice if the Skuid builder UI checked to see if the snippet you referenced in a component actually existed :) .