This topic contains 8 replies, has 0 voices, and was last updated by grygmpl 7 years, 6 months ago.
-
AuthorPosts
-
April 19, 2017 at 6:24 pm #5787
grygmplHi,
I’m a newbie on scripting and I would like to create a script that will populate the Location on the line items of a PO based on the Location on the main form.
Any help is highly appreciated.
Thanks,
Gary
This is a cached copy. Click here to see the original post. -
April 19, 2017 at 8:28 pm #5788
k_duncThis certainly sounds achievable. So you’d want to probably write a Client Script for that purpose. Here’s a link to SuiteAnswers.
So what you could do, is use a Validate Line function that, upon the user ‘adding’ a new PO row, you simply populate the Location column with the value of what’s in the Location body field. Once you get that working, you could potentially even hide the Location column so the user doesn’t even have to interact with it.
-
April 19, 2017 at 11:33 pm #5789
Vesku1980Hi,
I made this kind on functionality with postsourcing function in client script.
function postSourcing(type, name){
if(type === ‘item’ && name === ‘item’){
var loc = nlapiGetFieldValue(‘location’); // GET Location from main page
nlapiSetCurrentLineItemValue(‘item’, ‘location’, loc);
}
}
This script is executed when item is added to line.
Vesku
-
April 27, 2017 at 6:56 pm #5790
grygmplHi k_dunc and Vesku,
Thank you for your responses Appreciate it a lot. Script is working like a charm.
-Gary
k_dunc replied on 04/27/2017, 09:50 PM: Great to hear.
-
May 1, 2017 at 4:02 pm #5791
grygmplHello again,
I also wanted to apply this under the Expenses column ? Is this possible ?
Thanks,
Gary
-
May 1, 2017 at 7:04 pm #5792
k_duncHi Gary,
That too should be achievable. Instead of linking to the ‘item’ sublist, you’d need to link to the ‘expense’ sublist. Something like this:
Code:
nlapiSetCurrentLineItemValue(‘expense’, ‘location’, loc);
Note, the first parameter in the Set Current Line Item Value API is the sublist to link to. May I also suggest that if you’re going to be doing this sort of thing, you should bookmark the NetSuite Records Browser. In the Records Browser, you can then see all the fields and field IDs for each record type. -
May 3, 2017 at 7:20 pm #5793
grygmplThanks again k_dunc. I’m actually trying to populate the Department this time.
I’ve tried this one but doesn’t work. Not sure what I am missing.
function PopulateDept(type, name) {
if(type === ‘expense’ && name === ‘expense’)
{ var deptmain = nlapiGetFieldValue(‘department’);
nlapiSetCurrentLineItemValue(‘expense’, ‘department’, deptmain);
}
}
-
May 3, 2017 at 9:56 pm #5794
k_duncI would guess because there is no “expense” field on a PO. The ‘name’ argument is the name (Internal ID) of the field that you’re testing to see if it has changed. You’d need to change that second part of your ‘if’ to something like:
Code:
if(type === ‘expense’ && name === ‘amount’)
So this means, that once the ‘amount’ field changes in the Expenses sublist, then it should set your department column. You could change the ‘amount’ to almost any other column field you wish to use instead (so long as it’s part of the Expenses sublist). -
May 4, 2017 at 7:56 am #5795
grygmplI actually tried to use other fields i.e. account. It’s strange that when I am testing it the first time, it’s not working.
But now suddenly, the script is working.
Not sure what happened but anyway, thanks again for your kind help. Appreciate it a lot. =)
-
AuthorPosts
You must be logged in to reply to this topic.