This topic contains 14 replies, has 0 voices, and was last updated by jmessersmith 8 years, 4 months ago.
-
AuthorPosts
-
July 7, 2016 at 7:59 am #2663
jmessersmithIs there a way to add a total item count to a sublist? I understand how to get the total with suitescripts but don’t see a way to put a div or field at the buttom of the sublist so I can populate it.
Do I have to recreate the entire form in a Suitelet to get this level of customization?
This is a cached copy. Click here to see the original post. -
July 7, 2016 at 1:05 pm #2664
errolDo you need it at the bottom of the sublist? Will a custom integer field on that subtab (above the sublist) work? If so, you can create a custom integer field and populate it with the count either using script or a non-stored field and a search. Depending on your skills, doing the non-stored field (search) may be the easiest option. Though, I do think the script is the best way to accomplish what you are trying to do for many reasons. Finally, if you do NEED it as the bottom of the sublist, you will probably need to “hack” it using jquery. You could do that pretty easily by just adding a row with total to the list, though I probably wouldn’t recommend that. Hope this helps, maybe others will have better ideas for you.
-Errol
-
July 8, 2016 at 7:58 am #2665
jmessersmithDo you have an example of how to “hack” it? I’m not sure how to do this, nothing has an ID assigned.
-
July 8, 2016 at 8:28 am #2666
errolIs this the actual Item sublist on a Transaction you are talking about? Or is is a Sublist from a Saved Search that it put on the form?
-
July 8, 2016 at 8:37 am #2667
jmessersmithIts the item sublist on a transaction.
-
July 8, 2016 at 10:43 am #2668
errolBelow is a quick example (not fully tested). This should at least give you an idea on one way this could be accomplished. I also want to reiterate that this is not a supported customization by NetSuite and would probably need more work to make it fully usable to what you need.
[js]Code:
function beforeLoad(type, form){
//Execute the logic only when editing the record in the browser UI
if (nlapiGetContext().getExecutionContext() == ‘userinterface’) {if (type == ‘edit’ || type == ‘view’) {
form.addField(‘custpage_trans_itemcount_pagescript’, ‘inlinehtml’);
form.getField(‘custpage_trans_itemcount_pagescript’).setDefaultValue(getItemTotalPageLoadScript());
}
}
}function getItemTotalPageLoadScript(){
var itemCount = 0;
var lineCount = nlapiGetLineItemCount(‘item’);
for (var i = 1; i ‘; script_c += ‘ jQuery(document).ready(function() { ‘; script_c += ‘ var colCount = 0;’; script_c += ‘ var rowCols = jQuery(“#item_splits > tbody > tr:nth-child(1) td”);’; script_c += ‘ if (rowCols) {‘; script_c += ‘ rowCols.each(function(){‘; script_c += ‘ if (jQuery(this).attr(“colspan”)) {‘; script_c += ‘ colCount += +jQuery(this).attr(“colspan”);’; script_c += ‘ }’; script_c += ‘ else {‘; script_c += ‘ colCount++;’; script_c += ‘ }’; script_c += ‘ }); ‘; script_c += ‘ jQuery(“#item_splits > tbody:last-child”).append(‘‘ + itemCount + ‘ Items ‘);’; script_c += ‘ }’; script_c += ‘ }); ‘; script_c += ‘‘;
return script_c;
}[/js]July 8, 2016 at 2:01 pm #2669
jmessersmithI couldnt get your code to work but i like the concept. I ran into a snag. I’m just adding a div to the bottom of the page, but when I do that it messes up the adding more items to the form, it just says loading and doesnt give you a new line to select an item. Any idea why that would happen? I’m using page Int function.
Code:
var divCSS = “background:#d3d3d3;color: #000;opacity: 0.7;height: 100px;z-index: 1000”;
document.body.innerHTML += “Something in footer“;
July 8, 2016 at 2:29 pm #2670
jmessersmithI found a solution, I’ll post my complete code when I’m done.
Code:
var node = document.createElement(“div”); // Create anode
var textnode = document.createTextNode(“Water”); // Create a text node
node.appendChild(textnode);node.setAttribute(“id”, “footer”);
node.style.cssText = “background:#d3d3d3;color: #000;opacity: 0.7;height: 100px;z-index: 1000”;
document.getElementsByTagName(‘body’)[0].appendChild(node);July 11, 2016 at 8:08 am #2671
jmessersmithIs there a way to execute javascript on the view part of a form? I don’t see how its done.
July 11, 2016 at 6:31 pm #2672
michoelOriginally posted by jmessersmith
View Post
Is there a way to execute javascript on the view part of a form? I don’t see how its done.
You would do this by creating a User Event script with a beforeLoad event, and then call form.setScript();
July 12, 2016 at 9:49 am #2673
jmessersmithThanks, I got it working. alert(nlapiGetLineItemCount(‘item’)); returns -1 on the view, is some some other function I should use on the view part?
July 12, 2016 at 11:59 am #2674
errolThat’s one of the reasons I put it server side in the beforeLoad, vs client side using setScript. What about my example didn’t work? I just tested it in my development account and it worked. My suggestion is to build it server-side, then update it client side (only in edit mode would it be necessary as lines are added/removed). But you could use a normal validateLine client script to do that.
July 12, 2016 at 7:09 pm #2675
michoelOriginally posted by jmessersmith
View Post
Thanks, I got it working. alert(nlapiGetLineItemCount(‘item’)); returns -1 on the view, is some some other function I should use on the view part?
In view mode you would have to load the record first:
Code:
var record = nlapiLoadRecord(nlapiGetRecordType(), nlapiGetRecordId());
alert(record.getLineItemCount(‘item’));July 14, 2016 at 7:47 am #2676
jmessersmithNevermind, I need to use getLineItemValue.
July 15, 2016 at 8:52 am #2677
jmessersmithI got it working. Here is the code:
Put pageInit in User Event Script on the Purchase Order BeforeLoad function
Code:
function pageInit(type){
form.setScript(‘customscriptclient_po_item_summary’);
}Add this script to the Client scripts for the Purchase Order, pageInit on Page Init and getItemTotalPageLoadScript on Line Init function.
The script is still a little messy but should work.
Code:
var node = document.createElement(‘div’); // Create anodenode.setAttribute(‘id’, ‘footer’);
node.style.cssText = ‘position: fixed; bottom: 0px; color: rgb(0, 0, 0); height: 100px; z-index: 1000;width: 50%;margin: 0 auto; ‘;
document.getElementsByTagName(‘body’)[0].appendChild(node);var nodePad = document.createElement(‘div’); // Create a
nodenodePad.setAttribute(‘id’, ‘footerpad’);
nodePad.style.cssText = ‘color: #000;opacity: 0.7;height: 100px;z-index: 1000’;
document.getElementsByTagName(‘body’)[0].appendChild(nodePad);//var divCSS = ‘background:#d3d3d3;color: #000;opacity: 0.7;height: 100px;z-index: 1000’;
//document.body.innerHTML += ‘Something in footer‘;
document.addEventListener(‘DOMContentLoaded’, function (event) {
var element = document.getElementById(‘container’);
var height = element.offsetHeight;
if (height ‘;
document.getElementById(‘footer’).innerHTML += “Line Count ” + correctedLineCount + “ “;
document.getElementById(‘footer’).innerHTML += “Total Qty ” + totalQty + “ “;
document.getElementById(‘footer’).innerHTML += “Total Billed ” + totalBilled + “ “;
document.getElementById(‘footer’).innerHTML += “Total Recieved ” + totalRec + “ “;
document.getElementById(‘footer’).innerHTML += “Total $” + dollarTotal + “ “;
//document.getElementById(‘footer’).innerHTML += ‘Total Qty ‘ + totalQty + ‘ ‘;
//document.getElementById(‘footer’).innerHTML += ‘Total Billed ‘ + totalBilled + ‘ ‘;
//document.getElementById(‘footer’).innerHTML += ‘Total Recieved ‘ + totalRec + ‘ ‘;
document.getElementById(‘footer’).innerHTML += ‘‘;}
function getItemTotalPageLoadScriptView(){
var record = nlapiLoadRecord(nlapiGetRecordType(), nlapiGetRecordId());
var totalQty = 0;
var totalBilled = 0;
var totalRec = 0;
var dollarTotal = 0;
var lineCount = record.getLineItemCount(‘item’);
var correctedLineCount = 0;for (var i = 1; i ‘;
document.getElementById(‘footer’).innerHTML += “Line Count ” + correctedLineCount + “ “;
document.getElementById(‘footer’).innerHTML += “Total Qty ” + totalQty + “ “;
document.getElementById(‘footer’).innerHTML += “Total Billed ” + totalBilled + “ “;
document.getElementById(‘footer’).innerHTML += “Total Recieved ” + totalRec + “ “;
document.getElementById(‘footer’).innerHTML += “Total $” + dollarTotal + “ “;
//document.getElementById(‘footer’).innerHTML += ‘Total Qty ‘ + totalQty + ‘ ‘;
//document.getElementById(‘footer’).innerHTML += ‘Total Billed ‘ + totalBilled + ‘ ‘;
//document.getElementById(‘footer’).innerHTML += ‘Total Recieved ‘ + totalRec + ‘ ‘;
document.getElementById(‘footer’).innerHTML += ‘‘;}
function pageInit(){
var node = document.createElement(‘div’); // Create anodenode.setAttribute(‘id’, ‘footer’);
node.style.cssText = ‘position: fixed; bottom: 0px; color: rgb(0, 0, 0); height: 100px; z-index: 1000;width: 50%;margin: 0 auto; ‘;
document.getElementsByTagName(‘body’)[0].appendChild(node);var nodePad = document.createElement(‘div’); // Create a
nodenodePad.setAttribute(‘id’, ‘footerpad’);
nodePad.style.cssText = ‘color: #000;opacity: 0.7;height: 100px;z-index: 1000’;
document.getElementsByTagName(‘body’)[0].appendChild(nodePad);//var divCSS = ‘background:#d3d3d3;color: #000;opacity: 0.7;height: 100px;z-index: 1000’;
//document.body.innerHTML += ‘Something in footer‘;
document.addEventListener(‘DOMContentLoaded’, function (event) {
var element = document.getElementById(‘container’);
var height = element.offsetHeight;
if (heightAuthorPostsYou must be logged in to reply to this topic.