I have a UE deployed to work orders that is trying...
# suitescript
b
I have a UE deployed to work orders that is trying to populate fields based on data from the createdfrom record. These are multi-level boms and the item source is set to work order so we create the top level in the UI and then the system creates all of the sub work order. The problem that I'm running into is that the top level work order doesn't seem to submit to the server until the lower levels are all saved so all of my search for the data to set to fields in the createdfrom are returning null. What is the best way to handle this? It's really just three fields that I need to write - two are static based on what is set at the parent work order and one is numeric so createdfrom.number + 1 to create a sequence.
oh.
@Michael McNamara how did you solve this? I see your record.load() idea but post-processing lost me. Are you calling another script at the end?
m
@Bryan Miller Hey Bryan….Been a while since I did thid, but here was my working script
const beforeSubmit = (scriptContext) => {
var currentWorkOrder = context.newRecord;
var assemblyItem = currentWorkOrder.getValue({
fieldId: 'assemblyitem'
});
var buildQty = currentWorkOrder.getValue({
fieldId: 'quantity'
});
log.debug({
title: 'Item: ' + assemblyItem
});
if(assemblyItem !== null){
var itemBuildMin =  search.lookupFields({
type: search.Type.ITEM,
id: assemblyItem,
columns: ['custitem_lum_min_wo_build_qty']
});
}
if(itemBuildMin !== null){
var minNum = itemBuildMin['custitem_lum_min_wo_build_qty']
log.debug({
title: minNum
});
if(buildQty < minNum){
var checkMark = currentWorkOrder.setValue({
fieldId: 'custbody_lum_below_min_qty',
value: true,
ignoreFieldChange: false
});
}
else if(buildQty >= minNum){
var uncheckMark = currentWorkOrder.setValue({
fieldId: 'custbody_lum_below_min_qty',
value: false,
ignoreFieldChange: false
});
}
}
}
🙌 1
b
Thanks!