cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Service Layer API filter - operator 'like' does not work properly

MatLakaemper
Participant
0 Likes
1,286

Hi,

i am encountering a Problem in SAP-BusinessOne 10 FP2502

The like-Expression does not work.

I think this is a bug.

kind Regards,
Matthias Lakämper

----------------------------------------------------------------------------------------------------------

 

GET {{SboServicelayerHost}}Orders?$select=CardCode,DocNum,CardName&$filter=CardName like '002%'
Content-Type: application/json
Cookie: : {{SboServicelayerSessionId}}
Cache-Control: no-cache
Accept: application/json
###
 
{ "error": { "code": "201", "details": [ { "code": "", "message": "" } ], "message": "Query string error - Invalid filter condition" } }

 

MatLakaemper_0-1743683186470.png

 

Accepted Solutions (0)

Answers (2)

Answers (2)

williamwachholz
Active Participant

Hello,

You can use the SQLQueries entity, you have more possibilites to work with queries.

Here is a sample:

You send a POST to the endpoint b1s/v1/SQLQueries

The payload:

{
"SqlCode": "Demo_Q1",
"SqlName": "Demo - list of Salesorder",
"SqlText": "SELECT T0.[DocNum],T0.[DocDate], T0.[DocDueDate], T0.[CreateDate] FROM ORDR T0 WHERE T0.[CardName] like '002%' order by T0.[Createdate] desc"
}

It will create the query with ID "Demo_Q1. You can then list the result by sending a POST to the endpoint  b1s/v1/SQLQueries('Demo_Q1')/List

 

Best regards

MatLakaemper
Participant
0 Likes

Hello William,

thank you for your Answer, i know that possibility.

But i need the functionality within CAP-Sql

eg. cds-repl-Command: (Standard for Odata).

qx = B1Svl.run(SELECT.columns('CardCode', 'DocNum').from('B1Svl.Orders').where `CardName like '001%' `

and here i get the error...

So my opinion is, that is a bug and should be fixed.

Kind Regards,
Matthias

MatLakaemper_0-1743698459474.png

 

 

Johan_Hakkesteegt
Active Contributor
0 Likes
This has a missing quote, can that be it?: qx = B1Svl.run(SELECT.columns('CardCode', 'DocNum').from('B1Svl.Orders').where `CardName like '001%' `
MatLakaemper
Participant
0 Likes

Hi,

there is no missing quote, it was on the next line... but indeed the closing bracket was missing.

kind Regards
Matthnias

qx = B1Svl.run(SELECT.columns('CardCode', 'DocNum').from('B1Svl.Orders').where `CardName like '001%' `)

 

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi MatLakaemper,

It appears that Service Layer does not support like operator.

https://help.sap.com/docs/SAP_BUSINESS_ONE/f110a154dd0f4c20bf7f3ebca9eeb794/3e5b7d980d99493f92718474... 

Kind regards,

ANKIT CHAUHAN

SAP Business One Support

 

MatLakaemper
Participant

Hi Ankit,

thanks for the link,

so the solution is:

GET {{SboServicelayerHost}}Orders?$select=CardCode,DocNum,CardName&$filter=startswith(CardName, 'W')
GET {{SboServicelayerHost}}Orders?$select=CardCode,DocNum,CardName&$filter=contains(CardName, 'Way')

that works for me.

kind Regards,
Matthias