Fetch corda transaction from Ledger based on query condition

(Jayant) #1

Hi ,
I want to fetch corda transaction from ledger based on some condition.
e.g. my transaction contains property like userId or Date .
so how can I fetch transaction or filter the data based on date or userId or any perperty of my transacion.

I can see only below code in purchase order example which actually fetches all the data.
I want to apply filter here …


Can anyone help in this regard.

(Srinidhi) #2

public List getPurchaseOrdersOnCondition(@PathParam(“conditionField”) String conditionField) {
List matchedStates= new ArrayList();
services.vaultAndUpdates().getFirst().forEach(contractStateStateAndRef -> {
YourStatestate = (YourState) contractStateStateAndRef.getState().getData();
return matchedStates;