Hi, I am adding items into the purchaseorder using...
# suitescript
m
Hi, I am adding items into the purchaseorder using client script it is adding items but not committing to new line after adding first item how can I add items to the existing grid, I have below code
Copy code
currentRecord.selectNewLine({ sublistId: 'expense' });

						currentRecord.setCurrentSublistValue({ sublistId: 'expense', fieldId: 'account', value: account1 });
						
						var amount1 = purchaseReq.getValue({ fieldId: 'custrecordpola1' });
						currentRecord.setCurrentSublistValue({ sublistId: 'expense', fieldId: 'amount', value: amount1 });
						
						var department1 = purchaseReq.getValue({ fieldId: 'custrecord89' });
						currentRecord.setCurrentSublistValue({ sublistId: 'expense', fieldId: 'department', value: department1 });
						
						var location1 = purchaseReq.getValue({ fieldId: 'custrecord109' });
						currentRecord.setCurrentSublistValue({ sublistId: 'expense', fieldId: 'location', value: locationId });
						
						// commit the changes
						currentRecord.commitLine({ sublistId: 'expense' });
after adding items it is showing like below image, I do not want to click on add button, is there any way to add items.
r
You usually have to call record.save after commitLine as far as I'm aware.
m
are you sure it will not save the purchase order.
r
It will save the purchase order. Maybe someone else can weigh in on this but I'm sure you have to call save for the changes to lines to take effect.
l
What’s the trigger to add these lines? was Vendor and Subsidiary set before?
s
^ what battk said and make sure you set them in the exact order you would set them when modifying the lines in the UI