Page 1 of 2

How can I combine multiple text fields so their contents fill the text box of the SendGrid API?

Posted: Thu Jun 18, 2015 12:35 pm
by Preston To

Heres my problem:
I'm trying to combine the Warehouse Manager (from the tutorial) with the SendGrid API, so that the collected information (Scanned article, quantity and username, 3 different fields) get pasted into the text area of the Email. However, when I map all 3 infos to the text area, only the last one goes into the email. I hope I described my problem well enough and thanks in advance.
Image


How can I combine multiple text fields so their contents fill the text box of the SendGrid API?

Posted: Fri Jun 19, 2015 11:21 am
by Alena Prykhodko

Hello,

You can use localStorage and custom JavaScript.
Please look at a similar posts https://getsatisfaction.com/apperyio/...
https://getsatisfaction.com/apperyio/...


How can I combine multiple text fields so their contents fill the text box of the SendGrid API?

Posted: Wed Jun 24, 2015 7:05 am
by Preston To

Thanks, I got it to work halfway now, except that I get "undefined" instead of my Values. I've mapped 2 of my component to localstorage variables and added the following lines to my "text" component:

var fullText = localStorage.articlecode + " " + localStorage.qty + " " + value;
return fullText;

what am I missing here?


How can I combine multiple text fields so their contents fill the text box of the SendGrid API?

Posted: Wed Jun 24, 2015 9:31 am
by Preston To

I got it to work now, for anyone interested: I needed to refer to the storage variable instead of the model item, but weirdly only for one of my fields.
Image


How can I combine multiple text fields so their contents fill the text box of the SendGrid API?

Posted: Wed Jun 24, 2015 9:40 am
by Alena Prykhodko

Great! Thank you for sharing.


How can I combine multiple text fields so their contents fill the text box of the SendGrid API?

Posted: Wed Jul 08, 2015 12:30 pm
by Preston To

Hi, so while my requested function is still working, my app sometimes adds an "\n" to the end of my scanned Barcode when I send out my email. For example, instead of

"Username" "Barcode123" Quantity123

I get

"Username" "Barcode123\n" Quantity123

in my generated email. It also happens very inconsistently. Any ideas how I can resolve this?

  • Preston

How can I combine multiple text fields so their contents fill the text box of the SendGrid API?

Posted: Wed Jul 08, 2015 1:30 pm
by Preston To

After a bit of searching I found out that \n means next line in JS, but I can't happen to find it in any of the codes that I'm using.


How can I combine multiple text fields so their contents fill the text box of the SendGrid API?

Posted: Thu Jul 09, 2015 4:25 am
by Yurii Orishchuk

HI Preston,

So you just need to add some fields to your app UI and then use these fields to make body of your message.

In this case you need:

1 Add needed fields to the APP.

2 Open "Before send" mapping for sendgrid service datasource.

3 Find needed parameter for example body.

4 Click "JS" button on this parameter(to add JS code).

5 Populate it with JS code code like:

pre

//Where "firstNameName" is a goal field name.
var firstName = Apperyio("firstNameName");

//Where "secondNameName" is a goal field name.
var secondName = Apperyio("secondNameName");

var goalStringToReturn = "Hello " + firstName + " " + secondName ;

return goalStringToReturn;

/pre

This is a simple example that describes how you can use all fields that you need and combine them into single string..

Regards.


How can I combine multiple text fields so their contents fill the text box of the SendGrid API?

Posted: Thu Jul 09, 2015 6:25 am
by Preston To

Thanks for the response Yurii,

However, when I try your method the email body turns into this:

[object Object] [object Object] [object Object]

Any solution?


How can I combine multiple text fields so their contents fill the text box of the SendGrid API?

Posted: Thu Jul 09, 2015 8:14 am
by Preston To

I went back to
code
var fullText = localStorage.Username1 + " " + localStorage.Artikel + " " + value;
return fullText;
/code

and figured out the \n only appears if my scanned barcode is longer than one line in the text box of my app. Still trying to figure out to get rid of it though.