Skip to main content
  1. Posts/

When to use Named Search Spec?

·2 mins

Named Search Specification is a powerful little feature that is hidden away. It enables you to programmatically set the search specification relation to that cannot be cleared from the UI.

All you need to do is write the following piece of code in your script -

function BusComp_PreQuery ()
{
   if (TheApplication().GetProfileAttr("Position Type") == "External Partner") {
      this.SetNamedSearch ("External Partner", "[Type] <> 'Internal'");
   
   return (ContinueOperation);
}

The above example shows the named search specification set in the PreQuery event.

Once this is executed, external partners cannot see records of type “Internal”.

You use a named search specification when you do not want any of the user queries to clear the filter criteria that has already been set through the script. The predefined search criteria will be applied to any user initiated queries - maybe through PDQ, new search, and even after navigation across screens.

Once defined the named service specification is applicable for that instance of the business component. It may be applicable when the BC is being instantiated through Applets, Picklists, scripts or from any other object.

Alternate ways of setting filter criteria like SetSearchSpec, SetSearchExpr will be cleared once the user hits the “query” button, or selects a PDQ.

You can clear the named such specification by retrieving the name of the search spec, and clearing it explicitly.

You can retrieve the server specification for future programmatic uses by using the following statement-

bcOpty.GetNamedSearch ("External Partner");