extendscript cant align button or center button below listbox - extendscript

My button is floating on top of the list box. I want it to sit right under the list box.
I will be adding more buttons and just want to know why this is not working.
If anybody can assist on this will be grateful.
var objDlg = new Window ("dialog", "パネル", [0,0,300,150]);
//var objDlg = new Window ("dialog", "Abas", [0,0,0,0]);
objDlgorientation = 'column';
// w.margins = 5;
// w.spacing = 10;
objDlg.alignChildren = ['fill', 'fill'];
objDlg.size = [380, 520]
var tpanel = objDlg.add ("tabbedpanel" ,[10,10,0,0],);
var general = tpanel.add ("tab", [0,0,0,0], "Color");
var general1 = tpanel.add ("tab", [0,0,0,0], "general");
var general2 = tpanel.add ("tab", [0,0,0,0], "playstation");
var general3 = tpanel.add ("tab", [0,0,0,0], "xbox 360");
var general4 = tpanel.add ("tab", [0,0,0,0], "xbox 360");
var general5 = tpanel.add ("tab", [0,0,0,0], "xbox 360");
var general6 = tpanel.add ("tab", [0,0,0,0], "xbox 360");
var general7 = tpanel.add ("tab", [0,0,0,0], "xbox 360");
var listBoxxc = general.add("listbox", [10,30,180,110], []);
listBoxxc.selection = 0;
listBoxxc.size = [340, 200];
listBoxxc.add("item", "Create Angle Control");
listBoxxc.add("item", "Create Color Control");
listBoxxc.add("item", "Create Checkbox Control");
listBoxxc.add("item", "Create Layer Control");
listBoxxc.add("item", "Create Point Control");
listBoxxc.add("item", "Create Slider Control");
testBtn = general.add( "button", [40,90,110,110], "Test" );
tpanel.size = [360,300];
objDlg.center();
objDlg.show();

I believe that you will need to group the Listbox and the Button separately. My code is a little different to yours, but this works:
var dialog = new Window("dialog");
dialog.text = "Dialog";
dialog.preferredSize.width = 380;
dialog.preferredSize.height = 520;
dialog.orientation = "column";
dialog.alignChildren = ["fill","top"];
dialog.spacing = 10;
dialog.margins = 16;
// TPANEL
// ======
var tpanel = dialog.add("tabbedpanel", undefined, undefined, {name: "tpanel"});
tpanel.alignChildren = "fill";
tpanel.preferredSize.width = 348;
tpanel.margins = 0;
// CLRTAB
// ======
var clrTab = tpanel.add("tab", undefined, undefined, {name: "clrTab"});
clrTab.text = "Color";
clrTab.orientation = "column";
clrTab.alignChildren = ["fill","top"];
clrTab.spacing = 10;
clrTab.margins = 10;
// CLRTAB_LSTGRP
// =============
var clrTab_LstGrp = clrTab.add("group", undefined, {name: "clrTab_LstGrp"});
clrTab_LstGrp.orientation = "row";
clrTab_LstGrp.alignChildren = ["left","center"];
clrTab_LstGrp.spacing = 10;
clrTab_LstGrp.margins = 0;
var listBoxxc_array = [
"Create Angle Control",
"Create Color Control",
"Create Checkbox Control",
"Create Layer Control",
"Create Point Control",
"Create Slider Control"
];
var listBoxxc = clrTab_LstGrp.add("listbox", undefined, undefined, {name: "listBoxxc", items: listBoxxc_array});
listBoxxc.preferredSize.width = 300;
// CLRTAB_BTNGRP
// =============
var clrTab_BtnGrp = clrTab.add("group", undefined, {name: "clrTab_BtnGrp"});
clrTab_BtnGrp.orientation = "row";
clrTab_BtnGrp.alignChildren = ["left","center"];
clrTab_BtnGrp.spacing = 10;
clrTab_BtnGrp.margins = 0;
var testBtn = clrTab_BtnGrp.add("button", undefined, undefined, {name: "testBtn"});
testBtn.text = "Test";
// GENTAB
// ======
var genTab = tpanel.add("tab", undefined, undefined, {name: "genTab"});
genTab.text = "General";
genTab.orientation = "column";
genTab.alignChildren = ["left","top"];
genTab.spacing = 10;
genTab.margins = 10;
// TPANEL
// ======
tpanel.selection = clrTab;
dialog.show();

Related

Extendscript how do i align my text to be above listbox

