Set the form view for Search Screen's result

s12345
Giga Contributor

I'm working on a custom application. In Studio, I've created a "Search Screen" module so users can search within the app. I've also created a form view that I want to be used for the initial search form only.

In the Search Screen module's settings, I set 'View name' to the name of my view ("app_search"). This works for setting the initial search form. But! After I perform a search and open up a record, that record also uses the view ("app_search"). I want it to use the default view.

How can I configure records opened from my Search Screen module to use the default view, rather than the custom view used in the initial search?

Note: I've already read this documentation, which cryptically says, "Use the parameter &sysparm_result_view=view_name to define the view the results are rendered in." But there's no 'parameter' field in Studio... I've tried putting it in a few different fields but nothing seems to have any effect.

Thanks!

1 ACCEPTED SOLUTION

s12345
Giga Contributor

I've figured out a solution.

As I mentioned, a line in the documentation says, "Use the parameter &sysparm_result_view=view_name to define the view the results are rendered in." ...but when you're configuring a Search Screen module in Studio, there's no field for setting URL parameters! So what you have to do is change the module to be a custom URL From Arguments, then reverse-engineer what your URL should be.

For me, my final configuration looked like this:

  • Link type: URL (from Arguments:)
  • Table: [my table name]
  • View name: [view for initial search]
  • Arguments: [my table name]_search.do?sysparm_view=[view for initial search]&sysparm_result_view=[view for results]

Once I made this change, everything worked like I wanted.

I'd 100% describe this as a failing in the documentation. The docs should say: If you want to control the results view, you have to switch to a custom URL module. Alternatively, ServiceNow should let you set the sysparm_result_view parameter within the Search Screen config.

View solution in original post

2 REPLIES 2

s12345
Giga Contributor

I've figured out a solution.

As I mentioned, a line in the documentation says, "Use the parameter &sysparm_result_view=view_name to define the view the results are rendered in." ...but when you're configuring a Search Screen module in Studio, there's no field for setting URL parameters! So what you have to do is change the module to be a custom URL From Arguments, then reverse-engineer what your URL should be.

For me, my final configuration looked like this:

  • Link type: URL (from Arguments:)
  • Table: [my table name]
  • View name: [view for initial search]
  • Arguments: [my table name]_search.do?sysparm_view=[view for initial search]&sysparm_result_view=[view for results]

Once I made this change, everything worked like I wanted.

I'd 100% describe this as a failing in the documentation. The docs should say: If you want to control the results view, you have to switch to a custom URL module. Alternatively, ServiceNow should let you set the sysparm_result_view parameter within the Search Screen config.

fpoth
Tera Contributor

Does anyone know of a way to also set the default query method? It appears to default to "starts with", but I would like to change it to "contains". For example, if I go to /incident_search.do and fill in the number field, the query will look like: numberSTARTSWITHINC0009009. I was wondering if I could achieve this with URL parameters, but I am open to any method that can achieve this.