Currently, the customer deposit standard print doesn’t provide a direct connection to SO and print item table in Advanced PDF template.
SOLUTION
Create a UE script in customer deposit and create a custom hidden field to store the SO item data and fetch this data in advanced pdf template and print the table
if (context.type == 'print') {
var currentRec = context.newRecord;
var createdFrom = currentRec.getValue({
fieldId: 'salesorder'
});
if (createdFrom) {
var columns = [];
var results = [];
columns[1] = search.createColumn({
name: "itemid",
join: 'item',
label: "Item"
});
columns[2] = search.createColumn({
name: "salesdescription",
join: "item",
label: "Sales Description"
});
columns[0] = search.createColumn({
name: "quantity",
label: "Qty"
});
columns[3] = search.createColumn({
name: "itemid",
join: "item",
label: "Item ID"
});
columns[4] = search.createColumn({
name: "type",
join: "item",
label: "Type"
});
//Creating search to get all the values for work order
var mySearch = search.create({
type: "salesorder",
filters:
[
["type", "anyof", "SalesOrd"],
"AND",
["internalid", "anyof", createdFrom],
"AND",
["mainline", "is", "F"],
"AND",
["shipping", "is", "F"],
"AND",
["cogs", "is", "F"],
"AND",
["taxline", "is", "F"]
],
columns: columns
});
var searchResultCount = mySearch.runPaged().count;
mySearch.run().each(function (result) {
// .run().each has a limit of 4,000 results
results.push(result);
return true;
});
//populate current printout with custom record entries
var customRecords = { columns: columns, results: results };
log.debug("Search Results", customRecords)
var columns = customRecords.columns, results = customRecords.results;
var custrecord = context.form.addField({ id: 'custpage_custrecord_to_print', type: serverWidget.FieldType.LONGTEXT, label: " " })
var custrecordArray = [];
if (results && results instanceof Array) {
for (var i = 0; i < results.length; i++) {
var singleLine = {};
for (var j = 0; j < columns.length; j++) {
var value = results[i].getValue(columns[j]);
log.debug("Value", value)
if (j == 0 || j == 1 || j == 2) {
if (value.indexOf('.') == 0 || value.indexOf(',') == 0 || value.indexOf('-.') == 0 || value.indexOf('-,') == 0) {
value = '0' + value;
}
}
singleLine["col" + j] = (value) ? value : '';
}
custrecordArray.push(singleLine);
log.debug("Array", custrecordArray)
}
custrecord.defaultValue = JSON.stringify(custrecordArray);
}
}
}
And on PDF template,
<#if record.custpage_custrecord_to_print?has_content>
<#assign customrecord = record.custpage_custrecord_to_print?eval />
<table style="width: 100%;" colspan="8" border-color="#8c8a86fa" border="1px" margin-top="0px">
<#list customrecord as item>
<#if item_index==0>
<thead>
<tr>
<th class="headerstyle" colspan="1">Qty</th>
<th class="headerstyle" colspan="2" align="left">Item</th>
<th class="headerstyle" colspan="6" align="left">Description #</th>
</tr>
</thead>
</#if>
<tr>
<td colspan="1" class="extravariable" border-right="1px #8c8a86fa"><span class="headname">${item.col0}</span></td>
<td colspan="2" class="extravariable" border-right="1px #8c8a86fa"><#if item.col1?contains(":")>
<span class="headname">${item.col1?keep_after(": ")}</span></#if><#if item.col1?contains(":")==false><span class="headname">${item.col1}</span></#if>
</td>
<td colspan="6" class="extravariable"><span class="headname">${item.col2}
</span></td>
</tr>
</#list>
</table>
</#if>