i want my text to be above each listbox however it seems not to align well
this is my text code
var t = Main.add("statictext", undefined, "Hello", {multiline:false});
t.text = "Solids with video co pilot";
t.graphics.foregroundColor = t.graphics.newPen (t.graphics.PenType.SOLID_COLOR, [0.0, 1.0, 1.0], 1);
t.graphics.font = ScriptUI.newFont ("Arial", "Bold", 30);
kindly assist me thank you.
var dialog = new Window("dialog");
dialog.text = "Dialog";
dialog.preferredSize.width = 380;
dialog.preferredSize.height = 520;
dialog.orientation = "column";
dialog.alignChildren = ["fill","top"];
dialog.spacing = 10;
dialog.margins = 16;
// TPANEL
// ======
var tpanel = dialog.add("tabbedpanel", undefined, undefined, {name: "tpanel"});
tpanel.alignChildren = "fill";
tpanel.preferredSize.width = 348;
tpanel.margins = 0;
// CLRTAB
// ======
var Main1 = tpanel.add("tab", undefined, undefined, {name: "clrTab"});
Main1.text = "Main1";
Main1.orientation = "column";
Main1.alignChildren = ["fill","top"];
Main1.spacing = 10;
Main1.margins = 30;
var Main = tpanel.add("tab", undefined, undefined, {name: "clrTab"});
Main.text = "Main";
Main.orientation = "column";
Main.alignChildren = ["fill","top"];
Main.spacing = 10;
Main.margins = 10;
// CLRTAB_LSTGRP
// =============
var clrTab_LstGrp = Main.add("group", undefined, {name: "clrTab_LstGrp"});
//clrTab_LstGrp.orientation = "row";
clrTab_LstGrp.alignChildren = ["left","center"];
clrTab_LstGrp.spacing = 10;
clrTab_LstGrp.margins = 0;
var t = clrTab_LstGrp.add("statictext", undefined, "Hello", {multiline:false});
t.text = "Create Solids";
t.graphics.foregroundColor = t.graphics.newPen (t.graphics.PenType.SOLID_COLOR, [0.0, 1.0, 1.0], 1);
t.graphics.font = ScriptUI.newFont ("Arial", "Bold", 30);
var listBoxxc_array = [
"Create 2 solids",
"Create Solid",
"Create Solid with fractual noise",
"Create Solid CC Particle World",
"Create Solid Particular",
"Solid With BCC Sphere",
"Solid With BCC Turbulence",
"Solid With BCC Bulge",
"Solid With BCC Tritone",
"Solid With BCC Fractal Noise",
"Solid With BCC Rays",
"Solid With BCC Rain",
"Solid With BCC Rock",
"Solid With BCC Snow",
"Solid With BCC Particle System",
"Solid With BCC Edge Lighting",
"Solid With BCC Light Zoom",
"Solid With BCC Rays Ring",
"Solid With BCC Rays Ripply",
"Solid With BCC Rays Streaky",
"Solid With BCC Rays Puffy",
"Solid With BCC Rays Wedge",
];
var listBoxxc = clrTab_LstGrp.add("listbox", undefined, undefined, {name: "listBoxxc", items: listBoxxc_array});
listBoxxc.preferredSize.width = 300;
listBoxxc.size = [340, 200];
var t = Main.add("statictext", undefined, "Hello", {multiline:false});
t.text = "Solids with video co pilot";
t.graphics.foregroundColor = t.graphics.newPen (t.graphics.PenType.SOLID_COLOR, [0.0, 1.0, 1.0], 1);
t.graphics.font = ScriptUI.newFont ("Arial", "Bold", 30);
var listBoxxb_array = [
"Create solid with element",
"Create solid with saber",
"Create solid with Vc orb",
"Create solid with Optical Flares",
"Create solid with Twitch",
"Create solid with heat Distortion",
];
var listBoxxb = Main.add("listbox", undefined, undefined, {name: "listBoxxb", items: listBoxxb_array});
listBoxxb.preferredSize.width = 300;
listBoxxb.size = [100, 130];
var listBoxxn_array = [
"Create Angle Control",
"Create Color Control",
"Create Checkbox Control",
"Create Layer Control",
"Create Point Control",
"Create Slider Control"
];
listBoxxb.size = [100, 130];
var listBoxxn = Main.add("listbox", undefined, undefined, {name: "listBoxxn", items: listBoxxn_array});
listBoxxn.preferredSize.width = 300;
// CLRTAB_BTNGRP
// =============
var clrTab_BtnGrp = Main.add("group", undefined, {name: "clrTab_BtnGrp"});
clrTab_BtnGrp.orientation = "row";
clrTab_BtnGrp.alignChildren = ["left","center"];
clrTab_BtnGrp.spacing = 10;
clrTab_BtnGrp.margins = 0;
var testBtn = Main.add("button", undefined, undefined, {name: "testBtn"});
testBtn.text = "Test";
var testBtn1 = Main.add("button", undefined, undefined, {name: "testBtn"});
testBtn1.text = "Test";
var testBtn2 = Main.add("button", undefined, undefined, {name: "testBtn"});
testBtn2.text = "Test";
var testBtn3 = Main.add("button", undefined, undefined, {name: "testBtn"});
testBtn3.text = "Test";
var testBtn4 = Main.add("button", undefined, undefined, {name: "testBtn"});
testBtn4.text = "Test";
var testBtn5 = Main.add("button", undefined, undefined, {name: "testBtn"});
testBtn5.text = "Test";
var testBtn6 = Main.add("button", undefined, undefined, {name: "testBtn"});
testBtn6.text = "Test";
// GENTAB
// ======
var genTab = tpanel.add("tab", undefined, undefined, {name: "genTab"});
genTab.text = "Solids";
genTab.orientation = "column";
genTab.alignChildren = ["left","top"];
genTab.spacing = 10;
genTab.margins = 10;
var clrTab = tpanel.add("tab", undefined, undefined, {name: "clrTab"});
clrTab.text = "Effects Fast";
clrTab.orientation = "column";
clrTab.alignChildren = ["fill","top"];
clrTab.spacing = 10;
clrTab.margins = 10;
var clrTab = tpanel.add("tab", undefined, undefined, {name: "clrTab"});
clrTab.text = "Comp Settings";
clrTab.orientation = "column";
clrTab.alignChildren = ["fill","top"];
clrTab.spacing = 10;
clrTab.margins = 10;
var clrTab = tpanel.add("tab", undefined, undefined, {name: "clrTab"});
clrTab.text = "Comp Settings2";
clrTab.orientation = "column";
clrTab.alignChildren = ["fill","top"];
clrTab.spacing = 10;
clrTab.margins = 10;
var clrTab = tpanel.add("tab", undefined, undefined, {name: "clrTab"});
clrTab.text = "More";
clrTab.orientation = "column";
clrTab.alignChildren = ["fill","top"];
clrTab.spacing = 10;
clrTab.margins = 10;
// TPANEL
// ======
//tpanel.selection = clrTab;
tpanel.selection = Main;
dialog.show();
It appears as though you just need to set orientation of clrTab_LstGrp to be column. Like so:
clrTab_LstGrp.orientation = "column";
I've also noticed that you have a bunch of tabs all with the same variable name, clrTab. You will want to give those separate names before you try to add contents to them. Otherwise, it you will only be able to add to the last one.
Another thing is that you've created a group called clrTab_BtnGrp. But you're still adding your buttons to Main. Did you want to add your buttons to this group? If so you need to do this:
var testBtn = clrTab_BtnGrp.add("button", undefined, undefined, {name: "testBtn"});
[EDIT]
I took a bit of time to clean up your code. A lot of what I've done is just for aesthetics or to align more properly with standard coding conventions. However, there were issues with your code that I would say needed some improvement. Such as reusing variable names, which shouldn't really be done unless the variable is no longer in use. An example of this is where you used the variable name t for each of your static-texts.
I also created groups that I thought made more sense.
var dialog = new Window("dialog");
dialog.text = "Dialog";
dialog.preferredSize.width = 380;
dialog.preferredSize.height = 520;
dialog.orientation = "column";
dialog.alignChildren = ["fill","top"];
dialog.spacing = 10;
dialog.margins = 16;
// TPANEL
// ======
var tpanel = dialog.add("tabbedpanel", undefined, undefined, {name: "tpanel"});
tpanel.alignChildren = "fill";
tpanel.preferredSize.width = 348;
tpanel.margins = 0;
// MAIN1 TAB
// ======
var Main1 = tpanel.add("tab", undefined, undefined, {name: "main_tab_1"});
Main1.text = "Main1";
Main1.orientation = "column";
Main1.alignChildren = ["fill","top"];
Main1.spacing = 10;
Main1.margins = 30;
// MAIN TAB
// ======
var Main = tpanel.add("tab", undefined, undefined, {name: "main_tab"});
Main.text = "Main";
Main.orientation = "column";
Main.alignChildren = ["fill","top"];
Main.spacing = 10;
Main.margins = 10;
// CREATE SOLIDS GROUP
var createSolidsGrp = Main.add("group", undefined, {name: "create_solids_group"});
createSolidsGrp.orientation = "column";
createSolidsGrp.alignChildren = ["fill","center"];
createSolidsGrp.spacing = 10;
createSolidsGrp.margins = 0;
var createSolidsTxt = createSolidsGrp.add("statictext", undefined, undefined, {multiline:false});
createSolidsTxt.text = "Create Solids";
createSolidsTxt.graphics.foregroundColor = createSolidsTxt.graphics.newPen (createSolidsTxt.graphics.PenType.SOLID_COLOR, [0.0, 1.0, 1.0], 1);
createSolidsTxt.graphics.font = ScriptUI.newFont ("Arial", "Bold", 30);
var listBoxxc_array = [
"Create 2 solids",
"Create Solid",
"Create Solid with fractual noise",
"Create Solid CC Particle World",
"Create Solid Particular",
"Solid With BCC Sphere",
"Solid With BCC Turbulence",
"Solid With BCC Bulge",
"Solid With BCC Tritone",
"Solid With BCC Fractal Noise",
"Solid With BCC Rays",
"Solid With BCC Rain",
"Solid With BCC Rock",
"Solid With BCC Snow",
"Solid With BCC Particle System",
"Solid With BCC Edge Lighting",
"Solid With BCC Light Zoom",
"Solid With BCC Rays Ring",
"Solid With BCC Rays Ripply",
"Solid With BCC Rays Streaky",
"Solid With BCC Rays Puffy",
"Solid With BCC Rays Wedge",
];
var listBoxxc = createSolidsGrp.add("listbox", undefined, undefined, {name: "listBoxxc", items: listBoxxc_array});
listBoxxc.size = [340, 200];
// SOLIDS WITH VIDEO COPILOT GROUP
var vidCopGrp = Main.add("group", undefined, {name: "create_solids_group"});
vidCopGrp.orientation = "column";
vidCopGrp.alignChildren = ["fill","center"];
vidCopGrp.spacing = 10;
vidCopGrp.margins = 0;
var vidCopTxt = vidCopGrp.add("statictext", undefined, undefined, {multiline:false});
vidCopTxt.text = "Solids with video co pilot";
vidCopTxt.graphics.foregroundColor = vidCopTxt.graphics.newPen (vidCopTxt.graphics.PenType.SOLID_COLOR, [0.0, 1.0, 1.0], 1);
vidCopTxt.graphics.font = ScriptUI.newFont ("Arial", "Bold", 30);
var listBoxxb_array = [
"Create solid with element",
"Create solid with saber",
"Create solid with Vc orb",
"Create solid with Optical Flares",
"Create solid with Twitch",
"Create solid with heat Distortion",
];
var listBoxxb = vidCopGrp.add("listbox", undefined, undefined, {name: "listBoxxb", items: listBoxxb_array});
listBoxxb.size = [100, 130];
// EXPRESSION CONTROLS GROUP
var expCtrlGrp = Main.add("group", undefined, {name: "create_solids_group"});
expCtrlGrp.orientation = "column";
expCtrlGrp.alignChildren = ["fill","center"];
expCtrlGrp.spacing = 10;
expCtrlGrp.margins = 0;
var expCtrlTxt = expCtrlGrp.add("statictext", undefined, undefined, {multiline:false});
expCtrlTxt.text = "Expression Controls";
expCtrlTxt.graphics.foregroundColor = expCtrlTxt.graphics.newPen (expCtrlTxt.graphics.PenType.SOLID_COLOR, [0.0, 1.0, 1.0], 1);
expCtrlTxt.graphics.font = ScriptUI.newFont ("Arial", "Bold", 30);
var listBoxxn_array = [
"Create Angle Control",
"Create Color Control",
"Create Checkbox Control",
"Create Layer Control",
"Create Point Control",
"Create Slider Control"
];
var listBoxxn = expCtrlGrp.add("listbox", undefined, undefined, {name: "listBoxxn", items: listBoxxn_array});
listBoxxn.size = [100, 130];
// CLRTAB_BTNGRP
// =============
var mainTab_BtnGrp = Main.add("group", undefined, {name: "main_tab_btn_group"});
mainTab_BtnGrp.orientation = "column";
mainTab_BtnGrp.alignChildren = ["fill","center"];
mainTab_BtnGrp.spacing = 10;
mainTab_BtnGrp.margins = 0;
var testBtn = mainTab_BtnGrp.add("button", undefined, undefined, {name: "testBtn"});
testBtn.text = "Test";
var testBtn1 = mainTab_BtnGrp.add("button", undefined, undefined, {name: "testBtn1"});
testBtn1.text = "Test";
var testBtn2 = mainTab_BtnGrp.add("button", undefined, undefined, {name: "testBtn2"});
testBtn2.text = "Test";
var testBtn3 = mainTab_BtnGrp.add("button", undefined, undefined, {name: "testBtn3"});
testBtn3.text = "Test";
var testBtn4 = mainTab_BtnGrp.add("button", undefined, undefined, {name: "testBtn4"});
testBtn4.text = "Test";
var testBtn5 = mainTab_BtnGrp.add("button", undefined, undefined, {name: "testBtn5"});
testBtn5.text = "Test";
var testBtn6 = mainTab_BtnGrp.add("button", undefined, undefined, {name: "testBtn6"});
testBtn6.text = "Test";
// SOLIDS TAB
var genTab = tpanel.add("tab", undefined, undefined, {name: "genTab"});
genTab.text = "Solids";
genTab.orientation = "column";
genTab.alignChildren = ["left","top"];
genTab.spacing = 10;
genTab.margins = 10;
var effFastTab = tpanel.add("tab", undefined, undefined, {name: "effects_fast_tab"});
effFastTab.text = "Effects Fast";
effFastTab.orientation = "column";
effFastTab.alignChildren = ["fill","top"];
effFastTab.spacing = 10;
effFastTab.margins = 10;
var compSet1Tab = tpanel.add("tab", undefined, undefined, {name: "comp_settings_1_tab"});
compSet1Tab.text = "Comp Settings";
compSet1Tab.orientation = "column";
compSet1Tab.alignChildren = ["fill","top"];
compSet1Tab.spacing = 10;
compSet1Tab.margins = 10;
var compSet2Tab = tpanel.add("tab", undefined, undefined, {name: "comp_settings_2_tab"});
compSet2Tab.text = "Comp Settings2";
compSet2Tab.orientation = "column";
compSet2Tab.alignChildren = ["fill","top"];
compSet2Tab.spacing = 10;
compSet2Tab.margins = 10;
var moreTab = tpanel.add("tab", undefined, undefined, {name: "more_tab"});
moreTab.text = "More";
moreTab.orientation = "column";
moreTab.alignChildren = ["fill","top"];
moreTab.spacing = 10;
moreTab.margins = 10;
tpanel.selection = Main;
dialog.show();

