Validate customer and items entered in sales order.

To validate the sales order whether the customer and items entered in it are synced to TrackTraceRX environment.

         function fieldChanged(scriptContext) {
            try {                
                let currentRecord = scriptContext.currentRecord;
                let sublistFieldName = scriptContext.fieldId;
                if (sublistFieldName === "entity") {
                    let entityId = currentRecord.getText({
                        fieldId: "entity"
                    })
                    let customerId = customerSearch(entityId);
                    if (checkForParameter(customerId)) {
                        alert("Customer is not synced to TrackTrace Environment.")
                    }
                }
                let sublistName = scriptContext.sublistId;
                if (sublistName === 'item' && sublistFieldName === 'item') {
                    let item = currentRecord.getCurrentSublistText({
                        sublistId: 'item',
                        fieldId: 'item'
                    })
                    let itemId = itemSearch(item);
                    if (itemId) {
                        alert("Item is not synced to TrackTrace Environment.")
                    }
                }
              } catch (e) {
                console.log("error @fieldChanged", e);
              }
          }

Leave a comment

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