Keywords

query

The query keyword is used to interact with query objects inside SAP Business One.

The query modes are:

  • run - This is the default mode. This mode will look for the query and execute it against the SAP Business One company database.

    Syntax: [/<optional-profile>]/query/<query-name>.aspx.

    Example (default profile): /query/salesorder.aspx

    Example (“myCompany” profile): /myCompany/query/salesorder.aspx

  • def - returns the SQL syntax of the specified query. Syntax: [/<optional-profile>]/query/<query-name>/def.aspx.

    Example (default profile): /query/salesorder/def.aspx

    Example (“myCompany” profile): /myCompany/query/salesorder/def.aspx

queryscalar

The queryscalar URL keyword is used to accept query parameters via an XML posting. These parameters will be included in the HTML POST that is received. An example would be the yahoo stores real time inventory integration that passes a string in the POST, for example: .catalog=yhst-79125732853272&.id=_my_item_&.code=_my_code_.

If your query contains a parameter called CARDCODE, then when you call the B1WebAPI web service you will need to pass a URL parameter called CARDCODE and a data value which will be executed with the query. Additional parameters must be followed with an & character.

When creating your query in B1 remember the parameter syntax should be as follows: [%cardcode].

queries

The queries URL keyword is used to retrieve the list of queries configured in SAP Business One that are contained inside a B1WebAPI category.

  • Default B1WebAPI category queries - This mode returns a list of queries available in the default B1WebAPI query category in SAP Business One.

    Syntax: [/<optional-profile>]/queries.aspx

  • Specified B1WebAPI category queries - This mode returns a list of queries available in the specified B1WebAPI query category in SAP Business One, such as B1WebAPI_CP for Customer Portal queries.

    Syntax: [/<optional-profile>]/queries/<query-sub-category>.aspx

    Example (default profile): /queries/CP.aspx returns all B1WebAPI_CP category queries, while /queries/OP.aspx returns all B1WebAPI_OP category queries. All queries relate to the default (first) B1WebAPI company profile.

    Example (“myCompany” profile): /myCompany/queries/CP.aspx returns all B1WebAPI_CP category queries for the company specified in the “myCompany” B1WebAPI profile, while /profile/queries/OP.aspx returns all B1WebAPI_OP category queries for the company specified in the “myCompany” B1WebAPI profile.

Testing Queries

You can review queries and their results using B1WebAPI.

  • Connect to B1WebAPI, typically installed on the SAP Business One server, usually at http://localhost:4033/index.aspx.
  • Navigate to Test Queries, typically http://localhost:4033/test.aspx
  • Select the desired query and load it. Select the Application and Query, then press the “Load Definition” button to load the query.

    Select the Application (1) and Query (2), then load the query (3).
    Select the Application (1) and Query (2), then load the query (3).
  • Review the query.

    Review the Query (1), then test the query results by completing parameters (2) and selecting the desired data type (3). Press Run Query to load the qurey results for the specified paramters.
    Review the Query (1), then test the query results by completing parameters (2) and selecting the desired data type (3). Press Run Query to load the qurey results for the specified paramters.
  • Load query results by entering the query parameters and running the query (see screenshot above). Results will be displayed as shown below. You may link to these query results directly by using the link provided by the query results.

    View query results (1) and link directly to those results (2).
    View query results (1) and link directly to those results (2).