NS Advanced PDF/HTML Template - oracle

I am creating a print out for Invoice using advanced pdf. I'm trying to get a value of a custom field in the "Tax code" record which is related to the field 'Tax code' in the sublist 'Item'.
I tried with ${item.taxcode.customfield}, but in the print out, I have an error
Exception during template merging.com.netledger.templates.TemplateServiceException: Exception during template merging.java.lang.NullPointerExceptionPlease contact your administrator.
Is there another way to manipulate my case and make it work ?
<table class="total" style="width: 100%; margin-top: 10px;" border="2">
<#list record.item as item><#if item_index==0>
<tr>
<th colspan="5" line-height="150%" style="font-weight: bold;background-color: rgb(255, 255, 255);padding: 4x 2px;">Tax Code Message</th>
</tr>
<tr>
<td ><#if item.taxcode?contains("VAT:")><#assign taxcode>${item.taxcode?replace("VAT:","")}</#assign>${taxcode}<br/>${item.taxcode.customfield}</#if></td>
<td ></td>
<td ></td>
</tr>
<tr>
<td ></td>
<td ></td>
<td ></td>
</tr>
</#if></#list>
</table>
Thanks!

//assuming customfield is a replacement of your actual SB/PD field.
I could be wrong, but could it be that you are trying to 'join' more than 2 records? Not sure NetSuite allows that.
See if you could access it with the following:
record.field?has_content
... <#assign...
<#list item as items
<#list items.taxCode as itemTaxCode>
<{itemTaxCode.customfield}>
Or you could do a source of the field on the line-item level of the record, then pull that custcol_* field.

Related

Ruby fastest way to select button in large table

