I have a script that imports in 2 other scripts an...
# suitescript
p
I have a script that imports in 2 other scripts and functions. How can I determine which script fires first? I thought putting them in order would do it - but it is not:
Copy code
autoStd.autoStd();
riatTAS.riatTAS();
Right now the
riatTAS
is firing first. I tried switching the order and it is still firing first.
b
autoStd.autoStd();
should run first
it might not do anything if its asynchronous
p
not asychronus. I am thinking it is being cached this way because originally i had it the opposite way with riatTAS first. I did try clearing the browser cache but still the same.
b
what does the rest of the code look like
p
Copy code
define(['N/currentRecord', 'N/search', 'N/ui/dialog', './export_AirStdRates.js', './addRiatRates.js', './export_AirStdRatesFAS.js'], (currentRecord, search, dialog, autoStd, riatTAS, autoStdFAS) => {

    function pageInit(context) {}

    function selectTariffType(context) {
        const options = {
            title: 'Select import Type',
            message: 'Select import type.',
            buttons: [{
                    label: 'Std TAS',
                    value: 1
                },

                {
                    label: 'STD FAS',
                    value: 2
                }

            ]
        };

        function success(result) {
            if (result == 1) {
                autoStd.autoStd();
                riatTAS.riatTAS();
            } else if (result == 2) {
            autoStdFAS.autoStdFAS();
            }
}

        function failure(reason) {
            console.log(Failure: ${reason})
        }

        dialog.create(options).then(success).catch(failure);
    }
    return {
        selectTariffType,
        pageInit
    };
});
b
are you sure you understand what is asynchronous or not?
your code uses a Promise, which is very much asynchronous
p
guess i did not. thought i did.
b
you also probably want to fix your failure function, its missing its backticks (`)
p
got it. thanks.