guidewiregosu

How to select specific columns alone using Query.make()


In guidewire, Query.make(EntityName).select() returns the entire column values, How should be the code if I need column specific result.

For eg, If I just need PolicyNumber , PublicID and ID alone from Policy table, How should I write the code?


Solution

  • var op = Query.make(PolicyPeriod).select({
        QuerySelectColumns.pathWithAlias("PolicyNumber", Paths.make(PolicyPeriod#PolicyNumber)),
        QuerySelectColumns.pathWithAlias("OfferNumber", Paths.make(PolicyPeriod#OfferNumber)),
        QuerySelectColumns.pathWithAlias("Id", Paths.make(PolicyPeriod#ID))
    })
    
    foreach(o in op){
      print(" Policy No : "+o.getColumn("PolicyNumber") +" | Offer No : "+o.getColumn("OfferNumber")+" | ID : "+o.getColumn("Id"))
    }
    

    enter image description here