How to add child record items to Advanced HTML pdf NetSuite? - netsuite

I have a parent(P) and child(C) record in a Form. When there is more than 1 item in the child section, it does not appear on the html/pdf print out.
enter image description here
This is the javascript used to pull data
define(// jshint ignore:line
["N/record", "N/search", "N/format", "N/task"], function (record, search, format, task) {
function afterSubmit(context) {
if (context.type == context.UserEventType.CREATE) {
var recId = context.newRecord.id;
var rec = record.load({
type: "customrecord_mbce_outbound_trip",
id: recId,
});
var lineCount = rec.getLineCount("recmachcustrecord_otl_outbound_trip");
log.debug({ title: "lineCount", details: lineCount });
var arrData = [];
for (var i = 0; i < lineCount; i++) {
var lpn = rec.getSublistText({
sublistId: "recmachcustrecord_otl_outbound_trip",
fieldId: "custrecord_otl_lpn",
line: i,
});
log.debug({ title: "lpn", details: lpn});
var singleData = {
lpn: lpn,
};
log.debug({ title: "singleData ", details: JSON.stringify(singleData) });
arrData.push(singleData);
}
log.debug({ title: "array", details: JSON.stringify(arrData) });
rec.setValue({
fieldId: "custrecord_child_rec_outbound_trip",
value: JSON.stringify(arrData),
});
rec.save();
}
}
return {
afterSubmit: afterSubmit,
};
});
And the way I call it in advanced html is
<#if record.custrecord_child_rec_outbound_trip?has_content>
<#assign customrecord = record.custrecord_child_rec_outbound_trip?eval>
<table border="0" cellpadding="1" cellspacing="1" style="width: 100%;">
<#list customrecord as customrecord_line>
<#if customrecord_line_index == 0>
<thead>
<tr>
<th>LPN</th>
</tr>
</thead>
<tr>
<td>${customrecord_line.lpn}</td>
</tr>
</#if>
</#list>
</table>
</#if>
The way in look as pdf instead of 8 LPN only 1 coming enter image description here
How can I call all of them in the print out?

Related

Unable bind Array values retrived from Excel import in angular

I am trying excel import functionality using xlsx.
I got the array from the below code
onFileChange(evt:any){
const target : DataTransfer = <DataTransfer> (evt.target);
if(target.files.length !==1) throw new Error('not allowed to upload multiple files');
const Reader : FileReader = new FileReader();
Reader.onload = (e:any) => {
const fileData : string=e.target.result;
const wb : XLSX.WorkBook = XLSX.read(fileData,{type:'binary'});
const wsname : string = wb.SheetNames[0];
const ws : XLSX.WorkSheet = wb.Sheets[wsname];
this.data =(XLSX.utils.sheet_to_json(ws,{header:1}));
console.log(this.data)
let x = this.data.slice(1);
console.log(x)
};
setTimeout(() => {
if (this.data.length > 0) {
this.UploadedFileView(this.data);
}
}, 500);
Reader.readAsBinaryString(target.files[0]);
}
html as below
<input type="file" (change)="onFileChange($event)" multiple="false">
<table>
<tbody>
<tr *ngFor="let row of data">
<td *ngFor="let cell of row">
{{cell}}
</td>
</tr>
</tbody>
</table>
unable to create JSON to save in MongoDB...
if any complete example really helpful

how to select a row a matching a text with protractorjs

