mercredi 10 juin 2020

How to add another if condition in nested if else statement?

I am trying to add another condition in my if else statement. However, I am not sure how to add a if statement without condition? I cant use switch condition in this case. I want to replicate the else statement but with different query. Below is the code.

        if (smartSearchText) {
            //First try to search for erp
            var smartFilter = "startswith(WorkOrder/ERPOrder,'" + encodeURIComponent(smartSearchText) + "')&$orderby=Sequence asc";
            query = u4dmSvc.data.spliceFilterClause(options, statusCriteria);
            query = u4dmSvc.data.spliceFilterClause(query, smartFilter);
            query = addSelectAndExpand(query, { producedMaterialItems: true, isExGroup: isExGroup });
            return loadOperations(query).then(
                function (snResult) {
                    if (snResult.value.length > 0) {
                        snResult.count = 1;
                        return snResult;
                    }

                    else {
                        //Try to search for Machine 
                        var workPlaceFilter = "startswith(WorkOrder/NId,'" + encodeURIComponent(smartSearchText) + "')&$orderby=Sequence asc";
                        var workPlaceQuery = u4dmSvc.data.spliceFilterClause(options, statusCriteria);
                        workPlaceQuery = u4dmSvc.data.spliceFilterClause(workPlaceQuery, workPlaceFilter);
                        workPlaceQuery = addSelectAndExpand(workPlaceQuery, { toBeUsedMachines: true, isExGroup: isExGroup });
                        return loadOperations(workPlaceQuery);
                    }
           }

Aucun commentaire:

Enregistrer un commentaire