Canvas and discord.js text is all "▯"

my code runs first perfectly but now not anymore.
its a welcome card for a discord server.
here's how it should have looked:
https://imgur.com/GEcULY5.png
and here's how it looks now:
https://imgur.com/cHLr2Bi.png
here is the code:
client.on("guildMemberAdd",async member => {
var name = member.displayName
var id = member.id
var membercount = member.guild.memberCount
var displayAvatarURL = member.user.displayAvatarURL({format:"jpg"})
var joinimage = Canvas.createCanvas(2000,1000)
var ctx = joinimage.getContext("2d")
var background = await Canvas.loadImage("./background.png")
ctx.drawImage(background,0,0,2000,1000)
ctx.textAlign = "center"
ctx.font = '120px Arial';
ctx.fillStyle = '#ffffff';
ctx.fillText("welkom",1400,400)
ctx.fillText(name,1400,550)
ctx.font = '60px Arial';
ctx.fillText(("Maak veel plezier in PixelKingdoms!"),1400,750)
const avatar = await Canvas.loadImage(displayAvatarURL)
ctx.beginPath();
ctx.arc(500, 500, 300, 0, 2 * Math.PI);
ctx.clip();
ctx.drawImage(avatar, 200, 200, 600, 600);
ctx.lineWidth = 20;
ctx.strokeStyle = "white";
ctx.stroke();
ctx.closePath()
const attachment = new discord.MessageAttachment(joinimage.toBuffer(), 'welcome-image.png');
member.guild.channels.cache.get("873169519881900033").send("Hey <#"+id+">Welkom in **"+member.guild.name+"**!",attachment)
var fanrole = member.guild.roles.cache.get("873163741276033084")
member.roles.add(fanrole)
})```
(sorry for bad english)

Update Existing Line Item Values in Netsuite SuiteScript 2.0

No matter what I do, I can't update the line item values in an inbound shipment record. I have a ton of debug statements, and I know that I technically am at the correct line, but when I try to get or set values, they are empty.
I am working in dynamic mode, and so in order to loop, I found something online that said I needed to stringify the record. I see all the correct data, but any time I try to manipulate the values, it doesn't do anything, or the values are empty. I also keep getting asked to provide the required fields, but for this particular line, they are already there.
Here is my code:
function doPost(restletBody){
log.debug('Called from POST', restletBody);
var success = [],
errors = [];
restletBody.data.forEach(function(e)
{
try
{
//Inbound Shipment Stuff
var ibsID = e.ibShipments.inboundShipmentRecordID;
var containerNumber = e.ibShipments.containerNumber;
var memo = e.ibShipments.memo;
var cargoReturnDate = e.ibShipments.cargoReturnDate;
var billoflading = e.ibShipments.billoflading;
var quantityexpected = e.ibShipments.quantityexpected;
var destCountry = e.ibShipments.destCountry;
var actualdeliverydate = e.ibShipments.actualdeliverydate;
var expecteddeliverydate = e.ibShipments.expecteddeliverydate;
var poDueDate = e.ibShipments.poDueDate;
var shipmentstatus = e.ibShipments.shipmentstatus;
var factory = e.ibShipments.factory;
var vesselNumber = e.ibShipments.vesselNumber;
var actualshippingdate = e.ibShipments.actualshippingdate;
var expectedshippingdate = e.ibShipments.expectedshippingdate;
var vesselBookingNumber = e.ibShipments.vesselBookingNumber;
var bookingDate = e.ibShipments.bookingDate;
var recID = null;
if((ibsID == "" || ibsID == null) && (containerNumber != "" || memo != "" || cargoReturnDate != "" ||
billoflading != "" || quantityexpected != "" || destCountry != "" || actualdeliverydate != "" ||
expecteddeliverydate != "" || poDueDate != "" || shipmentstatus != "" || factory != "" || vesselNumber != "" ||
actualshippingdate != "" || expectedshippingdate != "" || vesselBookingNumber != "" || bookingDate != ""))
{
//Create a new record
log.debug('Create Record', "");
var rec =
r.create({
type: "inboundshipment",
isDynamic: true,
defaultValues: null
});
//Might need to save the record, then add the fields
recID = rec.save();
var i = 1;
}
else
{
log.debug('Update Record Instead', ibsID);
recID = ibsID;
}
var inboundShipmentUpdate = r.load({
type: 'inboundshipment',
id: recID,
isDynamic: true
});
//Get Values from purchase order
var poID = e.poID;
var poName = e.poName;
var poShipDate = e.poShipDate;
var poShipWindowStart = e.poShipWindowStart;
if(poShipWindowStart != "")
poShipWindowStart = new Date(poShipWindowStart);
else
poShipWindowStart = "";
var poShipWindowEnd = e.poShipWindowEnd;
if(poShipWindowEnd != "")
poShipWindowEnd = new Date(poShipWindowEnd);
else
poShipWindowEnd = "";
//Item Fields
var itemID = e.items.itemID;
var itemDisplayName = e.items.displayName;
var itemName = e.items.name;
//Get Values from inbound shipment entry
var shipmentnumber = e.ibShipments.shipmentnumber;
var bookingDate = e.ibShipments.bookingDate;
if(bookingDate != "")
bookingDate = new Date(bookingDate);
else
bookingDate = "";
var vesselBookingNumber = e.ibShipments.vesselBookingNumber;
var expectedshippingdate = e.ibShipments.expectedshippingdate;
if(expectedshippingdate != "")
expectedshippingdate = new Date(expectedshippingdate);
else
expectedshippingdate = "";
var actualshippingdate = e.ibShipments.actualshippingdate;
if(actualshippingdate != "")
actualshippingdate = new Date(actualshippingdate);
else
actualshippingdate = "";
var vesselNumber = e.ibShipments.vesselNumber;
var containerNumber = e.ibShipments.containerNumber;
var factory = e.ibShipments.factory;
var shipmentStatus = e.ibShipments.shipmentstatus;
var poDueDate = e.ibShipments.poDueDate;
var expecteddeliverydate = e.ibShipments.expecteddeliverydate;
if(expecteddeliverydate != "")
expecteddeliverydate = new Date(expecteddeliverydate);
else
expecteddeliverydate = "";
var actualdeliverydate = e.ibShipments.actualdeliverydate;
if(actualdeliverydate != "")
actualdeliverydate = new Date(actualdeliverydate);
else
actualdeliverydate = "";
var destCountry = e.ibShipments.destCountry;
var quantityexpected = e.ibShipments.quantityexpected;
var quantityreceived = e.ibShipments.quantityreceived;
var billoflading = e.ibShipments.billoflading;
var cargoReturnDate = e.ibShipments.cargoReturnDate;
if(cargoReturnDate != "")
cargoReturnDate = new Date(cargoReturnDate);
else
cargoReturnDate = "";
var memo = e.ibShipments.memo;
//Set Field Values
inboundShipmentUpdate.setValue('actualshippingdate', actualshippingdate);
inboundShipmentUpdate.setValue('actualdeliverydate',actualdeliverydate);
inboundShipmentUpdate.setValue('custrecord_kk_booking_date', bookingDate);
inboundShipmentUpdate.setValue('custrecord_kk_cargo_return_dt',cargoReturnDate);
inboundShipmentUpdate.setValue('expectedshippingdate',expectedshippingdate);
inboundShipmentUpdate.setValue('expecteddeliverydate',expecteddeliverydate);
inboundShipmentUpdate.setValue('shipmentmemo', memo);
inboundShipmentUpdate.setValue('externaldocumentnumber',containerNumber);
//inboundShipmentUpdate.setValue('shipmentstatus',shipmentStatus);
inboundShipmentUpdate.setValue('billoflading',billoflading);
inboundShipmentUpdate.setValue('custrecord_kk_vesselbooking_number',vesselBookingNumber);
inboundShipmentUpdate.setValue('vesselnumber',vesselNumber);
inboundShipmentUpdate.setValue('custrecord_kk_destination',destCountry);
log.debug("Inside Line Items", e.items.itemID + " " + poID);
//The item must be unique, so it cannot already be on the inbound shipment. Do not set the current sublist value to the item
//if it already exists
var objCurRecIBS = JSON.parse(JSON.stringify(inboundShipmentUpdate));
log.debug("objCurRecIBS", objCurRecIBS );
var objSublistsIBS = objCurRecIBS.sublists ? objCurRecIBS.sublists : '';
log.debug("objSublistsIBS", objSublistsIBS );
var objIBSItems = objSublistsIBS.items ? objSublistsIBS.items : '';
log.debug("objIBSItems", objIBSItems );
var itemLineCountIBS = Object.keys(objSublistsIBS.items).length; //First Item is an empty item
var itemPresent = false;
//First Item is an empty item, so start at 1
for (var k = 1; k < itemLineCountIBS; k++)
{
//This keeps coming back empty
var currentQuantity = inboundShipmentUpdate.getCurrentSublistValue({
sublistId: "items",
fieldId: "quantityexpected"
});
log.debug("Current Quantity", currentQuantity + "Line " + k );
//So does this
var currentItem = inboundShipmentUpdate.getCurrentSublistValue({
sublistId: "items",
fieldId: "shipmentitem"
});
log.debug("Current Item", currentItem + "Line " + k );
var currItemIDIBS = objIBSItems[Object.keys(objSublistsIBS.items)[k]].itemid;
log.debug("Current Line Item Id", currItemIDIBS);
var currentLineIBS = objIBSItems[Object.keys(objSublistsIBS.items)[k]];
log.debug("cURRENT iTEM IBS Line", currentLineIBS);
if(currItemIDIBS == itemID)
{
//Update the existing line, since it is already present
itemPresent = true;
log.debug("Current Item Exists in the IBS", itemPresent);
//This is empty, too
var linePO = inboundShipmentUpdate.getCurrentSublistValue({
sublistId: "items",
fieldId: "purchaseorder"
});
log.debug("Line PO: ", linePO);
var currentQuantity = inboundShipmentUpdate.getCurrentSublistValue({
sublistId: "items",
fieldId: "quantityexpected"
});
log.debug("Current Quantity", currentQuantity + "Line " + k );
var newQuantity = currentQuantity + 2;
log.debug("New Quantity", newQuantity );
inboundShipmentUpdate.selectLine({
sublistId: 'items',
line: k
});
inboundShipmentUpdate.setCurrentSublistValue({
sublistId: "items",
fieldId: "quantityexpected",
value: newQuantity
//quantityexpected
});
inboundShipmentUpdate.commitLine({sublistId:"items"});
log.debug("Inside SELECT Line Items", "Line Committed" );
}
}
if(!itemPresent)
{
log.debug("Inside Item Present Check", itemPresent);
inboundShipmentUpdate.setCurrentSublistValue({
sublistId: "items",
fieldId: "shipmentitem",
value: shipmentitem
});
inboundShipmentUpdate.setCurrentSublistValue({
sublistId: "items",
fieldId: "quantityexpected",
value: quantityexpected
});
log.debug("Inside Line Items", "Shipment ITEM Added " + shipmentitem );
inboundShipmentUpdate.commitLine({sublistId:"items"});
log.debug("Inside Line Items", "Line Committed" );
}
++i;
inboundShipmentUpdate.save();
}
catch(err)
{
var msg = '';
log.debug("There was an error", err);
}
})
return "";
}
Does anyone have any idea why everything is coming back empty for me when I try to use NetSuite's methods, but showing correctly when I read the actual record's JSON?
I made this much more difficult than I needed to. I used the findSublistLineWithValue function, and was able to get the correct line value (it WAS 0, for whatever reason the json of the object was coming back with two entries, the first being empty values, so I incorrectly assumed that was line 0). I also had to compare against an actual string instead of a value, or I would get -1.
var lineNumber = inboundShipmentUpdate.findSublistLineWithValue({
sublistId: 'items',
fieldId: 'itemid',
value: itemID.toString()
});
Once I did this, I was able to get the correct values using my other methods. I just really dumbed down my api calls, and that helped me figure out what was going on.

GetCursorPos Node FFI - How to get pointer return by ref

I wrote following code to set keyboard cursor position. But get garbage. Any clue, what am I missing?
var ffi = require('ffi');
var ref = require('ref');
var Struct = require('ref-struct');
var point = Struct({
'x': 'long',
'y': 'long'
});
var user32 = ffi.Library('user32.dll', {
GetCaretPos:['bool',[locPtr]]
});
var pbuf = new point();
caretpos = user32.GetCaretPos(pbuf);
console.log(":",pbuf.x );
Next, I tried the following, but that doesn't work as well.
var ffi = require('ffi');
var ref = require('ref');
var Struct = require('ref-struct');
var voidPtr = ref.refType(ref.types.void);
var user32 = ffi.Library('user32.dll', {
GetCaretPos:['bool',[voidPtr]]
});
var pbuf = new Buffer(2);
caretpos = user32.GetCaretPos(pbuf);
var cpos =(new Uint8Array(pbuf));
console.log(">",cpos ); //Doesn't work **> Uint8Array [ 0, 0, 0, 0 ]**
As the article heading states "GetCursorPos in Node FFI" and return pointer x,y
The code below works for me, its a hack to get the x,y pointer.
var ffi = require('ffi');
var repbuffer = new Buffer(16); // holder for windows structures
var user32 = ffi.Library('user32.dll', {
'GetCursorPos':['bool',['pointer']]
});
//Show mouse cords at console every sec
setInterval( function() { getmousepos();}, 1000);
function getmousepos(){
var p = user32.GetCursorPos(repbuffer);
var x= repbuffer[0]+ (repbuffer[1]*256);
var y= repbuffer[4]+(repbuffer[5]*256);
console.log(x + " " + y);
}
What worked for me:
var PointStruct = Struct({
x: ffi.types.long,
y: ffi.types.long,
});
var user32 = ffi.Library("user32", {
GetCursorPos: ["bool", [ref.refType(PointStruct)]],
SetCursorPos: ["long", ["long", "long"]],
});
export function GetMousePos() {
let mousePosBuffer = ref.alloc(PointStruct);
let success = user32.GetCursorPos(mousePosBuffer);
let mousePos = mousePosBuffer["deref"]() as {x: number, y: number};
return new Vector2i(mousePos.x, mousePos.y);
}
export function SetMousePos(x: number, y: number) {
user32.SetCursorPos(x, y);
}

Listing folders in specified folder

I'm trying this code to list the files inside cabinet's folder in NetSuite, but I can list only the files. I need to list the folders inside the folder with the ID: 28
The code I'm using:
var folder = 28;
var filters = new Array();
filters[0] = new nlobjSearchFilter('internalid', null, 'is', folder);
var columns = new Array();
var filename = new nlobjSearchColumn('name', 'file');
var fileid = new nlobjSearchColumn('internalid', 'file');
columns[0] = filename;
columns[1] = fileid;
var searchResult = nlapiSearchRecord('folder', null , filters , columns);
if(searchResult) {
for (var i = 0 ; i < searchResult.length; i++) {
alert(searchResult[i].getValue(filename)+searchResult[i].getValue(fileid));
};
};
The result:
warning File1.txt1938 11/22/2016 17:30:08.693
warning File2.txt1636 11/22/2016 17:30:08.693
warning File3.txt1939 11/22/2016 17:30:08.693
warning File4.txt4601 11/22/2016 17:30:08.693
this is correct, but it's listing only files, not folders?
Thanks!
Perform a UserEvent BeforeLoad function. All files have a parent folder ID.
// pass in the internal id of the file's parent folder
var folder = 415 // the folder ID we care about
var filters = new Array();
filters[0] = new nlobjSearchFilter('internalid', null, 'is', folder);
//file name and file internal ID
var columns = new Array();
var filename = new nlobjSearchColumn('name', 'file');
var fileid = new nlobjSearchColumn('internalid', 'file');
columns[0] = filename;
columns[1] = fileid;
// perform the search and loop through the findings
var searchResult = nlapiSearchRecord('folder', null , filters , columns);
if(searchResult) {
for (var i = 0 ; i < searchResult.length; i++) {
var f = searchResult[i];
//do what you want with f here
};
};
Credit: http://blog.prolecto.com/2014/01/09/get-netsuite-list-of-files-from-folder/
I was able to list the subfolders of folder with this code:
var folder = 3232;
var filters = new Array();
filters[0] = new nlobjSearchFilter('parent', null, 'is', folder);
var columns = new Array();
var filename = new nlobjSearchColumn('name');
var fileid = new nlobjSearchColumn('internalid');
columns[0] = filename;
columns[1] = fileid;
var searchResult = nlapiSearchRecord('folder', null , filters , columns);
if(searchResult) {
for (var i = 0 ; i < searchResult.length; i++) {
alert(searchResult[i].getValue(filename)+searchResult[i].getValue(fileid));
};
};

Resources