Sequential Controllers in Event

This forum allows users to post and respond to "How Do I Do ....." questions. The information contained in this forum has not been validated by K-Rise Systems and, as such, K-Rise Systems cannot guarantee the accuracy of the information.
Post Reply
JefferyD
Posts: 177
Joined: August 31st, 2021, 11:37 am
Contact:

Sequential Controllers in Event

Unread post by JefferyD »

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.
Multi-Controllers.PNG
Multi-Controllers.PNG (21.2 KiB) Viewed 459 times
Multi-Controllers.PNG
Multi-Controllers.PNG (21.2 KiB) Viewed 459 times
word count: 87

Tags:
SteveCap
Posts: 328
Joined: August 26th, 2021, 9:18 am
Contact:

Re: Sequential Controllers in Event

Unread post by SteveCap »

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
JefferyD
Posts: 177
Joined: August 31st, 2021, 11:37 am
Contact:

Re: Sequential Controllers in Event

Unread post by JefferyD »

I think they are being called in order, but not always returning in that same order.

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
SteveCap
Posts: 328
Joined: August 26th, 2021, 9:18 am
Contact:

Re: Sequential Controllers in Event

Unread post by SteveCap »

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.
word count: 48
Post Reply