I am setting the value of the sublist of SO in the...
# suitescript
v
I am setting the value of the sublist of SO in the fieldChanged functiion. but its not setting up the value. how to achieve this?
v
I think you've been here long enough to know to share your code 🙂
v
function fieldChanged(context) { try{ var salesOrderRecord = context.currentRecord; var sublistName = context.sublistId; var fieldName = context.fieldId; var lineCount = salesOrderRecord.getLineCount('item'); var customer = salesOrderRecord.getValue('entity'); for(var i = 0; i < lineCount; i++){ if(sublistName === 'item' && fieldName === 'item'){ log.debug('entering if line',i); var item = salesOrderRecord.getCurrentSublistValue({ sublistId : 'item', fieldId : 'item' }); log.debug('item',item); var itemType = salesOrderRecord.getCurrentSublistValue({ sublistId : 'item', fieldId : 'itemtype' }); var manufactureCountry = search.lookupFields({ type : itemType, id : item, columns : ['countryofmanufacture'] })['countryofmanufacture']; log.debug('manufacturecountry',manufactureCountry); if(manufactureCountry){ log.debug('engerin if manucountry'); salesOrderRecord.setCurrentSublistValue({ sublistId : 'item', fieldId : 'custcol_country_of_origin_code', value : manufactureCountry }); } } } }catch(e){console.log('error',e);} }
v
Is this doable just using field sourcing?
v
you mean postSourcing?
if you mean postSourcing, the execution comes into the set function, but it does not set the value
v
No, i mean sourcing the field. Setting on the custom column field. No scripting needed.
v
SORRY I DONT GET IT; I GET THE MANUFACTURECOUNTRY, BUT ITSNOT SETTING UP THE VALUE
log.debug('engerin if manucountry'); i get this log
b
sourcing is the non suitescript option to fill in a field with the value from another related record, in this case to source a field from the item set on the item line
if you want to script this still, i heavily advise reducing your code to only set a hardcoded value in your field
there are multiple mistakes in your code its hard to tell which one you are at