This topic contains 1 reply, has 0 voices, and was last updated by markjasonflores 7 years, 8 months ago.
-
AuthorPosts
-
March 2, 2017 at 9:32 am #21796
zcheng100I create a customized csv import suitelet. It reads date from selected csv file, create sales order with ('ismultishipto',"T"), and create custom address for each line item. I used for loop to check if it is same address. When it happens to be same address, I need to select shipaddress. It seens that custom shipaddress is not available to load. I don't want go back to edit shipaddress after salesorder is created. How can I select shipaddress to a custom shippingaddress by script?
Here is my code to create custom shippingaddress:
var subrecord = newSalesorder.createCurrentLineItemSubrecord('item ', 'shippingaddress');
subrecord.setFieldValue( 'label', itemArray[i][nameIndex]);
subrecord.setFieldValue( 'attention', itemArray[i][nameIndex]);
subrecord.setFieldValue( 'addressee', itemArray[i][companyIndex]);
subrecord.setFieldValue( 'addr1', itemArray[i][streetIndex]);
subrecord.setFieldValue( 'city', itemArray[i][cityIndex]);
subrecord.setFieldValue( 'zip', itemArray[i][zipIndex]);
subrecord.setFieldValue( 'state', itemArray[i][stateIndex]);
subrecord.setFieldValue( 'country', 'US');
subrecord.commit();
This is a cached copy. Click here to see the original post. -
March 7, 2017 at 4:51 pm #21797
markjasonfloresHello zcheng100
Here is a sample code on how you can define custom address on item lines on the SO
:
var tran = nlapiCreateRecord('salesorder', {recordmode: 'dynamic'});
tran.setFieldValue('entity', '220');
tran.setFieldValue('ismultishipto', 'T');
tran.selectLineItem('item', 1);
tran.setCurrentLineItemValue('item', 'item', '144');
tran.setCurrentLineItemValue('item', 'quantity', '2');
//Custom address definition
var subrecord = tran.createCurrentLineItemSubrecord('item', 'shippingaddress');
subrecord.setFieldValue('country', 'US');
subrecord.setFieldValue('addr1', 'Test 1');
//Custom address label is write-only. Address will be stored with this label, but when address is loaded again, it won't be available for read using SuiteScript (it will be visible in UI as usual). This is because label is not a part of address and so it won't be loaded on address subrecord load.
//When custom address is edited, new custom address is always created. When custom address is edited after transaction was saved and loaded again, label will be null as it won't be copied over to new custom address. In such case, user has to define address label again.
subrecord.setFieldValue('label', 'My label');
subrecord.setFieldValue('zip', '94403');
subrecord.setFieldValue('state', 'CA');
subrecord.commit();
tran.commitLineItem('item');
tran.selectNewLineItem('item');
tran.setCurrentLineItemValue('item', 'item', '144');
tran.setCurrentLineItemValue('item', 'quantity', '3');
//User can use new custom address on multiple item lines, he just needs to set its address book key to item line 'shipaddress' select. In this case we set custom address used on item line 1
tran.setCurrentLineItemValue('item', 'shipaddress', tran.getLineItemValue('item', 'shipaddress', 1));
tran.commitLineItem('item');
nlapiSubmitRecord(tran);
zcheng100 replied on 03/13/2017, 10:51 AM: I tried. tran.setCurrentLineItemValue(‘item’, ‘shipaddress’, tran.getLineItemValue(‘item’, ‘shipaddress’, 1)); results empty ship to address.
-
AuthorPosts
You must be logged in to reply to this topic.