This topic contains 2 replies, has 0 voices, and was last updated by rob@harkness 7 years, 3 months ago.
-
AuthorPosts
-
August 9, 2017 at 5:01 am #21514
rob@harknessThe below updates all line item descriptions from the body memo field using a client script with a 'field changed function' and is deployed on the sales order. I would like to change this to trigger on save instead. I have tried to change to 'save record function' but it doesnt work. I have also tried to change the script type to an event script with no joy.
Code:
function description(type,name){
if (name == 'memo'){
var description = nlapiGetFieldValue('memo');
var count = nlapiGetLineItemCount('item');
if (count > 0){
for (var x = 1; x <= count; x++){
nlapiSelectLineItem('item', x);
nlapiSetCurrentLineItemValue('item', 'description', memo.value, false, true);
nlapiCommitLineItem('item');
}
}
}
}
Any help appreciated
This is a cached copy. Click here to see the original post. -
August 11, 2017 at 1:51 pm #21515
jejacobThis works on my end:
Code:
var memoInit;
var memoSave;function clientPageInit(type){
if(type == 'edit'){
memoInit = nlapiGetFieldValue('memo');
}
}function clientSaveRecord(){
memoSave = nlapiGetFieldValue('memo');
if(memoInit !== memoSave){
var itemsListCount = nlapiGetLineItemCount('item');
for (var x = 1; x <= itemsListCount ; x++ ){
nlapiSetLineItemValue('item', 'description', 1, memoSave);
}
}
return true;
} -
August 21, 2017 at 4:46 am #21516
rob@harknessThis is great thanks Jejacob. Behaviour works to update the line item 'memo' on save. However this only seems to be working for the first line. I cant seem to get this to work for multiple lines on creation or edit
erictgrubaugh replied on 08/21/2017, 07:51 AM: I’m assuming you copied this line exactly then:
nlapiSetLineItemValue(‘item’, ‘description’, 1, memoSave);
You can see it is always setting the first line. Change the index parameter of nlapiSetLineItemValue to match your loop iterator variable x, and it will set the value for all lines.
-
AuthorPosts
You must be logged in to reply to this topic.