a!queryEntity( entity: cons!WMG_GBL_DB_ENTITY_CATEGORY_SETTINGS, query: a!query( selection: a!querySelection( columns: { a!queryColumn( field: "id" ), a!queryColumn( field: "xmlDocId" ), a!queryColumn( field: "xmlDocName" ), a!queryColumn( field: "categoryName" ), a!queryColumn( field: "entityType" ), a!queryColumn( field: "accountType" ), a!queryColumn( field: "productType" ) } ), logicalExpression: a!queryLogicalExpression( operator: "AND", filters: { a!queryFilter( field: "id", operator: "not null" ), if( ri!kycOrKya_txt = "KYC", { if( rule!APN_isBlank( ri!entityType_txt ), null, a!queryFilter( field: "entityType", operator: "=", value: ri!entityType_txt ) ) }, null ), if( rule!APN_isBlank( ri!naics_txt ), null, { logicalExpressions: { a!queryLogicalExpression( operator: "OR", filters: { a!queryFilter( field: "naics", operator: "=", value: ri!naics_txt ), a!queryFilter( field: "naics", operator: "=", value: ri!naics_txt ) } ) } } ) } ), pagingInfo: a!pagingInfo( startIndex: 1, batchSize: 100, sort: a!sortInfo( field: "xmlDocName", ascending: true ) ) ) ).data