简体   繁体   中英

Gosu (Guidewire)

If we need to consider two states of claim (eg - 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?

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM