Sendgrid - handlebar error msg in dynamic template - sendgrid

I have tried to setup a Sendgrid dynamic template that contains several handlebars, including an Iterator with each
The whole email template html can be found her
The test data looks like this:
{
"total":"1000",
"items":[
{
"text":"Ebook 1",
"qty":"1",
"price":"3"
},
{
"text":"Ebook 2",
"qty":"2",
"price":"3"
},
{
"text":"ebook 3",
"qty":"4",
"price":"3"
}
],
"name":"John Doe",
"address01":"Stargate 292",
"city":"NY",
"state":"NY",
"zip":"4567",
"orderId":"456",
"expiry":"Nov 9 2021",
"customerRef":"123"
}
For some reason I keep getting this error when saving:
Your template has been successfully saved, but we've detected an issue with your handlebars code that requires attention.
I cannot find any other error msg that can tell me exactly why and where in the code this error occur.
I am using an {{#each}} iteration, not 100% sure if this is correctly setup
{{#each items}}
<table>
<tr>
<td>{{this.text}}</td>
</tr>
<tr>
<td>{{this.qty}}</td>
</tr>
<tr>
<td>{{this.price}}</td>
</tr>
</table>
{{/each}}
The other handlebars are just basic ones like {{ name }}, {{ city }} etc.
Do anyone have experience with this kind of error and know how to fix it?

Found the error in this typo:
{{ customerRef} })
had to change it to
{{ customerRef }}
Lesson:
Be aware of the curly brackets when using handlebars
Sendgrid error handling will hopefully be more detailed in the future!

I got the same error-message. After pasting the code into a note file and pasting it back in, the formatting was lost. But with the exact same input the error message disappeared.
Unclear to me, why that worked. But maybe it works for others as well.

Related

Netsuite : HTML/Email Sublist of Transaction not looping correctly

I am looping the transaction.item to get the stockcodes which perfectly works like a charm.
But when I tried to get the links for individual item, it populates all of the td tag, the link should exist ONLY on stockcode 100132 but instead the rest of the items get the links too. Also I did double check the databse if there were any links for the rest of stockcodes. It only exist on stockcode 100132.
This is definitely weird and doesnt make any sense to me. Here's my code for the list
<#list transaction.item as sdsitem>
<tr style="text-align: center">
<td class="th-border stockcode">${sdsitem.item}</td>
<td class="th-border sdslink">
<#if (sdsitem.item.custitemabco_sds_email_link)??>
<a href="${sdsitem.item.custitemabco_sds_email_link}"
target="_blank">Link only exists on stockcode 100132</a>
</#if>
</td>
</tr>
</#list>
Thank you so much for those who will give a time to help me. I'm a beginner at Netsuite, and will really appreciate the answer. God bless!
I think the problem you're seeing can be answered by Suite Answer 98056. When an item is referenced on a transaction (Purchase/Sales/Work/Transfer Order etc), the fields that are found on the item record can not be directly accessed by using a dot to drill through the item.
Instead, you will need to create a new Transaction Item Field that is sourced from the item record, and the field name you're looking at using i.e. custitemabco_sds_email_link.

{{#each pages}} not working in Assemble 0.6.0/Gulp-Assemble

I've got my pages correctly pulling in partials and sources but I can't seem to get something resembling a navigation to work using the {{#each pages}} logic.
I am trying to gather up all my pages and output them as a unordered list.
{{#each pages }}
<li>{{basename }}</li>
{{/each}}
I thought I was following 0.6.0 methodology:
gulp.task('assemble', function () {
assemble.layouts('./templates/layouts/*.hbs');
assemble.option({
layout: 'default'
});
gulp.src('./src/hbs/components/**/*.hbs')
.pipe(gulpAssemble(assemble))
.pipe(prettify())
.pipe(extname())
.pipe(gulp.dest('./dist'));
});
Again, everything else seems to work. I don't understand where the "pages" object that #each is iterating over comes from. I've used {{#log this}} and I can see the the "basename" object but I don't see the "name" object.

Selenium IDE excluding nested spans when asserting text

I want to assert on text but NOT the nested span - is this possible?
I have the following HTML:
<span id="yui_3_15_0_3_1429668403358_1935" class="instancename">
1 Activity 0LP0
<span class="accesshide ">
Assignment
</span>
</span>
I have tried this:
<tr>
<td>assertText</td>
<td>//div/h3[.='Topic ${TopicNumber}']/../ul/li/div/div/div/div/a/span/</td>
<td>1 Activity ${Tracker}</td>
</tr>
This does work though (and is not what I want):
<tr>
<td>assertText</td>
<td>//div/h3[.='Topic ${TopicNumber}']/../ul/li/div/div/div/div/a/span/</td>
<td>1 Activity ${Tracker} Assignment</td>
</tr>
But it does not work. I'd like to NOT include the extra nested span, any ideas without resorting to clever javascript?
Thanks in advance for your assistance ;-)
Unfortunately assertText uses textContent which is going to return that entire string "1 Activity ${Tracker} Assignment".
But you should be able to use a glob to check this "1 Activity ${Tracker} *"

Trouble pinpointing child elements while using Mojo::DOM

I'm trying to extract text from an old vBulletin forum using WWW::Mechanize and Mojo::DOM.
vBulletin doesn't use HTML and CSS for semantic markup, and I'm having trouble using Mojo::DOM->children to get at certain elements.
These vBulletin posts are structured differently depending on their content.
Single message:
<div id="postid_12345">The quick brown fox jumps over the lazy dog.<div>
Single message quoting another user:
<div id="postid_12345">
<div>
<table>
<tr>
<td>
<div>Quote originally posted by Bob</div>
<div>Everyone knows the sky is blue.</div>
</td>
</tr>
</table>
</div>
I disagree with you, Bob. It's obviously green.
</div>
Single message with spoilers:
<div id="postid_12345">
<div class="spoiler">Yoda is Luke's father!</div>
</div>
Single message quoting another user, with spoilers:
<div id="postid_12345">
<div>
<table>
<tr>
<td>
<div>Quote originally posted by Fred</div>
<div class="spoiler">Yoda is Luke's father!</div>
</td>
</tr>
</table>
</div>
<div class="spoiler">No waaaaay!</div>
</div>
Assuming the above HTML and an array packed with the necessary post IDs:
for (#post_ids) {
$mech->get($full_url_of_specific_forum_post);
my $dom = Mojo::DOM->new($mech->content);
my $div_id = 'postid_' . $_;
say $dom->at($div_id)->children('div')->first;
say $dom->at($div_id)->text;
}
Using $dom->at($div_id)->all_text gives me everything in an unbroken line, which makes it difficult to tell what's quoted and what's original in the post.
Using $dom->at($div_id)->text skips all of the child elements, so quoted text and spoilers are not picked up.
I've tried variations of $dom->at($div_id)->children('div')->first, but this gives me everything, including the HTML.
Ideally, I'd like to be able to pick up all the text in each post, with each child element on its own line, e.g.
POSTID12345:
+ Quote originally posted by Bob
+ Everyone knows the sky is blue.
I disagree with you, Bob. It's obviously green.
I'm new to Mojo and rusty with Perl. I wanted to solve this on my own, but after looking over the documentation and fiddling with it for a few hours, my brain is mush and I'm at a loss. I'm just not getting how Mojo::DOM and Mojo::Collections work.
Any help will be greatly appreciated.
Looking at the source of Mojo::DOM, basically the all_text method recursively walks the DOM and extracts all text. Use that source to write your own walking the DOM function. Its recursive function depends on returning a single string, in yours you might have it return an array with whatever context you need.
EDIT:
After some discussion on IRC, the web scraping example has been updated, it might help you guide you. http://mojolicio.us/perldoc/Mojolicious/Guides/Cookbook#Web_scraping
There is a module to flattern HTML tree, HTML::Linear.
The explanation of purpose for flatterning HTML tree is a bit long and boring, so here's a picture showing the output of the xpathify tool, bound with that module:
As you see, HTML tree nodes become single key/value list, where the key is the XPath for that node, and the value is the node's text attribute.
In a few keystrokes, this is how you use HTML::Linear:
#!/usr/bin/env perl
use strict;
use utf8;
use warnings;
use Data::Printer;
use HTML::Linear;
my $hl = HTML::Linear->new;
$hl->parse_file(q(vboard.html));
for my $el ($hl->as_list) {
my $hash = $el->as_hash;
next unless keys %{$hash};
p $hash;
}

Send parsed console output in email

I am working with two Jenkins plugins, Email-Ext and Log Parser. I have the regular expressions for the Log Parser plugin how I want them, and I would like to include the output of the Log Parser plugin in the email that is sent out to users after a build.
The Email-Ext plugin has access to the console output, and I could rewrite my regular expressions for the console output in the email, but since the Log Parser plugin has already done the hard work I was hoping there was some way I could just pull its output into the email.
Does anyone know of any way (like a Jenkins environment variable) this can be done?
A co-worker told me that every build in Jenkins has "actions" associated with it and that Jenkins plugins do their magic via actions. I was able to find all actions of my actions with build.getActions(). I then looped through the actions until I got LogParserAction which is the action supplied by the Jenkins Log Parser plugin.
I then looked through the source code of LogParserAction.class to find the method getErrorLinksFile(). With this method I was able to get the text of the parsed log. A similar method called getWarningLinksFile() is available for the warnings and another is available for info.
I then looped through the text on \n character and applied some regexs to make it look how I wanted. Important parts of the code are below. Looks better if you view it as HTML in Notepad++
%>
<TABLE width="100%">
<TR>
<TD class="bg1" colspan="2">ERRORS</TD>
</TR>
<%
def publisher = null
for(iter in project.getPublishersList()){
if(iter.getDescriptor().getDisplayName().equals("Editable Email Notification")){
publisher = iter
break
}
}
if(publisher != null){
def logParserResult
//Get the LogParserAction from Jenkins
for(action in build.getActions()){
if(action.toString().contains("LogParserAction")){
//Get the LogParserResult from the LogParserAction
logParserResult = action.getResult()
break
}
}
//Get the ErrorLinksFile from the LogParserResult
def errorLinksFile = new File(logParserResult.getErrorLinksFile())
//Rewrite the URL so it directs to something useful
pattern = ~/<a.*?><font.*?>/
def errorList = []
for(line in errorLinksFile.getText().split("\n")){
//All errors have a link, so this makes sure no superfluous text is displayed
if(!line.contains("href")){
continue
}
errorList.add(line.replaceAll(pattern, "<a href="+ rooturl + build.url + "parsed_console/?\">").minus("</font>"))
}
%>
<TR>
<TD class="bg2" colspan="2">Total : ${errorList.count{it}} error(s)</TD>
</TR>
<%
for(error in errorList){
%>
<TR>
<TD class="errors" colspan="2">${error}</TD>
</TR>
<%
}
%>
</TABLE>
If you are able to pull the logs and write into a file.
You can attach that file as an attachment to your email using Email-Ext.