I'm trying to interact with a site that has a large table that looks something like this:
<table id="tblID" cellspacing="1" cellpadding="0" border="0" width="100%">
<tbody><tr valign="top" align="left">
<td colspan="6" height="10"></td>
</tr>
<tr><td bgcolor="#666666" height="1" colspan="6"><img src="img.gif" width="1" height="1" border="0"></td></tr>
<tr class="GridHeader" valign="top" align="left">
<td width="60"><b>Select</b></td>
<td width="210" colspan="2"><b>Account Type</b></td>
<td width="160" colspan="2"><b>Number</b></td>
<td width="200"><b>Account known as</b></td>
</tr>
<tr align="left" valign="middle">
<td class="normal"><input type="radio" id="radButton" name="radButton" value="1233399,1515636"></td>
<td class="normal">ACCTYPE</td>
<td class="normal" width="10"> </td>
<td class="normal">ACCNUMBER</td>
<td class="normal" width="10"> </td>
<td class="normal">ACCNAME</td>
</tr>
<tr align="left" valign="top">
<td height="1" colspan="6" bgcolor="#cccccc"><img src=".img.gif" width="1" height="1" border="0"></td>
</tr>
<tr align="left" valign="middle">
<td class="normal"><input type="radio" id="radButton" name="radButton" value="2263763,2777747"></td>
<td class="normal">ACCTYPE</td>
<td class="normal" width="10"> </td>
<td class="normal">ACCNUMBER</td>
<td class="normal" width="10"> </td>
<td class="normal">ACCNAME</td>
</tr>
This goes on for many hundreds of rows.
My code's aim is to search the rows based on ACCNUMBER, and select the associated radio button. My code does this, but takes a LONG time to do it.
my ruby code so far is this:
require 'watir'
require 'nokogiri'
html = browser.html
doc = Nokogiri::HTML(html)
*csv import and loop stuff*
bkacc = CSV[0]
*nokogiri go fast!*
rows = doc.css("table[id='tblID'] tbody tr")
rows.each do |row|
target = row.text[bkacc]
if !target.nil?
cells = row.css("td[class='normal']")
#pushme = cells[0].css('input')[0]['value']
end
end
*watir goes slow*
browser.table(:id,"tblMaintenance").tbody.trs(:valign,"middle").find do |tr|
temp = tr.td(index: 0).radio(:id => "radButton").attribute_value("value")
if temp == #pushme
tr.td(index: 0).radio(:id => "radButton").set
break
end
end
*other commands and loop to next line in csv*
The finding of the :value of the button I want to push is very fast with nokogiri, but once found, using that :value to look for and set the button with watir is very slow.
My question is; how can I speed this up? I thought perhaps by using mechanize I could but the syntax escapes me. I'm still very new to Ruby so am probably missing some basic knowledge.
Assuming that the combination of the id and value attribute is unique for each radio button, you could locate the radio button directly. The entire Watir loop could be replaced by just:
browser.radio(:id => "radButton", :value => #pushme).set
Alternatively, I would try replacing both loops with the following. Finding the row will be a touch slower than the Nokogiri approach, but the code would be a lot simpler.
row = browser.table(id: 'tblID').tr(text: /#{bkacc}/)
row.radio.set

Form submission verification through Ruby script

I have a file which has a form the following HTML code:
<label for="subject">Subject</label>* : <input name="subject" id="subject" type="text">
<br>
<label for="message">Message</label>* : <textarea type="text" name="message" id="message"></textarea>
<br>
<input name="name" id="name" value="" type="hidden">
<input value="Submit Ticket" onclick="submitTicket()" type="button">
After I submit the form, the respective ticket will be in a table which has the following HTML code:
<table class="list" width="100%">
<tbody><tr class="messagelist">
<th>#</th>
<th>ID</th>
<th>Name</a></th>
<th>Subject</a></th>
<th>Owner</a></th>
<th>Priority</a></th>
</tr>
<tr class="list_row">
<td>1.</td>
<td>14</td>
<td class="name">X</td>
<td class="subject">Test1</td>
<td class="owner">AB</td>
<td class="priority">High</td>
</tr>
<tr class="list_row">
<td>2.</td>
<td>22</td>
<td class="name">Y</td>
<td class="subject">Test2</td>
<td class="owner">CD</td>
<td class="priority">Low</td>
</tr>
<tr class="list_row">
<td>3.</td>
<td>31</td>
<td class="name">Z</td>
<td class="subject">Test3</td>
<td class="owner">EF</td>
<td class="priority">Medium</td>
</tr>
<tr class="list_row">
<td>4.</td>
<td>42</td>
<td class="name">A</td>
<td class="subject">Test4</td>
<td class="owner">GH</td>
<td class="priority">High</td>
</tr>
<tr class="list_row">
<td>5.</td>
<td>34</td>
<td class="name">B</td>
<td class="subject">Test5</td>
<td class="owner">IJ</td>
<td class="priority">Low</td>
</tr>
<tr class="list_row">
<td>6.</td>
<td>43</td>
<td class="name">C</td>
<td class="subject">Test6</td>
<td class="owner">KL</td>
<td class="priority">Medium</td>
</tr>
</tbody></table>
I am writing a RUBY code for the above form and ticket. I want to verify the submitted form and ticket with respect to subject Test1. Based on the subject, I want to click the ID link of Test1.
Could anyone please help how to do this?
Here is what I tried:
require 'watir'
browser.tds(:class, 'list_row').each do |tds_row|
if tds_row.text =~ /Test1/
tds_row.a(:href, 'index.html').click
end
end
You can iterate over the table rows, and element of the iterated row will be a table cell. Then, you can examine the text of that cell. If the value of the 4th cell is the one you're looking for (i.e. "Test1"), then click the link in the second cell, and break out of the iteration. Here's a contrived example:
require 'watir'
b = Watir::Browser.new :chrome
b.goto("http://some_url")
b.button(:value => "Submit Ticket").click
b.trs.each do |tr|
if tr[3].text == "Test1"
tr[1].a.click
break
end
end
b.close
It's still clunky and fragile, so it might be better to target the cells based on their class attributes.
Also--in your watir example--it looks like you are trying to locate table cells based on the parent row's class attribute (i.e. browser.tds(:class, 'list_row') instead of browser.tds(:class, 'list_row').
Given that the HTML is well marked-up, iterating through the rows is more complicated than it has to be. It would be easier to find the specific subject cell and then navigate to its parent row.
# Find the cell with the specific subject text
subject = browser.td(class: 'subject', text: 'Test1')
# Get the row
row = subject.parent
# Click the tracking code link
row.link(class: 'trackingcode').click

Umbraco 7.3.1 CurrentPage.Children issue

Consider this code:
#inherits Umbraco.Web.Macros.PartialViewMacroPage
#{
var pages = #CurrentPage.Children;
}
<table style="width:100% !important">
<thead>
<tr>
<td>Subbasin Name</td>
<td style="width: 15% !important">Hydrologic Unit Code (HUC)</td>
<td style="width: 25% !important">TMDL Status</td>
<td style="width: 25% !important">Implementation Plan Status</td>
<td style="width: 15% !important">Five Year Review Status</td>
</tr>
</thead>
<tbody>
#foreach (var page in #pages){
<tr>
<td>#page.pageTitle <br />#page.watershedName</td>
<td>#page.hydrologicUnitCode</td>
<td>#page.tmdlStatus</td>
<td>#page.implementationPlanStatus</td>
<td>#page.fiveYearReviewStatus</td>
</tr>
}
</tbody>
</table>
Problem: The table draws and populates as desired but for one thing...
#page.pageTitle
The URL of each of the child pages isn't right.. each row of the table has the right Title, and the other columns are correct, but the anchor is being formed with the URL of the CurrentPage rather than each Child's .Url. I assume I am doing something wrong, but I cannot see why this isn't working.
Any suggestions?
Thanks!
Found my problem - case sensitivity (duh).
Changing:
#page.pageTitle
to:
#page.pageTitle
fixes the problem.

