Email templates using Metadata

Post Reply
cnicolaisen
Newbie
Posts: 2
Joined: Mon Oct 29, 2012 3:43 pm

Email templates using Metadata

Post by cnicolaisen »

I've been trying for quite some time now to figure out how to send custom email templates from Switch and have come to a stand still. There are many great posts on here but I haven't been able to find a resolution.

I have had success on my html "Fixed file" sending out information such as Job Size and Flow Name but whenever I add in a variable from the Metadata collected during file submission (such as user name or phone number, etc) the entire email comes back with the coding but not the data. Also, ONLY using the collected Metadata does not work.

Example 1: Job Size and Flow name only
Job size: 69369
Flow name: Connector - Starting Point

Example 2: adding the variable phone number to the above
Job size: [Job.ByteCount]
Flow name: [Switch.FlowName]
Phone: [Metadata.Text:Path="/field-list/field[4]/value",Dataset="Submit",Model="XML"]

Extra Info:
Graphics (images) work in either of the above scenarios.
I'm using Dreamweaver as my html editor/creator.
The data paths work perfectly in the "Built-in" html template within Switch

Would anybody have any thoughts/ideas to get me headed in the right direction?

Thanks in advance,
Corey
Corey Nicolaisen
West Canadian Digital Imaging
Calgary, AB
cnicolaisen@westcanadian.com
User avatar
gabrielp
Advanced member
Posts: 577
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: Email templates using Metadata

Post by gabrielp »

If you aren't using a fixed file, are you sure you are using "Define multi-line text with variables" and not "Edit multi-line text"?

If you are using a fixed file, I can't think of why Switch wouldn't put a working variable in there. Any warnings/errors from that Mail Send element?

This doesn't solve your problem, but your solution would be cleaner if you mapped the phone number to private data as private data key "Phone" or something. That way you could access it like this:

Code: Select all

[Job.PrivateData:Key="Phone"]
You can write values to private data easily with a simple script like this: https://github.com/dominickp/SwitchWriteToPrivateData. This is nice because if you ever have to overwrite Phone based on some logic, you can just pass it through another Private Data write and update the variable and use the same email later. It also means if you XML structure changes later, you can simply update your private data mapping in a single configurator and not in all of your emails.

Hope that helps a bit.
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
cnicolaisen
Newbie
Posts: 2
Joined: Mon Oct 29, 2012 3:43 pm

Re: Email templates using Metadata

Post by cnicolaisen »

Thank you for the response, thank you very much!

But oh my, how to feel stupid :oops:

Yes, I was using a fixed file and YES there were error/warning messages which I did not think to look at. Oh my! And YES, looking at the warnings got me in the right direction to solve the issue.

For reference in case anyone else has the same issue, here's the breakdown;

The code I copied into my html editor (Dreamweaver in this case) was;
[Metadata.Text:Path="/field-list/field[4]/value",Dataset="Submit",Model="XML"]

The WARNING I received from Switch was;
Variable 'Metadata.Text' has incorrect syntax in 'Template file': unexpected '&' character after '='; expected characters are ''' or '"'

So, going back into Dreamweaver, I noticed in the code that all my " were changed to " and looked like this;
[Metadata.Text:Path="/field-list/field[4]/value",Dataset="Submit",Model="XML"]

Changing these back to proper quotes solved the issue and I am now in custom email bliss :D

gabrielp - thank you again for the point in the right direction and I'm looking forward to experimenting with the private data mapping.
Corey Nicolaisen
West Canadian Digital Imaging
Calgary, AB
cnicolaisen@westcanadian.com
User avatar
gabrielp
Advanced member
Posts: 577
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: Email templates using Metadata

Post by gabrielp »

cnicolaisen wrote:So, going back into Dreamweaver, I noticed in the code that all my " were changed to " and looked like this;
[Metadata.Text:Path="/field-list/field[4]/value",Dataset="Submit",Model="XML"]

Changing these back to proper quotes solved the issue and I am now in custom email bliss :D
Thanks for posting your solution! ;)
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Post Reply