sendgrid / sendgrid-nodejs

The Official Twilio SendGrid Led, Community Driven Node.js API Library
https://sendgrid.com
MIT License
3k stars 782 forks source link

How to iterate array of objects in Sendgrid template? #221

Closed ghost closed 6 years ago

ghost commented 8 years ago

Mandrill provides support for Handlebars template and so looping is supported. As I read, Sendgrid doesnot support each like directive. So how do the sendgrid users tackle this shortcoming?

I want to loop through the products, as shown in below object.

products:
[ { name: 'VEEBA SWEET CHILLI SAUCE 1KG',
   qty: 2,
   price: 145,
   packSize: '1 KG',
   itemSubTotal: 290,
   comments: null },
 { name: 'Chilled French Fries',
   qty: 1,
   price: 85,
   packSize: '1 KG',
   itemSubTotal: 85,
   comments: null } ]
thinkingserious commented 8 years ago

Hello @sabapk,

Please open a ticket at https://support.sendgrid.com. Thanks!

adamreisnz commented 7 years ago

is this supported yet by the templating engine?

thinkingserious commented 7 years ago

@adamreisnz,

I'm checking with our product team for an update, thanks!

thinkingserious commented 7 years ago

@adamreisnz,

This is on our radar for implementation, but there is no estimate on timeline yet.

adamreisnz commented 7 years ago

Ok thanks for the update. I guess a work around would be to generate the looped HTML manually and pass that in as a substitution. Crude, but it would work.

eupharis commented 7 years ago

@thinkingserious I am subscribed to this issue. Is there another way I could subscribe for notifications about iterator implementation in sendgrid templates?

thinkingserious commented 7 years ago

Hello @eupharis,

Please make sure the email you have in your SendGrid account settings is up to date. We send product announcements to that email address.

Thanks!

Elmer

free4ride commented 7 years ago

Hi @thinkingserious What is status of this issue? When is it coming live?

thinkingserious commented 7 years ago

Hi @free4ride,

There is still no estimate on timeline yet.

The best option to be notified of any updates on this issue is to make sure the email you have in your SendGrid account settings is up to day.

Thanks!

Elmer

davidhagg commented 7 years ago

As @adamreisnz commented, sending the array in as a HTML might work, however we are experiencing problems with the substitutions being too large, exceeding 10000 bytes

stephengardner commented 7 years ago

Sendgrid, I thought, was a pretty good alternative to Mandrill.

No looping?

That's actually ridiculously surprising from such a large service....

It's impossible to even create a checkout order success form, because you need to loop through the items purchased and display them.

Oh well, another one down.

thinkingserious commented 7 years ago

Hello @stephengardner,

Have you tried using substitutions with our templates? Check this out.

If that does not fit your need, let me know and I'll try to figure out how to help you achieve the results you need.

Thanks!

With Best Regards,

Elmer

adamreisnz commented 7 years ago

Substitutions don't work for listing a table of purchased products for example, because they can only replace one value, and not an array of values, let alone an array of objects with more detailed values.

What we need is support to loop through products and have a template for each product that then gets repeated depending on how many products you supply for the substitution.

The only way around it is kind of half-baked -- you'd have to generate the HTML on the server, and send that whole chunk of HTML as a single substitution. Clearly that is not ideal as you then have part of the layout sitting in server side code instead of nicely in the online template where designers can edit it.

I do agree that this is a major item that's preventing us from using templates as well. As such, we have templates on our server and process them there using handlebars, which does support looping, if statements, etc. We then just send the entire HTML out as mail body, which is a bit of a waste of resources.

thinkingserious commented 7 years ago

Thanks @adamreisnz,

I have reached out to the product team that owns this functionality. I will update this thread when I learn more.

With Best Regards,

Elmer

thinkingserious commented 7 years ago

Hi @stephengardner, @adamreisnz,

Your votes have been added to give this feature higher priority for implementation.

Please make sure the email you have on file for your account is up to date, that is how we would notify you of the implementation of the feature.

With Best Regards,

Elmer

psavard commented 7 years ago

I would like to vote up this feature too. This is a must for you system.

Thanks ;)

free4ride commented 7 years ago

Completely agree. Up-vote from me and my team! Please add this feature asap.

thinkingserious commented 7 years ago

Thanks @free4ride, your vote has been added.

gabzim commented 7 years ago

+1, I was surprised to find this is not implemented yet, I assumed iterating would work. Add my vote please.

eupharis commented 7 years ago

+1! Iterators would be awesome!!

thinkingserious commented 7 years ago

@arg20, @eupharis,

Your votes have been counted, thanks!

MaxShv commented 7 years ago

Any ETA on this? It is ridiculous that this feature hasn't been implemented yet. Right now we are generating the email body on the server and it is getting rejected by sendgrid API because it is over the substitute limit.

etyp commented 7 years ago

@thinkingserious any update on this? We're likely to move off of Sendgrid in the coming week if there's no affirmative movement on it. We can't afford to compromise the quality of our emails because a standard feature like this isn't supported by a large service.

thinkingserious commented 7 years ago

Hi @MaxShv, @etyp,

I have added your votes and passed this additional feedback to our product team.

I don't have any new insights into the progress on this, but once I do find that there is movement, I will update this thread.