How to use "selenium-webdriver-xpath" to get the text value from <td>?

Find the below html code:
<table id="supplier_list_data" cellspacing="1" cellpadding="0" class="data">
<tr class="rowLight">
<td class="extraWidthSmall">
Cdata
</td>
<td class="extraWidthSmall">
xyz
</td>
<td class="extraWidthSmall">
ppm
</td>
</tr>
</table>
Now using xpath how to get the value xyz (means always the second "<td>") . Give me an idea please!
Try //tr/td[2]/data().
//tr/td selects all <td/> elements, [2] the second result inside each <tr/> and data() returns their contents.

Finding table values in watij using xpath

I am using watij to automate my UI testing. I have many tables in a webpage. I need to find a table which has a width 95%. It contains many rows. I have to find each row with different text say "running first UI test on local" as below adn need to get the td value "Complete". I am not ble to get the value but I get the watij address. Let me know how I can find this.
<table width=95%>
<tr>
<th align="left">
<span id="lblHeaderComponent" style="font-size:10pt;font-weight:bold;">Component</span>
</th>
<th align="left">
<span id="lblHeaderServer" style="font-size:10pt;font-weight:bold;">Server</span>
</th>
<th align="left">
<span id="lblHeaderStatus" style="font-size:10pt;font-weight:bold;">
</span>
</th>
</tr>
<tr>
<td align="left"
nowrap="nowrap" style="font-size:12px;">running first UI test on local</td>
<td align="left" style="font-size:12px;">Google</td>
<td align="left" style="font-size:12px;">
<a style='color:#336600;'>Complete</a>
</td>
</tr>
<tr>
<td align="left"
style="border-top:1px solid #cfcfcf;border-bottom:1px solid #cfcfcf;"
colspan="3"
style="font-size:12px; color:#ff3300;">
</td>
</tr>
<tr>
<td align="left" nowrap="nowrap" style="font-size:12px;">running second UI test on local</td>
<td align="left" style="font-size:12px;">Google</td>
<td align="left" style="font-size:12px;">
<a style='color:#336600;'>Complete</a>
</td>
</tr>
</table>
You can try an xpath visualizer like this one to assist you in getting the right expression. It lets you see the results visually.
Using XPath on HTML assumes the HTML is XHTML - in other words it must be well-formed XML.

Resources