So before save I intend to get details of an object and use them in an email that is sent from an app to the customer after they have paid for items.
I have an array column in my database that stores strings as objects in the array. Each string object is a bunch of details about a particular item of an order put into one string.
This is how I access the array:
order.get('fullOrderDetails', [0, 1])
This is fine if my array will always have 2 objects but in this case the amount of objects will always vary.
If you look at my code below I have a for loop that loops through objects in the array. I need to some how do this: order.get('fullOrderDetails', [index of objects separated by commas]) dynamically.
Parse.Cloud.beforeSave("Dispatch", function(request, response) {
// email
var order = request.object;
mandrill.initialize("API-KEY");
var arrayLength = order.get('fullOrderDetails').length;
for (var i = 0; i < arrayLength; i++) {
}
mandrill.sendEmail({
message: {
text: "Your order: " + order.get('fullOrderDetails', [0, 1]) + "has been processed and we will notify you when your order has been dispatched!",
subject: "Thank you for your order!",
from_email: "[email protected]",
from_name: "aStore.com!",
to: [
{
email: order.get('email'),
name: order.get('name')
}
]
},
async: true
}, {
success: function(httpResponse) { response.success(); },
error: function(httpResponse) { response.error("Uh oh, something went wrong"); }
});
});
So calling my array objects manually using index numbers is not ideal for me because the amount of objects vary so I need a way to do it dynamically.
How do I do this?
Thanks for your time.