Allocating production, sandbox and RP accounts data with 3rd party real-time sync

When using real-time APIs (user event scripts), we need to identify the environment as well as the account id so that the data is sent to the correct database.

In this case, we can add functionality in the library file or in the code to find the production account, and sandbox accounts and send data to the mapped database.

            let companyInfo = config.load({
                type: config.Type.COMPANY_INFORMATION
            });

            let ns_companyid = companyInfo.getValue({
                fieldId: 'companyid'
            });

            ns_companyid = ns_companyid.toString().trim().toLowerCase();

            if (Number.isNaN(Number(ns_companyid)) && ns_companyid.indexOf('sb1') > -1) {
                return sandboxDevGlobal;
            }
            else if (Number.isNaN(Number(ns_companyid)) && ns_companyid.indexOf('sb2') > -1) {
                return sandboxTestGlobal;
            }
            else if (Number.isNaN(Number(ns_companyid)) && ns_companyid.indexOf('rp') > -1) {
                return rpGlobal;
            }
            else if (Number.isNaN(Number(ns_companyid)) && ns_companyid.indexOf('sb') == -1) {
                return {};
            }
            else {

                 if (runtime.EnvType == runtime.EnvType.PRODUCTION) {
                    return productionGlobal;
              }
            }

Leave a comment

Your email address will not be published. Required fields are marked *