asked on January 30, 2023

I am using a JSON script to pull data from a form upon submission and store it to be used to repopulate another form if necessary.  The script works perfectly expect for fields that pull data from a sp with a parameter requirement.  It is bypassing the rule to populate the field and dropping the data to be reselected even if the parameter is filled in.  

Here is the script that takes the field data and repopulates the field:

   //lookup complete
    $(document).on("lookupcomplete", function() {
        console.log("Lookup Complete");

       //update Fields
        function updateField(type, id, value) {
            //If value is an array, update each value for the field
            try {
                JSON.parse(value).forEach(function(x) {
                    updateField(type, id, x);
                });
                return;
            } catch (error){}

            //Checkbox - Radio
            if (["checkbox", "radio"].includes(type)) {
                $("[id='" + id + "'] [value='" + value + "']:not(.value-imported)")
                    .prop("checked", true)
                    //.attr("lookupalt","true")
                    .addClass("value-imported")
                    .trigger("change");
            }
            //Text - LongText - email - number - Date - Select
            if (["text", "longtext", "email", "date", "number", "select"].includes(type)) {
                $("[id='" + id + "']:not(.value-imported)")
                    .val(value)
                    //.attr("lookupalt","true")
                    .addClass("value-imported")
                    .trigger("change");
            }

        }

I'm sure this is a clash between the lookup rule already imbedded and the script.  Is there a way to override it?

0 0