Is there a way to ensure 1 controller finishes before the next 1?
I was trying to have a controller make changes via the UpdateElement service and then a 2nd controller do some things before undoing the changes with another UpdateElement, but they didn't always happen in the same order. Sometimes the 2nd controller would try to undo the change before the 1st one actually made the change.
Sequential Controllers in Event
-
- Posts: 178
- Joined: August 31st, 2021, 11:37 am
- Contact:
-
- Posts: 329
- Joined: August 26th, 2021, 9:18 am
- Contact:
Re: Sequential Controllers in Event
The order that they are displayed should be the order the execute in then you should be able to use the arrows to change the order. Can you take a look at the JavaScript that is generated?
word count: 37
-
- Posts: 178
- Joined: August 31st, 2021, 11:37 am
- Contact:
Re: Sequential Controllers in Event
I think they are being called in order, but not always returning in that same order.
Here is the JS code. I autoformatted it.
Here is the JS code. I autoformatted it.
Code: Select all
function WorkOrderStagingGrid_SGPartLotLocs_change(event, target, loopIndex, modelDataObj) {
if (loopIndex == null || loopIndex == undefined || loopIndex == "") {
loopIndex = 0;
}
let args = {};
let workData = {};
workData['ViewName'] = 'WorkOrderStagingGrid';
workData['EventName'] = 'DisableSubmit';
let input = {};
let searchElement = null;
let parent = $(target).parents('view[viewid="VIEW-20000023"]');
if (parent != null && parent != undefined && parent.length != 0) {
searchElement = parent;
} else {
searchElement = document;
}
let options = {
CauseValidation: 'False',
GroupToValidate: 'Default',
ValidationLocation: 'Inline',
TemplateWidgetControllerMode: 'Row',
TemplateWidgetControllerRow: '0',
SearchElement: searchElement
};
workData['_ControllerParameters'] = input;
args['WorkData'] = workData;
EPEvent(args, event, options);
args = {};
workData = {};
workData['ViewName'] = 'WorkOrderStagingGrid';
workData['EventName'] = 'SelectFromLotLoc';
input = {};
input['PartNumber'] = {};
input['PartNumber'] = $($(searchElement).find('[containerId="VIEW-20000023"][name="ComponentID"]')[loopIndex]).val();
input['LotLocation'] = {};
input['LotLocation'] = $(target).val();
input['LotNumber'] = {};
input['LotNumber'] = '';
input['ThisIndex'] = {};
input['ThisIndex'] = $($(searchElement).find('[containerId="VIEW-20000023"][name="SGPartIndex"]')[loopIndex]).val();
options = {
CauseValidation: 'False',
GroupToValidate: 'Default',
ValidationLocation: 'Inline',
TemplateWidgetControllerMode: 'Row',
TemplateWidgetControllerRow: '0',
SearchElement: searchElement
};
workData['_ControllerParameters'] = input;
args['WorkData'] = workData;
EPEvent(args, event, options);
}
word count: 170
-
- Posts: 329
- Joined: August 26th, 2021, 9:18 am
- Contact:
Re: Sequential Controllers in Event
EPEvent() is making a jquery ajax call which is asynchronous by default.
https://api.jquery.com/jquery.ajax/
Which makes sense why they may return out of order. There is a async flag we can use for this. Will just need to determine where/how to set that.
https://api.jquery.com/jquery.ajax/
Which makes sense why they may return out of order. There is a async flag we can use for this. Will just need to determine where/how to set that.
word count: 48