Issues regarding calling a custom function in a Netsuite CS script on button click - netsuite

I added a button to my employee form via a UE script to which I bound the 'createDebtor' function, which I made in the CS script which I attached to my UE script.
I am not really familiar with this method yet and run into some errors in my CS script. The following is the start of my CS script:
I added both console and script logging, because the script logging did not work. Note that the alert function works, so the initialization of the code and binding of the function works correctly. I have the following questions regarding my code:
*Why does log.debug not work (I am owner of the script and the script deployment has debug log level and testing status)
*Trying to console.log the 'employee' variable returns a readOnly object with the methods like 'getvalue', but no properties containing data. Is there an easy way to obtain and log all the properties of this object?
*As a followup to the previous question I tried to use the 'getValue' function to obtain data, but this returns 'undefined' for the 'subsidiary' field. (the field ID should be correct, as I got it from the employee form itself). Could someone advice what I am doing wrong here?

Suite Answers 68476, 74121, and 10564 suggest that you try/confirm the following:
In the User Event script, call form.setScript() before form.addButton().
Check the execution log of the User Event script, not the Client Script.
Confirm that the Log Level is set correctly, I assume on the User Event script and the Client Script.

Related

Text in Bash terminal getting overwritten! Using JS, Node.js (npms are: inquirer, console.table, and mysql)

Short 10sec video of what is happening: https://drive.google.com/file/d/1YZccegry36sZIPxTawGjaQ4Sexw5zGpZ/view
I have a CLI app that asks a user for a selection, then returns a response from a mysql database. The CLI app is run in node.js and prompts questions with Inquirer.
However, after returning the table of information, the next prompt overwrites the table data, making it mostly unreadable. It should appear on its own lines beneath the rest of the data, not overlap. The functions that gather and return the data are asynchronous (they must be in order to loop), but I have tried it with just a short list of standard synchronous functions for testing purposes, and the same problem exists. I have tried it with and without console.table, and the prompt still overwrites the response, as a console table or object list.
I have enabled checkwinsize in Bash with
shopt -s checkwinsize
And it still persists.
Is it Bash? Is it a problem with Inquirer?
I was having this issue as well. In my .then method of my prompt I was using switch and case to determine what to console log depending on the users selection. Then at the bottom I had an if statement checking to if they selected 'Finish' if they didn't I called the prompt function again, which I named 'questionUser'.
That's where I was having the issue, calling questionUser again was overriding my console logs.
What I did was I wrapped the questionUser call in a setTimeout like this:
if(data.option !== 'Finish'){
setTimeout(() => {
questionUser();
}, 1000);
}
This worked for me and allowed my console log data to not get deleted.
Hopefully if anyone else is having this issue this helps, I couldn't find an answer to this specific question anywhere.

How do I add button in NetSuite client script and use it as trigger for script function?

