Skip to content

Instantly share code, notes, and snippets.

@dmulvi
Created August 26, 2015 18:55
Show Gist options
  • Save dmulvi/b0696fbbb8973871dee3 to your computer and use it in GitHub Desktop.
Save dmulvi/b0696fbbb8973871dee3 to your computer and use it in GitHub Desktop.
Export records SugarCRM
// this is used in coremark custom/modules/Accounts/clients/base/views/nearby-stores/nearby-stores.js
({
exportData: function() {
app.alert.show('massexport_loading', {
level: 'process',
title: app.lang.getAppString('LBL_LOADING')
});
var fields = [
'name',
'billing_address_street',
'billing_address_city',
'billing_address_state',
'billing_address_postalcode',
'billing_address_country',
'iscustomer_c',
'assigned_user_name',
];
var filteredRows = $("#nearbyStores").dataTable()._('tr', {"filter": "applied"});
app.api.call('create', app.api.buildURL('Accounts/exportStores'),
{
'uid' : filteredRows.pluck('id'),
'module': 'Accounts',
'fields': fields
},
{
success: function(data) {
var filename = data.filename;
app.api.fileDownload(
'cache/pdf/' + filename,
{
complete: function(response) {
/*
app.api.call(
'create',
app.api.buildURL('Accounts/deleteStoreFile'),
{ 'filename':filename },
{ success: function(data) {} }
);
*/
},
error: function(errorData) {}
},
{ iframe: this.$el }
);
},
complete: function(data) {
app.alert.dismiss('massexport_loading');
}
});
},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment