Preston To
Posts: 0
Joined: Thu Jun 18, 2015 12:35 pm

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

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

Preston To
Posts: 0
Joined: Thu Jun 18, 2015 12:35 pm

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

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?

Preston To
Posts: 0
Joined: Thu Jun 18, 2015 12:35 pm

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

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

Preston To
Posts: 0
Joined: Thu Jun 18, 2015 12:35 pm

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

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
Preston To
Posts: 0
Joined: Thu Jun 18, 2015 12:35 pm

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

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.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

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

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.

Preston To
Posts: 0
Joined: Thu Jun 18, 2015 12:35 pm

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

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?

Preston To
Posts: 0
Joined: Thu Jun 18, 2015 12:35 pm

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

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.

Return to “Issues”