i need to fill the custom line field 'Origin Count...
# suitescript
v
i need to fill the custom line field 'Origin Country' in the SO line of the Item with the value of the manufacture country of the Item. I am trying to set , but its not set .
n
You need to provide more details, come on man, you need to do better to help us to help you! 🧐 It's a custom field but you provide no details of what the field type is or how it's configured. You do not explain whether you have the value or your problem is you're setting it but it's not showing afterwards. You have not shared your code.
v
its a custom free-form text field , but in the sales order item line, its showing as a country drop-down list.
function fieldChanged(context) { try{ var salesOrderRecord = context.currentRecord; var sublistName = context.sublistId; var fieldName = context.fieldId; var lineCount = salesOrderRecord.getLineCount('item'); 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 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_name', value : manufactureCountry }); } } } }catch(e){log.debug('error',e);} }
n
Where is itemType coming from? var manufactureCountry = search.lookupFields({ type : itemType, // <-- This? id : item, columns : ['countryofmanufacture'] })['countryofmanufacture' and do you see a value for manufactureCountry?
v
sorry it missed but its there in the script var itemType = salesOrderRecord.getCurrentSublistValue({ sublistId : 'item', fieldId : 'itemtype' });
n
and do you see a value for manufactureCountry?
v
yes i get it
only setting up the value is not successful
r
I'm guessing you created a script record for your client script and therefore log.debug() is doing something. Another approach is to use console.log() and view your logs in the browser console. For me that's accessible via CTRL-SHIFT-J.
I recommend using
log.error()
when catching an error.
v
no it does not help even