we are using protractorjs and node for our test automation. as we have two web application one with customer facing which is ReactJS application which has very reactive elements on those we are using this framework. In the agent facing application we have a page which has normal html table. i was trying to match the text of my choice and double click on it to open a model box. i was able to find the number of rows on the table, but could not go to the exact row of my choice. could any one help me on this with any protractorjs functions.
in this case i need to navigate to 'ETHBTC' and double-click on that to open its details in new pop-up model box.
Page Element
<table class="table">
<thead>
<tr>
<th>Instrument ID</th>
<th>Symbol</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>BTCUSD</td>
<td>Running</td>
<tr>
<td>2</td>
<td>ETHBTC</td>
<td>Running</td>
<tr>
<td>3</td>
<td>ETHGBP</td>
<td>Running</td>
</tr>
</tbody>
</table>
screen picture
code:
after getting row count do not know how to traverse to required row and select that. i know we have to use for loop to traverse, but dono how to match the the expected one.
const service_table = element(by.css('.table'))
let table_rows = service_table.element.all(by.tagName('tbody')).all(by.tagName('tr'))
let rows_count = table_rows.count()
UPDATED
here is my full mrthod for double clicking activity on the table row
async open_exchange_service(data) {
await browser.sleep(1000)
const service_table = await element(by.css('.table'));
const table_row = await service_table.element(by.cssContainingText('tbody tr td', data));
try {
console.log('i am in tryyyyyyyy loooppppp')
await browser.actions().click(table_row).perform().then(() => browser.actions().click(table_row).perform());
// await browser.actions().
// mouseMove(table_row).
// doubleClick().
// perform();
// await browser.actions().
// mouseMove(table_row).
// doubleClick().
// perform();
} catch (error) {
console.log('i am in catchhhhhh looppppp')
const service_table = await element(by.css('.table'));
const table_row = await service_table.element(by.cssContainingText('tbody tr td', data));
await browser.actions().click(table_row).perform().then(() => browser.actions().click(table_row).perform());
// await browser.actions().
// mouseMove(table_row).
// doubleClick().
// perform();
// await browser.actions().
// mouseMove(table_row).
// doubleClick().
// perform();
}
}
async open_exchange_instrument(data) {
await browser.sleep(1000)
const service_table = await element(by.css('.table'));
const table_row = await service_table.element(by.cssContainingText('tbody tr td', data));
try {
console.log('i am in tryyyyyyyy loooppppp')
await browser.actions().click(table_row).perform().then(() => browser.actions().click(table_row).perform());
// await browser.actions().doubleClick(table_row).perform();
// await browser.actions().doubleClick(table_row).perform();
} catch (error) {
console.log('i am in catchhhhhh looppppp')
await browser.sleep(500)
const service_table = await element(by.css('.table'));
const table_row = await service_table.element(by.cssContainingText('tbody tr td', data));
await browser.executeScript('arguments[0].scrollIntoView(true);', table_row);
await browser.actions().click(table_row).perform().then(() => browser.actions().click(table_row).perform());
// await browser.actions().doubleClick(table_row).perform();
// await browser.actions().doubleClick(table_row).perform();
}
}
You can use cssContainingText to identify a specific row by text:
const service_table = $('.table'));
const table_row = service_table.element(by.cssContainingText('tbody tr td', 'ETHBTC'));
browser.actions().doubleClick(table_row).perform();

Use Socket.io to fill google Area Chart - 'google.visualization.DataTable is not a constructor'

