Reputation: 89
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
Upvotes: 0
Views: 852
Reputation: 41
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)
Upvotes: 1
Reputation: 75
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
Upvotes: 1