Hello, how do I validate a line on a vendor bill w...
# suitescript
p
Hello, how do I validate a line on a vendor bill when its been added/editied for the item sublist? I only want to do the check when the user is on the item sublist
b
what are you doing now? All the line validation entry points have a context object which tells which sublist triggered it
p
I don't have anything yet. I would like to check when its created or editied
I got the logic down. is it possible to validate on edit and create? here is my code: function validateLine(scriptContext) { if ('item' == scriptContext.sublistId) { var curRec = scriptContext.currentRecord var item_id= curRec.getCurrentSublistValue({ sublistId: 'item', fieldId: 'item' }); log.debug({details:"item_id = " + item_id}); var iteminfo = search.lookupFields({ "type" : "item", "id" : item_id, "columns" : [ "custitem_pi_expenseaccounttype", ] }); log.debug(iteminfo); var itemexpensetype = iteminfo.custitem_pi_expenseaccounttype; log.debug({details:"itemexpensetype = " + itemexpensetype}); if (itemexpensetype == 'Fixed Asset') { alert('Item is a fixed asset'); return false; }
e
validateLine
runs whenever a sublist line is committed. It doesn't matter if it's a new record or an existing one, and it doesn't matter if any fields changed or not. Basically any time the user clicks OK on a sublist line, the
validateLine
event fires
p
thats awesome. thank you
b
the item filtering you are doing can be done via an item filter on the form
the item filter allows you to define a saved search of valid items
p
thanks