I'm trying to use the nlapiGetLineItemCount('purchaseorder');command to get the number of lines of a Purchase Order. But it just return '-1' .
Is there something wrong with my code?
Thank you!
EDIT: I've also tried nlapiGetLineItemCount('item'); and it's have the same behavior if there is something inexistent. Like this: nlapiGetLineItemCount('trying_lines');
EDIT 2 : I'm trying to use it directly on CONSOLE.
If you tried in browser console you should be in "Edit Mode" (hit the record edit button or add &e=T to record url).
nlapiGetLineItemCount('item');
ClientScript 2.0
require(['N/currentRecord'], function (currentRecord) {
console.log('getLineCount', currentRecord.get().getLineCount({sublistId: 'item'})
});
UserEvent 2.0 (in before load function)
function beforeLoad(context){
log.debug('getLineCount', context.newRecord.getLineCount({sublistId: 'item'}))
}
Use nlapiGetLineItemCount('item'); to get the number of line items in a purchase order.
This call will only work in the context of: User Event, Client, or Workflow Action scripts. What script type are you trying to run it in?
In order to run this in the console and get a sensible result you'd have to be in the console opened on Purchase Order edit window.
Related
I want to test if my jQuery code is sound. So I thought I just enter the code in the browser console. I use Mozilla Firefox.
I want to test if I can select ids and that stuff.
But when I enter:
$("#testId")
I get the following error:
Uncaught SyntaxError: private names aren't valid in this context
Are the elements that I want to access private? What does that mean and why is that?
follow these steps to test & practice JQuery in your console:
first, use the browser debugger tool to inspect any element in your browser, view the source code, e.g like classNames and id'
Next, now use the jQuery syntax to select it example $(".className") or $("#ids"),
just type
console.log($("#testId"));
Try something like this
<div id="testId">hi user1664377</div>
then
console.log($("#testId").text()); // you will see "hi user1664377" in console
In case you dont have access to jQuery in console (window/document).
You can add the jQuery script to DOM directly from console by creating and appending the script to body:
let s = document.createElement('script')
s.setAttribute('src','https://code.jquery.com/jquery-3.6.0.min.js')
document.getElementsByTagName('body')[0].appendChild(s)
And now eg get the jQuery version:
console.log(jQuery.fn.jquery)
I want to display a message on a google sheet. But I don't get it, and, after research here, in documentation, I don't get the answer.
I think that the problem is in "activate" the spreadsheet, where i need to display.
var SEGUIMIENTO = SpreadsheetApp.openById("MyTestediD");
var INF = SEGUIMIENTO.getSheetByName("NameOfSheet");
function TestMessage() {
INF.activate();
Browser.msgBox("Hello")
}
When i run.. nothing happen
I need the definition of Spreadsheet outside the function because I'm working in 2 Spreadsheet's by ID in more that one function.
i only need the correction in my code for display a simple message in the spreadsheet.
PD. i really cant find a simple example of that,
Update
This code it's part of a macro recorder of a Spreadsheet, the same "SpreadsheetApp.openById("MyTestediD");"
I don't know why you try to 'activate' a sheet. If you want display a message I assume you want to do it in the user's current sheet, so:
SpreadsheetApp.getUi().alert('Confirmation received.');
From https://developers.google.com/apps-script/reference/base/browser
The methods in this class are only available for use in the context of a Google Spreadsheet. Please use G Suite dialogs instead.
As you can see, Google is nicely asking you to use G Suite dialogs instead of Class Browser, so be nice too and follow their request.
When you say you want a message in a spreeadsheet, do you mean an alert message? If so, the answer is to use the code SpreadsheetApp.getUi().alert('Hello.'); when the TestMessage function is executed
var SEGUIMIENTO = SpreadsheetApp.openById("My TestediD");
var INF = SEGUIMIENTO.getSheetByName("NameOfSheet");
function TestMessage() {
INF.activate();
SpreadsheetApp.getUi().alert('Hello.');
}
Let's say I've just open a random Stackoverflow page, then I open Console in Firefox and run something like this:
alert(document.getElementsByClassName("question-hyperlink")["0"]["firstChild"].textContent)
As a result, it will pop up me the question asked on that page (on this particular page it would be Vimperator and Javascript: getting value of an object).
Now, I want to use that value in a script with Vimperator. I add something like this to my .vimperatorrc
:js << EOF
function dummyFu() {
var myElement = document.getElementsByClassName("question-hyperlink");
alert(myElement["0"].firstChild.textContent);
}
EOF
map <F5> :js dummyFu()<CR>
However, when run, it says TypeError: myElement[0] is undefined.
So, what is wrong? Would be grateful for any suggestion, thanks.
See https://developer.mozilla.org/en-US/docs/Web/API/Window/content
E.g., content.document.getElementsByClassName("question-hyperlink")[0].firstChild.textContent;
(No, it's not me, but all the credits go to GitHub user dkearns, actually. Thanks them a lot. :)
friendID = 1234;
$route.when(
"/friends/:friendID/raw",
{
event: "friends.view"
}
);
When I run the above the URL in Chrome Dev Tools shows that the url tried is http://domain.com/friends/raw?0=1&1=2&2=3&3=4
is there a way to actually get it to run as http://domain.com/friends/1234/raw
It's difficult to tell what's going on here with only this snippet. Can you post the values of your JSON object? At first glance, it appears that your object it's passing multiple values. You might try setting its value to 1234 and see if it passes correctly.
I am pulling my hairs.
I have ZK grid then within the grid there's another grid.
Both are bound to separate view models.
Think about it as a social network wall.
Outer Grid is a ViewModel that render posts.
Then for each post an inner grid is used which is bound to another ViewModel to render comments.
Okay, the issue is "Failed to process setAttr Cannot call method 'set' of null (TypeError)"
HOW TO DEBUG THIS ERROR. No server side error at all. By the way code works fine but every now and then I start get this error.
I am using ZK 6.5.1.1 the latest version.
Note: I know without code it would harder to analyse the problem. But it's not too simple for me to post a portion of working or useful code snippet. So I would appreciate if someone knows how to debug this dreaded message. Also I see other type of similar messages: Failed to mount: cannot call replaceWidget of null etc etc.
Thanks
Regarding to debug this kind of issue, you can try something like below:
.1. Open the debug mode (see ref)
zk.xml
<zk>
<client-config>
<debug-js>true</debug-js>
</client-config>
<library-property>
<name>org.zkoss.web.classWebResource.cache</name>
<value>false</value>
</library-property>
</zk>
.2. Try reproduce this issue, here I create a sample to reproduce a similar issue by unbind a component manually as below (click 'test' button to see the similar error)
test.zul
<zk>
<textbox id="tbx" />
<button label="test">
<attribute name="onClick"><![CDATA[
String uuid = tbx.getUuid();
Clients.evalJavaScript("zk.Widget.$('$tbx').unbind();");
tbx.setValue("abc");
]]></attribute>
</button>
</zk>
.3. See the error message in chrome's developer tooles then click the source link:
.4. Left click on the first line under setAttr to add a breakpoint.
.5. Refersh page and click the 'test' button again, we can see the 'wgt' is null at right side, wgt usually denotes a widget (the Component at client side).
.6. Now what we know is a widget becomes null and then ZK executing setAttr command of it, to debug this, we can simply log every uuid and className while bind_ is called (bind_ is a function of widget's life cycle, basically instanciate all dom elements of a widget) by Client Side Programming, and log all widget again while button clicked.
e.g.,
test.zul (updated)
<zk>
<script><![CDATA[
var allUuids = [];
zk.afterLoad("zul", function () {
var _wgt = {};
// override zk.Widget,
// basically zk.Widget is the
// root of all widget classes
zk.override(zk.Widget.prototype, _wgt, {
bind_: function (a, b, c) {
// call original function
_wgt.bind_.apply(this, arguments);
// each widget has a uuid and className
allUuids.push({uuid: this.uuid, ele: this.className});
}
});
});
function showAllUuids () {
var info,
wgt;
for (var i = 0; i < allUuids.length; i++) {
info = allUuids[i];
// get widget by uuid
wgt = zk.Widget.$('#'+info.uuid);
// show the old className and current status
// you can also try record some more information as needed
// e.g., parent, previousSibling, sclass, etc
zk.log(info.uuid + ' was ' + info.ele + ' now ' + (wgt? wgt.className : wgt));
}
}
]]></script>
<textbox id="tbx" />
<button label="test">
<attribute name="onClick"><![CDATA[
String uuid = tbx.getUuid();
Clients.evalJavaScript("zk.Widget.$('$tbx').unbind();");
tbx.setValue("abc");
Clients.evalJavaScript("showAllUuids();");
]]></attribute>
</button>
</zk>
.7. Now we will get the log message below with the updated zul page after 'test' button clicked and let us know a textbox widget becoms null at client side, you can also check the response value in Network of chromes developer tooles.
Hope this helps
References :
ZK Client Side Programming
Open the debug mode
bind_ in zk.Widget
This particular error seems due to updating a component that is already detached/removed from ZK desktop. In other words, on server side you have a reference to a component that is cached but no longer attached to the component tree. When you try to update it ZK might try to sync its status with its corresponding Widget on client side. However since it was detached, it no longer exists in client side so calling a setAttr on a null widget gives you this error.
Although the best answer possible is already provided I wanted to add I was hitting this error and after debugging it turned out that there was a hflex="min" in a grid component. I changed this to hflex="1" and the error went away. This error started after updating zk version several versions at once so I'm not sure between which versions this change occurred but was a hard to identify. Hopefully simply searching your code base for hflex="min" might save someone some time... I would assume the same to be true for vertical flex.
It come when we are setting something to a already element which is already set previously..
like
OFCchart chart = new OFCchart;
chart.setJSONScript("somedata");
//----- Some other place setting to the same---
chart.setJSONScript("somedata");