Different search APIs for different advanced search form

Showing results for 
Search instead for 
Did you mean: 
Established Member

Different search APIs for different advanced search form

Hi everyone,

I am trying to use 2 different APIs for advanced search. When user selects the search form based on Aspect/Type (Look for Dropdown in Advanced Search page) and the fills the appropriate fields in then form fields and cliclks the search button, it should give the result based on the selected form.

Let's say we have 4 custom forms created, and user has searched for Form 1 and Form 2, then it should call custom webscript, otherwise OOTB advanced search should be executed. 

In advsearch.js file, I am able to get the form Id but I'm not sure how to move ahed further to call custom webscript in if condition and OOTB in else condition.


Here is the changes I made in advsearch.js file to get form Id.

onSearchClick: function ADVSearch_onSearchClick(e, obj)
         // retrieve form data structure directly from the runtime
         var formData = this.currentForm.runtime.getFormData();
         // add DD type to form data structure
         formData.datatype = this.currentForm.type;
		 //Custom Code to get Aspect name / Form Id
		 var aspectName = this.currentForm.id;
		 console.log("--------Form Id / Aspect Name---------" + aspectName);
		 if(aspectName == "CustomAspect1SearchForm" || aspectName == "CustomAspect2SearchForm"){
			 console.log("It is scenario 2");
			 console.log("It is normal scenario");
         // build and execute url for search page
         // 'this.options.searchPath' contains {variable} replacement points for substitution
         var url = YAHOO.lang.substitute(Alfresco.constants.URL_PAGECONTEXT + this.options.searchPath,
            site: (this.options.siteId.length !== 0 ? ("site/" + this.options.siteId + "/") : ""),
            terms: encodeURIComponent(Dom.get(this.id + "-search-text").value),
            query: encodeURIComponent(YAHOO.lang.JSON.stringify(formData)),
            scope: this.options.searchScope.toString()
         window.location.href = url;