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

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; }

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; 

Worked a treat! Thanks so much!

Zach - one further thing - Once the records have been processed I’m trying to get the return url to send the user back to a this page: …salesforce.com/a08?fcf=00Bb0000002kE9m

It’s currently sending them here: …visual.force.com/apex/UI?id=001b000000MhHed

with a “URL no longer exists” page

Any ideas?

This is controlled by the “retURL” query string parameter. Change the bottom part of your snippet to be this:

var retURL = "/a08?fcf=00Bb0000002kE9m"; window.top.location = "/apex/loop__masslooplus?contactfield=Primary_Contact__c" +"&sessionId=" + skuid.utils.userInfo.sessionId + "&retURL=" + encodeURI(retURL) + "&recordIds="+idsString; 

Brilliant! I hadn’t realised that the return URL parameter should be entered into the encodeURI function.

Cheers! I’ve only been using Skuid for a week and now I’m desperately trying to Skuidify ABSOLUTELY EVERYTHING!

Thanks again for the help!

Haha, glad to help. Good luck with Skuidifying everything!

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.

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;


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.

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);

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 :slight_smile: .