Search Widget not working

2377
3
Jump to solution
06-06-2019 11:25 AM
JamesAgidius
New Contributor III

Hello,

I have been working on this application, (using the Javascript API), but I have encountered a slight problem.

One of the widgets (Search Widget with multiple sources) doesn't seem to function, although it is present/visible (all of the other widgets seem to be working as intended).

I see no errors in fiddler or console, but it definitely doesn't search..

I am not very proficient, and I was wondering if anybody might have any insight? I have attached the entire file (below) in the hopes that somebody might have the time to take a look.

Thank you in advance.

-James

1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

James,

  Your issue is that the sources property is called layer and not featureLayer anymore as it was in previous versions.

var searchWidget = new Search({
        view: view,
        includeDefaultSources: false,
        locationEnabled: false,
        sources: [{
          layer: Parcels,
          searchFields: ["PM_PAR_14"],
          displayField: "PM_PAR_14",
          exactMatch: false,
          outFields: ["PARCEL_ID"],
          name: "Parcel Number",
          placeholder: "example: RP40N02W162502",
        }, {
          layer: Parcels,
          searchFields: ["PM_MAIL_NM"],
          displayField: "PM_MAIL_NM",
          exactMatch: false,
          outFields: ["PM_MAIL_NM"],
          name: "Last Name, First Name",
          placeholder: "example: Doe, John",
        }, {
          layer: Addresses,
          searchFields: ["FULLADDRSS"],
          exactMatch: false,
          outFields: ["*"],
          name: "Address",
        }, {
          layer: Actions,
          searchFields: ["LABEL"],
          exactMatch: false,
          outFields: ["*"],
          name: "Land Use Action",
        }, {
          featureLayer: Divisions,
          searchFields: ["LD_Number"],
          exactMatch: false,
          outFields: ["*"],
          name: "Land Division",
        }]
      });

View solution in original post

3 Replies
RobertScheitlin__GISP
MVP Emeritus

James,

  Your issue is that the sources property is called layer and not featureLayer anymore as it was in previous versions.

var searchWidget = new Search({
        view: view,
        includeDefaultSources: false,
        locationEnabled: false,
        sources: [{
          layer: Parcels,
          searchFields: ["PM_PAR_14"],
          displayField: "PM_PAR_14",
          exactMatch: false,
          outFields: ["PARCEL_ID"],
          name: "Parcel Number",
          placeholder: "example: RP40N02W162502",
        }, {
          layer: Parcels,
          searchFields: ["PM_MAIL_NM"],
          displayField: "PM_MAIL_NM",
          exactMatch: false,
          outFields: ["PM_MAIL_NM"],
          name: "Last Name, First Name",
          placeholder: "example: Doe, John",
        }, {
          layer: Addresses,
          searchFields: ["FULLADDRSS"],
          exactMatch: false,
          outFields: ["*"],
          name: "Address",
        }, {
          layer: Actions,
          searchFields: ["LABEL"],
          exactMatch: false,
          outFields: ["*"],
          name: "Land Use Action",
        }, {
          featureLayer: Divisions,
          searchFields: ["LD_Number"],
          exactMatch: false,
          outFields: ["*"],
          name: "Land Division",
        }]
      });
JamesAgidius
New Contributor III

Thank you Robert. That did the trick.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

James,

   No problem. Normally you would want the mark the reply that answered your question as the correct answer and not your reply to my correct answer.

0 Kudos