0

If we need to consider two states of claim (e.g - Draft & Closed state) for temporary claim, then how can we use these state using Query? I tried with -

var claims = Query.startswith("ClaimNumber", "TMP", false)
.compareIn(Claim#State, {ClaimState.TC_DRAFT, ClaimState.TC_CLOSED}.toArray())
.select()

The above line throws null pointer error . Could anyone help on this ?

Sergiy Ostrovsky
  • 2,372
  • 2
  • 16
  • 23

3 Answers3

1

I believe the Claim Entity has enough data to be queried.

Also i see the "make" statement is missing in the code given by you. Try the below query in your Gosu Scratchpad,

uses gw.api.database.Query
var claims = Query.make(Claim)
  .startsWith("ClaimNumber","TMP",false)
  .compareIn(Claim#State, {ClaimState.TC_DRAFT, ClaimState.TC_CLOSED} as ClaimState[])
  .select()

for(claim in claims){
 print(claim.ClaimNumber)
}

If you still face any issues, please provide the exception that you get.

Please mark the answer as correct if my info solved your issue.

Arun Kumar Mani
  • 337
  • 2
  • 7
1

Try with or block,

uses gw.api.database.Query
 var queryCliamState= Query.make(entity.Claim)
          .compare("ClaimNumber", Equals, "12345")
         .or(\orCondition -> {
              orCondition.compare("State" , Equals,typekey.ClaimState.TC_DRAFT)
              orCondition.compare("State" , Equals,typekey.ClaimState.TC_CLOSED)
 }) .select()

-When you are comparing make sure the state is equal to the database field.

Py-Coder
  • 2,024
  • 1
  • 22
  • 28
0

Looks like you are missing the make sentence:

var claims = Query.make(Claim).startsWith("ClaimNumber", "TMP", false)
    .compareIn(Claim#State, {ClaimState.TC_DRAFT, ClaimState.TC_CLOSED}.toArray())
    .select()

It should work after that.

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
robertant
  • 98
  • 7