This topic contains 3 replies, has 0 voices, and was last updated by Jordan Manningham 7 years, 9 months ago.
-
AuthorPosts
-
January 26, 2017 at 12:30 pm #5594
Jordan ManninghamHi All,
I’ve been working on a project that requires generating a PDF which of course requires some knowledge of HTML and CSS. The part I’m stuck on requires some JavaScript though I’m not sure how to tie both languages together using [js]'
xml += ''xml += '
'
xml += ''
xml += 'Bill of Materials '
xml += ''
xml += ''
xml += 'Item '
xml += 'Description '
xml += 'Quantity '
xml += 'Units '
xml += ''
xml += ''
xml += ''
xml += ''
xml += '';response.renderPDF(xml); //TESTING WITH ITEM 6700-55
}
else{
dumpResponse(request,response);
}}
[/js]
This is a cached copy. Click here to see the original post. -
February 2, 2017 at 9:47 am #5595
david.smithI don’t think you want to try and put your script into the xml for the PDF. A PDF document is not able to modify itself like this. There are quite a few things here I would change but basically you will want your ‘xml’ to be the complete before rendering it. So use your ‘lines’ loop to create the table data as a string and then just insert that into the ‘xml’.
-
February 2, 2017 at 2:26 pm #5596
Jordan Manninghamdavid.smith You’re a genius. That makes so much sense and I’m jealous I didn’t think of it haha. Will make corrections to my code and report back. Thanks!
david.smith replied on 02/02/2017, 02:54 PM: hahaha – shhhhhh, don’t tell anyone those kinda things.
Let me know how it goes.
-
February 17, 2017 at 9:29 am #5597
Jordan Manninghamdavid.smith It worked like a charm!
Code:
//Components – Bill of Materials
var lines = o_r.getLineItemCount(‘member’);
var bom_string;
for (var mem = 1; mem <= lines; mem++){
components[mem – 1][0] = o_r.getLineItemText('member', 'item', mem);
components[mem – 1][1] = o_r.getLineItemValue('member', 'memberdescr', mem);
components[mem – 1][2] = o_r.getLineItemValue('member', 'quantity', mem);
components[mem – 1][3] = o_r.getLineItemValue('member', 'memberunit', mem);
bom_string += '‘ + components[mem – 1][0] + ‘ ‘ + components[mem – 1][1] +
‘‘ +components[mem – 1][2] + ‘ ‘ + components[mem – 1][3] + ‘ ‘;
}while (bom_string.indexOf(‘ & ‘) != -1){
bom_string = bom_string.replace(‘ & ‘, ‘ & ‘);
}while (bom_string.indexOf(‘null’) != -1){
bom_string = bom_string.replace(‘null’, ‘ ‘);
}
david.smith replied on 02/17/2017, 09:37 AM: You could also try nlapiEscapeXML(bom_string).
-
AuthorPosts
You must be logged in to reply to this topic.