With Best Regards,

Elmer

9mm commented 7 years ago

The fact you don't have this is a complete a utter joke.

thinkingserious commented 7 years ago

You vote has been added @9mm, thanks!

futhr commented 7 years ago

Hi @thinkingserious, thanks for a great service, what is the progress of this? You would be so much more awesome if you can add e.g. Handlebars support without forcing your clients to use an external webhook service like Sendwithus.

Thanks

9mm commented 7 years ago

Everyone in this should just use https://www.sendwithus.com

I ended up getting tired of waiting and SWU is amazing, it lets you do everything you could ever want in a template and more. Complete shame that SendGrid doesn't have this super basic stuff by default. Based on this thread I don't think it will ever be added either... why dont you shit in one hand and hold a "vote" from this thread in the other, and see which one weighs more.

SendWithus is slightly expensive though but exceeds my expectations.

thinkingserious commented 7 years ago

Thanks for the suggestion, @9mm, SendWithUs is amazing and a solid partner.

I also have some exciting news for everyone on this thread (well, at least I think it's exciting :)). In just a few short weeks, we're about to get started on how best to implement this feature.

I can't wait! Thanks again for taking the time to voice your concerns to help this issue gain priority, I really appreciate it!

With Best Regards,

Elmer

adamreisnz commented 7 years ago

Great news, I've signed up for a chat.

We definitely need template iteration, but I think it would be even better (and simpler!) if Sendgrid were to support Handlebars templates. Then there's no need to reinvent the wheel!

mbernier commented 7 years ago

I am excited to chat with anyone who has some ideas or opinions on the templates. We need your feedback!!

kardamom commented 7 years ago

I need loops as well - is there a ticket I can track, vote for? I can't see how to find other people's tickets in the support interface.

Many thanks

thinkingserious commented 7 years ago

Hello @kardamom,

Your comment on this thread counts as a vote and any updates will be posted here.

Thanks!

With Best Regards,

Elmer

mbernier commented 7 years ago

@etyp thank you so much for the feedback and information on template logic! If you go here, https://dx.sendgrid.com/swag, you can grab some swag as our thanks for your time.

ameesme commented 7 years ago

Also waiting on this. Implementing Sendgrid in our platform has been troublesome to say the least, with the lack of basic functionalities like this or the excessively complicated structure of the old nodejs-module. It's kind of silly having to chain multiple templating-engines.

Edit: BTW, why is this ticket closed?

mbernier commented 7 years ago

@futhr, @hf2186, @katehlee Please click the following link to get your swag, we really appreciate your feedback about this! https://dx.sendgrid.com/swag

For anyone else who is interested, please feel free to grab a time on my calendar at the link above.

mbernier commented 7 years ago

@ameesme we are collecting feedback about template conditionals right now, so that we are building the right thing.

adamreisnz commented 7 years ago

Great chat this week with @mbernier and @ben-grid about templates and various use cases for iteration and conditionals etc. Hopeful that support for template iteration will be implemented in the near future! 😃

kylemantesso commented 7 years ago

@mbernier unfortunately its a bit hard to book a time with Matt to give feedback, because of the different time zone, but happy to provide more info over email if you have any specific questions...

We really need this feature to continue using SendGrid, which has otherwise been a great product.

dmorrow commented 7 years ago

Here to cast my vote for conditionals and iterating. I've set up a time to chat with @mbernier

gabzim commented 7 years ago

Support for something like handlebars would be amazing.

mbernier commented 7 years ago

@ameesme Thanks again for your feedback! Please grab some swag here: https://dx.sendgrid.com/swag !

mbernier commented 7 years ago

@dmorrow Thanks to you too for the feedback, friend. Check out https://dx.sendgrid.com/swag for some stuff.

mbernier commented 7 years ago

@kylemantesso my email is just my username here at sendgrid.com - hit me up

ameesme commented 7 years ago

Thanks a lot @mbernier. Really cool of you guys! :)

thinkingserious commented 7 years ago

@ameesme,

Could you please send your zip code over to dx@sendgrid.com? Thanks!

kurtisdavis commented 7 years ago

We need to have this loop feature as well. We're using SendGrid for mostly everything,but are still using a different vendor for this functionality. Seems like a fairly simple feature to implement. Please let us know updates on this feature as they come available.

thinkingserious commented 7 years ago

Hello @kurtisdavis,

If you would like to be part of the discussion for the templates functionality, Matt Bernier our Developer Experience Product Manager is digging into customer needs about templates. Please sign up for a time here https://calendly.com/matt-bernier/template-conditionals.

With Best Regards,

Elmer

kamelsalah commented 7 years ago

@thinkingserious What's the status of this feature ? Can you please confirm if it has a due date or anything like that ? We here at Atypon use SendGrid for millions of emails but we can't yet use the templates due to its limitations !! Using vm templates functionalities within your templates would be a great solution to solve all you problems, as the guys mentioned above you don't have to reinvent the wheel ! Thank you.

thinkingserious commented 7 years ago

Hello @kamelsalah,

This feature is currently under development. If you would like to have a voice and learn more, please setup a time to meet with our Developer Experience Product Manager, Matt Bernier: https://calendly.com/matt-bernier/template-conditionals

Thanks!

With Best Regards,

Elmer