I'm trying to add a button to the current record with the Client Script button definition on a script record, but for some reason it's not finding my function. I'm returning my function tryThisand there is a button on the page which I created on the script record with the function tryThis defined in the appropriate field, but the code doesn't run. Here's my script:
define (['N/currentRecord','N/search','N/record'] ,
function(currentRecord,search,record) {
function tryThis(context){
log.debug({
title: 'try this',
details: 'try this'
});
}
function pageInit(context) {
}
return {
pageInit: pageInit,
tryThis: tryThis
};
});
Nothing happens :(
Yes, the script is deployed.
How can I use this button on a client script??
This doesn't exactly answer your question directly, but I hope it may help. I tested this, and there appears to be nothing wrong with the way you've set it up - the only thing that seems to be not working is the log module, which I've come across before in client scripts.
Try running your function using a console.log() or alert() instead (both work for me).
Hopefully someone with more detailed knowledge of the N/log module's design and behavior will chip in, as the documentation seems to indicate that this should work.
At the bottom of your Client Script record in Edit mode you will find where you can easily set the button and function to call.

nightwatch - check for popup window, after each click event

Is there a way in nightwatch to check whether a popup window appears after each click event?
I have a problem that randomly an error message appear and I don't want to write for each click event the same callback function.
I have already tried out the after and afterEach commands in the Global.js but then the commands will only run after the whole test suite.
I also have tried it local within a test file, although it also does not cover all single click events, even though the official website writes "... while beforeEach and afterEach are ran before and after each testcase (test step)"?
Solution I'm looking for:
.waitForElementVisible('selector')
.click('selector')
.click('selector')
Solution I have come up with so far:
.waitForElementVisible('selector')
.click('selector', isPresent)
.click('selector', isPresent)
isPresent as a callback function, which does the checking and close the popup window if it appears.
Is there another way to write a function (with or without after and/or forEach), so that it will be called after each click event or after each command. Thus, I don't have to write the isPresent repetitive code?
You can insert something like this in your page object file:
var popupCommand = {
popupCheck:function(){
return this.waitForElementVisible('selector', 5000)
.click('selector', isPresent)
.click('selector', isPresent)
},
module.exports = {
commands:[popupCommand],
elements:{
firstElement: {selector: 'xpath',locateStrategy: 'xpath'},
secondElement: {selector: 'css'},
}
}
Where 'popupCommand' will be the name of your page object file, for example 'Popup'. And also you will have to insert your isPresent callback function here so you can use it.
I did my best to explain you as much as possible what and how to do that :)
you should yse .switchWindow() method.
Why don't you write your own custom command specific for that case, so that way you will avoid repetitive code?

Why won't my suitescript deploy scripts fire?

I don't know when this started, but I think it happened after I did some refactoring using the IDE with renaming.
Anyway, if I attach the script through the form, they fire. However, my user event, nor client scripts fire though there is a deployment record. That deployment record uses the same script that works IF it is attached via the form custom code area.
What happened?
EDIT:
For Instance:
Trying to add a button to opportunity:
function userEventBeforeLoad(type, form, request){
var list = form.getSubList("item");
list.addButton('custpage_customconfigurebutton', 'Configure', 'clientStartConfigurator()');
}
Upload Script
Add to "Script"
Deploy:
It never fires when I "Create Opportunity"?
NONE of my user event scripts are firing
EDIT 2 (NEW SCREENS as requested
Following lines of code working for me
function userEventBeforeLoad(type, form, request) {
//nlapiLogExecution('error', 'type', type);
var list = form.getSubList("item");
list.addButton('custpage_customconfigurebutton', 'Configure',"alert('Hello World')");
}
I suspect you might have an error in your clientStartConfigurator(). To verify, you can also use the browser console on click of your button to see whether you're successfully returning from your respective function or not.
Hope this will help you.

Netsuite: ReferenceError functionName is not defined

This is probably a stupid one but I have tried all the things I can think of. I am currently getting the below error on my client side script when I try and execute it.
Error: ReferenceError acvt_serialNumber_saveRecord is not defined
On the Script record in Netsuite I have set the saveRecord function as follows:
acvt_serialNumber_saveRecord
The code in the file is:
function acvt_serialNumber_saveRecord(){
/**do stuff */
}
I have reuploaded to code to make sure the right version was in NetSuite. I have added one character to both the script fn name and the fn name on the Script record (as a shot in the dark). I have seen in the Javascript console at runtime that the correct code is in there and I can see the exact function name (I did a ctrl+f for the "undefined" function in the code in the console to make sure spelling was all the same).
NOTHING has worked. I had this code working earlier, but the changes I made were not to this function at all.
Any help is appreciated
Another thing to check is the code that you recently changed. In particular, check for a hanging comma. IE:
var someObj = {
someProp:'somevalue',
};
The comma at the end of 'somevalue' will cause the script to fail, throwing 'undefined' errors.
Have you tried deleting the Script record in NetSuite and re-creating it?
Do you have any library included for that Client Script in netsuite ?
Provide a screen shot of your Netsuite script page
I encounter similar problem like this before, but it was because i called a function which is inside a library file
Thanks

Resources