can someone confirm if you must set the line level...
# administration
m
can someone confirm if you must set the line level Inventory location if Cross Subsidiary Fulfillment is enabled? I was under the impression, you only set the line level inventory location IF you wish to use the cross subsidiary fulfillment option? It seems, normal orders go on to back order if the inventory location is not set.
n
You need to set it. We deployed a script that populates the field for the users based on the header location. In the locations where we had cross subsidiary fulfills the new orders are now processing correctly. It’s in SuiteAnswers somewhere.
m
I found out in SA that once the feature is enabled, the body level location is no longer used for inventory. This means the users must set it at line level and given that some orders contain up to 50 items we'll need to do what you did and auto set it using the body location. Do you know if that was done using Client Script and on Validate Line function?
n
We used this User Event before submit script. Enabling the feature is one part, the existence of the "*Global Inventory Relationship"* for the Location is what changed it for us. We use this script to only update our sub's orders where we have a Global Inventory Relationship.
/**
* @NApiVersion 2.x
* @NScriptType UserEventScript
* @NModuleScope SameAccount
*/
define(['N/error', 'N/log', 'N/record','N/runtime'],
function(error, log, record,runtime) {
const LINE_FIELD_INVENTORY_LOCATION = 'inventorylocation';
function soBeforeSubmit(scriptContext){
if(scriptContext.type == scriptContext.UserEventType.CREATE || scriptContext.type == scriptContext.UserEventType.EDIT){
try{
var headerLocation = scriptContext.newRecord.getValue({
fieldId: 'location'
});
var transactionSubsdiary = scriptContext.newRecord.getValue({
fieldId: 'subsidiary'
});
log.debug('transactionSubsdiary'+transactionSubsdiary);
//If the subsidiary is  do this, otherwise do not execute.
if(transactionSubsdiary == 6 || transactionSubsdiary == 7 ){
//get the number if line is on the Sales Order
if (headerLocation){
var itemcount = scriptContext.newRecord.getLineCount({
sublistId: 'item'
});
log.debug('transactionSubsdiary:'+transactionSubsdiary+' Location ID:'+headerLocation+' No of lines:'+itemcount);
//get the existing line inventory location
for(var i = 0; i < itemcount; i++){
var lineLocation = scriptContext.newRecord.getSublistValue({
sublistId: 'item',
fieldId: LINE_FIELD_INVENTORY_LOCATION,
line: i
});
//update the line INventory Location if it does not match the header location.
if(lineLocation != headerLocation){
scriptContext.newRecord.setSublistValue({
sublistId: 'item',
fieldId: LINE_FIELD_INVENTORY_LOCATION,
line: i,
value: headerLocation
});
}
}
}
}
}
catch(e){
log.debug(e.name,e.message);
}
}
}
return {
beforeSubmit: soBeforeSubmit
};
});
m
Thanks for this. So the script is basically grabbing the header location and the line level location and compares the two and if it is different it sets it to the header level. This is exactly what I need. Out of interest: "We use this script to only update our sub's orders where we have a Global Inventory Relationship." - I don't think it matters if you have the GIR record because once the feature is enabled the header level location is no longer considered for commitment, which is why our orders went on to back orders.
the script worked perfect, many thanks. I guess now I just need to change it so that if it is genuinely a cross sub fillment then we do not use header level location.
n
Yes. For my use case I was only using cross-subsidiary returns. It only impacted sales orders for my GIR locations.