Content Management and Capture

Content Management and Capture

Come for answers. Stay for best practices. All we’re missing is you.

 View Only
  • 1.  Search Button Enable/Disable in Search Template using plugin

    Posted Tue July 06, 2021 05:45 AM

    Hi All,

    Requirement: I have a search template with 10 mandatory fields. Search button is enabled only when all 10 mandatory fields values entered. My requirement is to enable search button if any one of the mandatory field value is entered. This requirement I want to do using global plug-in.

    What I have Tried: I have tried below code in global plug-in. Imported required js files.

    aspect.after(ecm.model.SearchCriterion.prototype, "onValueChange", function() {

    if(this.value.length>0 && this.valueRequired){

    this.searchButton.set("disabled", false);

    }

    });

    Output: Using above code I could able to check whether mandatory field value is entered. But the search button is not enabled.

    Can you please suggest any solution.



    #IBMContentNavigator(ICN)
    #Support
    #SupportMigration


  • 2.  RE: Search Button Enable/Disable in Search Template using plugin
    Best Answer

    Posted Tue July 06, 2021 09:48 AM

    Hi,

    You may try

    aspect.after(ecm.widget.search.SearchForm.prototype, "onCriterionValidate", function() {

    for (var i = 0; i < this._propertyEditors._fields.length; i++) {

    var field = this._propertyEditors._fields[i];

    if (this._propertyEditors._isFieldValid(field) && field.required && field.textbox.value.length > 0) {

    this.searchButton.set("disabled", false);

    break;

    }

    }

    })

    Please note that this requirement is inconsistent with ICN search validation, and referencing private methods/properties in plugin is not recommended. I suggest contact your support and raise an enhancement for this requirement.



    #IBMContentNavigator(ICN)
    #Support
    #SupportMigration


  • 3.  RE: Search Button Enable/Disable in Search Template using plugin
    Best Answer

    Posted Tue July 06, 2021 12:29 PM

    Hi,


    It worked. But when I click on Search it's again doing the validation and asking to enter all mandatory fields. Do you have any idea how to proceed with search with minimum one mandatory field value.


    Regards,

    Ravi



    #IBMContentNavigator(ICN)
    #Support
    #SupportMigration


  • 4.  RE: Search Button Enable/Disable in Search Template using plugin
    Best Answer

    Posted Wed July 07, 2021 03:30 AM

    Hi,

    Overwriting the validation logic may cause unexpected problems. I suggest setting the fields as not required, and enable/disable the search button when one of the fields is non-empty. Here is an example:

    aspect.after(ecm.widget.search.SearchForm.prototype, "onCriterionValidate", function() {

    var disabled = true;

    for (var i = 0; i < this._propertyEditors._fields.length; i++) {

    var field = this._propertyEditors._fields[i];

    if (this._propertyEditors._isFieldValid(field) && field.textbox.value.length > 0 && i < 3) {

    disabled = false;

    break;

    }

    }

    this.searchButton.set("disabled", disabled);

    })



    #IBMContentNavigator(ICN)
    #Support
    #SupportMigration


  • 5.  RE: Search Button Enable/Disable in Search Template using plugin
    Best Answer

    Posted Wed July 21, 2021 03:35 PM

    Hi,


    It is working absolutely fine. But I noticed one issue. If I enter value in one field and click on another field to enter value, the control is going to previous field again. I have to click two times if I want to enter value in another field.


    Do you have any idea?



    #IBMContentNavigator(ICN)
    #Support
    #SupportMigration


  • 6.  RE: Search Button Enable/Disable in Search Template using plugin
    Best Answer

    Posted Thu July 22, 2021 03:29 PM

    Hi,

    Ignore the above issue. This is because of EDS in my application. So everything works as expected. Thanks a lot :-).



    #IBMContentNavigator(ICN)
    #Support
    #SupportMigration