I use NodeJS and Socket.io to get data from a database. I now want to fill a google area chart with these data but i kind of fail at doing it.
The data is transmitted as Objects. Each Object contains two values (datetime and value). I append these values to an array and then store them in a DataTable:
google.load('visualization', '1', {
packages: ['corechart']
});
google.setOnLoadCallback(drawChart);
var socket = io();
getData();
function drawChart(dataArray) {
var data = new google.visualization.DataTable();
data.addColumn('string', 'DateTime');
data.addColumn('number', 'Value');
for (var i = 0; i < dataArray.length; i += 2) {
console.log(dataArray[0]);
data.addRow([dataArray[i], dataArray[i + 1]]);
}
var chart = new google.visualization.AreaChart(document.getElementById('chart'));
chart.draw(data, {
title: "Data Visualization",
isStacked: true,
width: '50%',
height: '50%',
vAxis: {
title: 'Data v-Axis'
},
hAxis: {
title: 'Data h-Axis'
}
})
}
function getData() {
socket.emit('GET');
socket.on('serverSent', function (data) {
var processedData = processData(data);
drawChart(processedData);
})
}
function processData(data) {
var arr = new Array();
jQuery.each(data, function (index, object) {
arr.push(object['datetime'], parseInt(object['value']));
})
return arr;
}
If i call my website i see the chart but without any values and the error message `google.visualization.DataTable is not a constructor´. So what am i doing wrong?
The problem is drawChart is being called twice.
From both google.setOnLoadCallback and getData.
If getData is called before google.setOnLoadCallback,
then google.visualization.DataTable will not be recognized.
In addition, it is recommended to use loader.js vs. jsapi.
See Load the Libraries for more info...
As such, please try the following...
Replace...
<script src="https://www.google.com/jsapi"></script>
With...
<script src="https://www.gstatic.com/charts/loader.js"></script>
And try something like...
google.charts.load('current', {
callback: init,
packages: ['corechart']
});
function init() {
var socket = io();
socket.emit('GET');
socket.on('serverSent', function (data) {
var processedData = processData(data);
drawChart(processedData);
});
}
function drawChart(dataArray) {
var data = new google.visualization.DataTable();
data.addColumn('string', 'DateTime');
data.addColumn('number', 'Value');
for (var i = 0; i < dataArray.length; i += 2) {
console.log(dataArray[0]);
data.addRow([dataArray[i], dataArray[i + 1]]);
}
var chart = new google.visualization.AreaChart(document.getElementById('chart'));
chart.draw(data, {
title: "Data Visualization",
isStacked: true,
width: '50%',
height: '50%',
vAxis: {
title: 'Data v-Axis'
},
hAxis: {
title: 'Data h-Axis'
}
})
}

I want to display some query mongoose result data using Angular on an html page

I have a little problem, I want to display some mongoose query result data using Angular on on an html page.
I don't know how to send data to the angular $scope.
app.js:
User.find({ Code: doc.Code}, function (err, data){
var users = [];
var userswithsamecode = '';
data.forEach(function(d){
console.log(d.nom + " " + d.prenom);
users.push(d);
userswithsamecode += "<li>" + d.nom +" "+ d.prenom + '</li><br>';
How can I send this result to the angular $scope,
collegues.html
<html data-ng-app="demo">
<div data-ng-controller="simple">
Name:
<br/>
<input type="text" data-ng-model="name" />
<br/>
<ul>
<li data-ng-repeat="collegue in collegues |filter:name">{{}} </li>
</ul>
</div>
<script src="angular.min.js"></script>
<script>
var demo=angular.module('demo', []);
function simple($scope){
$scope.collegues=
];}
demo.controller('simple', simple);
</script>'
Thanks for your help!
First you need to create a model for mongo. An example
var Example = mongoose.model('ExampleCollection'{
name:String,
description: String
});
//posting to a mongodb
var example = new Example (
app.post("/add-something-to-mongo", function(req, res) {
name: req.body.name,
description: req.body.description
});
listing.save(function(err) {
if(err) {
console.log("Error! ", err);
}else
{
console.log("Saved!"
};
});
});
});
The angular code would look something like this.
var app = this;
var url = "heroku_url or localhost url";
app.save = function(Example) {
// create a new object
var newExample = {
"name": $scope.name
"description": $scope.description
};
$http.post(url + "/routefromserver", newExample).success(function() {
console.log("posting");
})
};
And lastly the HTML
<input id="name" type="text" ng-model="name" />
<input id="city" type="text" ng-model="description"/>
<button ng-click="app.save()">Save Me</button>

Save and Restore rectangles with connections in Draw2D.js touch via JSON

How do I create rectangles with 4 ports (each side) in a correct way, so I can save and restore them via JSON?
I tried this one, but only the rectangles are been saved. The connections and labels got lost.
JSFiddle: http://jsfiddle.net/xfvf4/36/
Create two elements (Add) - move them and connect them
Write: This gives the content as JSON-Array
Read: Should make the grafic out of the JSON-Array
The last point doesn't work.
JS:
var LabelRectangle = draw2d.shape.basic.Rectangle.extend({
NAME: "draw2d.shape.basic.Rectangle",
init: function (attr) {
this._super(attr);
this.label = new draw2d.shape.basic.Label({
text: "Text",
fontColor: "#0d0d0d",
stroke: 0
});
this.add(this.label, new draw2d.layout.locator.CenterLocator(this));
this.label.installEditor(new draw2d.ui.LabelInplaceEditor());
this.createPort("hybrid", new draw2d.layout.locator.BottomLocator(this));
},
getPersistentAttributes: function () {
var memento = this._super();
memento.labels = [];
var ports = [];
ports = this.getPorts();
memento.ports = [];
console.log(ports);
this.children.each(function (i, e) {
console.log(e);
memento.labels.push({
id: e.figure.getId(),
label: e.figure.getText(),
locator: e.locator.NAME
});
ports.each(function (i, e) {
memento.ports.push({
//id: e.id,
name: e.name,
locator: e.locator.NAME
});
});
});
return memento;
},
setPersistentAttributes: function (memento) {
this._super(memento);
this.resetChildren();
$.each(memento.labels, $.proxy(function (i, e) {
var label = new draw2d.shape.basic.Label(e.label);
var locator = eval("new " + e.locator + "()");
locator.setParent(this);
this.add(label, locator);
}, this));
}
});
$(window).load(function () {
var canvas = new draw2d.Canvas("gfx_holder");
$("#add").click(function (e) { // Add a new rectangle
var rect = new LabelRectangle({
width: 200,
height: 40,
radius: 3,
bgColor: '#ffffff',
stroke: 0
});
rect.createPort("hybrid", new draw2d.layout.locator.OutputPortLocator(rect));
rect.createPort("hybrid", new draw2d.layout.locator.InputPortLocator(rect));
rect.createPort("hybrid", new draw2d.layout.locator.TopLocator(rect));
canvas.add(rect, 150, 200);
});
$("#write").click(function (e) { // Write to pre-Element (JSON)
var writer = new draw2d.io.json.Writer();
writer.marshal(canvas, function(json){
$("#json").text(JSON.stringify(json,null,2));
$('#gfx_holder').empty();
});
});
$("#read").click(function (e) { // Read from pre-Element (JSON)
var canvas = new draw2d.Canvas("gfx_holder");
var jsonDocument = $('#json').text();
var reader = new draw2d.io.json.Reader();
reader.unmarshal(canvas, jsonDocument);
});
});
HTML:
<ul class="toolbar">
<li>Add</li>
<li>Write</li>
<li>Read</li>
</ul>
<div id="container" class="boxed">
<div onselectstart="javascript:/*IE8 hack*/return false" id="gfx_holder" style="width:100%; height:100%; ">
</div>
<pre id="json" style="overflow:auto;position:absolute; top:10px; right:10px; width:350; height:500;background:white;border:1px solid gray">
</pre>
</div>
Just use the write.js and Reader.js in the "json"-Folder of Draw2D.js 5.0.4 and this code:
$(window).load(function () {
var canvas = new draw2d.Canvas("gfx_holder");
// unmarshal the JSON document into the canvas
// (load)
var reader = new draw2d.io.json.Reader();
reader.unmarshal(canvas, jsonDocument);
// display the JSON document in the preview DIV
//
displayJSON(canvas);
// add an event listener to the Canvas for change notifications.
// We just dump the current canvas document into the DIV
//
canvas.getCommandStack().addEventListener(function(e){
if(e.isPostChangeEvent()){
displayJSON(canvas);
}
});
});
function displayJSON(canvas){
var writer = new draw2d.io.json.Writer();
writer.marshal(canvas,function(json){
$("#json").text(JSON.stringify(json, null, 2));
});
}
This should work:
var LabelRectangle = draw2d.shape.basic.Rectangle.extend({
NAME: "draw2d.shape.basic.Rectangle",
init: function (attr) {
this._super(attr);
this.label = new draw2d.shape.basic.Label({
text: "Text",
fontColor: "#0d0d0d",
stroke: 0
});
this.add(this.label, new draw2d.layout.locator.CenterLocator(this));
this.label.installEditor(new draw2d.ui.LabelInplaceEditor());
},
getPersistentAttributes: function () {
var memento = this._super();
memento.labels = [];
memento.ports = [];
this.getPorts().each(function(i,port){
memento.ports.push({
name : port.getName(),
port : port.NAME,
locator: port.getLocator().NAME
});
});
this.children.each(function (i, e) {
memento.labels.push({
id: e.figure.getId(),
label: e.figure.getText(),
locator: e.locator.NAME
});
});
return memento;
},
setPersistentAttributes: function (memento) {
this._super(memento);
this.resetChildren();
if(typeof memento.ports !=="undefined"){
this.resetPorts();
$.each(memento.ports, $.proxy(function(i,e){
var port = eval("new "+e.port+"()");
var locator = eval("new "+e.locator+"()");
this.add(port, locator);
port.setName(e.name);
},this));
}
$.each(memento.labels, $.proxy(function (i, e) {
var label = new draw2d.shape.basic.Label(e.label);
var locator = eval("new " + e.locator + "()");
locator.setParent(this);
this.add(label, locator);
}, this));
}
});

Resources