0

I want to return only two columns from the entity-Check. I tried below but it doesnt work. Please note that I am using Guidewire version 10.

Query.make(entity.Check) .compare(Check#Createtime, Equals, time) .select({QuerySelectColumns.pathWithAlias("CheckNumber", Paths.make(Check#CheckNumber)), QuerySelectColumns.pathWithAlias("InvoiceNumber", Paths.make(Check#InvoiceNumber)) })?.FirstResult

Vasanth
  • 35
  • 5

2 Answers2

1

what do u mean saying it doesnot work? what doe sit return to u?

var query = Query.make(Check) .compare(ReasonCodeParametersRgs#ProductCode, Equals, "smth") .select({ QuerySelectColumns.pathWithAlias("CheckNumber", Paths.make(Check#Field1)), QuerySelectColumns.pathWithAlias("InvoiceNumber", Paths.make(Check#Field2)) })

var count: Integer = query?.FirstResult?.ColumnCount print("!!!count = " + count)

this code returns 2 if query got any rows and 0 if query is empty. I've checked it with different entity and conditions

1

You can use below snippet.

var conQuery = Query.make(Person).select(\row -> new String[]{row.FirstName, row.LastName}) print(conQuery.first()) //just prints first row

Here the return type of conQuery will be IQueryBeanResult<String[]>. Each returned row will contain array of String with FirstName and LastName.

If only FirstName needed, use => select(\row -> row.FirstName)

Dharman
  • 30,962
  • 25
  • 85
  • 135