Automate

 View Only
  • 1.  Javascript - Conditionally Remove Dropdown Requirement and Invalid Option Warning

    Posted 21 days ago

    I have a Country & Region field. Both are required fields.

    Region's data is based on what is entered into the Country field. Select US as Country.... Region is all the state names

    I have some Countries that do not have any Regions so I would like to dynamically remove the dropdown requirements and invalid option warning from the Regions filed using javascript.  

    I can remove the frm_required and I can also set text-danger to "" <div class="text-danger">Invalid Option: WA</div> however when I click the submit button the "Invalid Option: WA" text reappears.

    What is the method to remove the text-danger so on Submit it doesn't reappear.

    Thanks,

    Kurt

        if (missingRegion.includes(searchItem)) {
            $form.setControlRequired('/my:myFields/my:ff_Region', false);
            $j("#content_frm_element_11280").removeClass("frm_required");
            setTimeout(function () {$j('#frm_element_11280 .text-danger').remove();}, 200);
            //$j("#content_frm_element_11280 .text-danger").removeClass("text-danger");
            //wsremoveError('/my:myFields/my:ff_Region');
        } else {
            $form.setControlRequired('/my:myFields/my:ff_Region', true);
        }

    <div type="control_dropdown" class="form-control-wf" id="frm_element_11280" data-cid="frm_element_11280" data-corigid="frm_element_11280">
    <div id="content_frm_element_11280">
    <div id="frm_label_80" class="form-label form-label-top frm_required" style="z-index: 100;">
    <span class="form-label-span editable">Region</span>
    </div>
    <div class="control-body" style="display:inline-block;width:100%">
    <div class="control-boxsize" style="width:100%">
    <span class="form-sub-label-container" style="width:100%">
    <select id="frm_component_select1_80" data-link="my_myFields.my_ff_Region.ws_text" class="form-component form-dropdown dropdown required_field" type="text" maxlength="6" style="">
    <option value="">No Region</option>
    </select>
    <label id="frm_component_label1_80" class="form-component form-sub-label sublabel "></label>
    </span>
    <div class="text-danger">Invalid Option: WA</div>
    </div>
    </div>
    </div>
    </div>


    ------------------------------
    Kurt Marshman
    Old World Industries, LLC
    ------------------------------


  • 2.  RE: Javascript - Conditionally Remove Dropdown Requirement and Invalid Option Warning

    Employee
    Posted 19 days ago

    Hi Kurt,

    We cannot remove the validation on Save and Route / Continue. The dropdown values are validated against the possible values present in the dropdown.

     Do not force the validation using Force option value property refer screenshot below, set it to false and then remove required property using javascript.

    Hope this helps.



    ------------------------------
    Hammad Naeem
    *Precisely Software Inc.
    ------------------------------



  • 3.  RE: Javascript - Conditionally Remove Dropdown Requirement and Invalid Option Warning

    Posted 19 days ago

    Hammad,

    I appreciate the post back.

    I set Force Option Value to false and change my script to

    if (missingRegion.includes(searchItem)) {
            $form.setControlRequired('/my:myFields/my:ff_Region', false);

            $form.setValue('/my:myFields/my:ff_Region','');
        } else {
            $form.setControlRequired('/my:myFields/my:ff_Region', true);
        }

    The problem is when I submit the form it works, however in the next step the form is rejected because it's still views the Region field as a required field.

    I had to change the field to not required in order for it to flow through.

    Thanks,

    Kurt 



    ------------------------------
    Kurt Marshman
    Old World Industries, LLC
    ------------------------------