Can we use method in GenericDelegator that does query using both 'and' and like operator...
I have a table Sales_Level which contains fields SALES_LEVEL_ID, NAME, DESCRIPTION, LOB, CHANNEL_CODE, and INCENTIVE. i want to select sales level with lob=A, channelCode=1, incentive=Y, and salesLevelId like LC. |
aa.. there is one thing I forgot to mention.. i try to display this query in ftl. so i put this line on top of the ftl file:
<#assign salesLevelsList = delegator.findByLike("SalesLevel", Static["org.ofbiz.base.util.UtilMisc"].toMap("lob","A","channelCode","1", "incentive","Y", "salesLevelId","%LC"), Static["org.ofbiz.base.util.UtilMisc"].toList("salesLevelId","name"))> and it doesn't work... note: the sales level id's i want to select is AL_ELC and AL_LC
|
In reply to this post by nashrul
Hi Nashrul
Try this: delegator.findByAnd("SalesLevel", UtilMisc.toList( new EntityExpr("lob", EntityOperator.EQUALS, "A"), new EntityExpr("channelCode", EntityOperator.EQUALS, "1"), new EntityExpr("incentive", EntityOperator.EQUALS, "Y"), new EntityExpr("salesLevelId", EntityOperator.LIKE, "LC"))); Regards Scott On 16/08/07, nashrul <[hidden email]> wrote: > > > Can we use method in GenericDelegator that does query using both 'and' and > like operator... > I have a table Sales_Level which contains fields SALES_LEVEL_ID, NAME, > DESCRIPTION, LOB, CHANNEL_CODE, and INCENTIVE. i want to select sales > level > with lob=A, channelCode=1, incentive=Y, and salesLevelId like LC. > -- > View this message in context: > http://www.nabble.com/query-combining-and-and-like-tf4278148.html#a12177156 > Sent from the OFBiz - User mailing list archive at Nabble.com. > > |
Hi scott..
I did as what you advised me, but it produces error.. "Error parsing included template tblDsMaster.ftl Encountered "EntityExpr" at line 19, column 82. Was expecting one of: ".." ... "=" ... "==" ... "!=" ... ... ... ... ... "," ... ")" ... ">" ... ">=" ... "." ... "[" ... "(" ... "?" ... "+" ." etc As I wrote before, I try to do this: <#assign salesLevelsList = delegator.findByLike("SalesLevel", Static["org.ofbiz.base.util.UtilMisc"].toMap("lob","A","channelCode","1", "incentive","Y", "salesLevelId","%LC"), Static["org.ofbiz.base.util.UtilMisc"].toList("salesLevelId","name"))> and i use salesLevelList to do iteration and display the result in ftl: <#assign iter=1> <#list salesLevelsList as s> .....more codes <#assign iter=iter+1> </#list>
|
You'd be better off preparing your data in a bsh script beforehand rather
than attempting to prepare and display in an ftl. Regards Scott On 16/08/07, nashrul <[hidden email]> wrote: > > > Hi scott.. > I did as what you advised me, but it produces error.. > "Error parsing included template tblDsMaster.ftl Encountered "EntityExpr" > at > line 19, column 82. Was expecting one of: ".." ... "=" ... "==" ... "!=" > ... > ... ... ... ... "," ... ")" ... ">" ... ">=" ... "." ... "[" ... "(" > ... > "?" ... "+" ." etc > As I wrote before, I try to do this: > > <#assign salesLevelsList = delegator.findByLike("SalesLevel", > Static["org.ofbiz.base.util.UtilMisc"].toMap("lob","A","channelCode","1", > "incentive","Y", "salesLevelId","%LC"), > Static["org.ofbiz.base.util.UtilMisc"].toList("salesLevelId","name"))> > > and i use salesLevelList to do iteration and display the result in ftl: > > <#assign iter=1> > <#list salesLevelsList as s> > .....more codes > <#assign iter=iter+1> > </#list> > > > Scott Gray wrote: > > > > Hi Nashrul > > > > Try this: > > delegator.findByAnd("SalesLevel", UtilMisc.toList( > > new EntityExpr("lob", EntityOperator.EQUALS, "A"), > > new EntityExpr("channelCode", EntityOperator.EQUALS, > > "1"), > > new EntityExpr("incentive", EntityOperator.EQUALS, > > "Y"), > > new EntityExpr("salesLevelId", EntityOperator.LIKE, > > "LC"))); > > > > Regards > > Scott > > > > On 16/08/07, nashrul <[hidden email]> wrote: > >> > >> > >> Can we use method in GenericDelegator that does query using both 'and' > >> and > >> like operator... > >> I have a table Sales_Level which contains fields SALES_LEVEL_ID, NAME, > >> DESCRIPTION, LOB, CHANNEL_CODE, and INCENTIVE. i want to select sales > >> level > >> with lob=A, channelCode=1, incentive=Y, and salesLevelId like LC. > >> -- > >> View this message in context: > >> > http://www.nabble.com/query-combining-and-and-like-tf4278148.html#a12177156 > >> Sent from the OFBiz - User mailing list archive at Nabble.com. > >> > >> > > > > > > -- > View this message in context: > http://www.nabble.com/query-combining-and-and-like-tf4278148.html#a12177860 > Sent from the OFBiz - User mailing list archive at Nabble.com. > > |
Use index attribute:
<#list salesLevelsList as s> s.index </#list> 2007/8/16, Scott Gray <[hidden email]>: > > You'd be better off preparing your data in a bsh script beforehand rather > than attempting to prepare and display in an ftl. > > Regards > Scott > > On 16/08/07, nashrul <[hidden email]> wrote: > > > > > > Hi scott.. > > I did as what you advised me, but it produces error.. > > "Error parsing included template tblDsMaster.ftl Encountered > "EntityExpr" > > at > > line 19, column 82. Was expecting one of: ".." ... "=" ... "==" ... "!=" > > ... > > ... ... ... ... "," ... ")" ... ">" ... ">=" ... "." ... "[" ... "(" > > ... > > "?" ... "+" ." etc > > As I wrote before, I try to do this: > > > > <#assign salesLevelsList = delegator.findByLike("SalesLevel", > > Static["org.ofbiz.base.util.UtilMisc > "].toMap("lob","A","channelCode","1", > > "incentive","Y", "salesLevelId","%LC"), > > Static["org.ofbiz.base.util.UtilMisc"].toList("salesLevelId","name"))> > > > > and i use salesLevelList to do iteration and display the result in ftl: > > > > <#assign iter=1> > > <#list salesLevelsList as s> > > .....more codes > > <#assign iter=iter+1> > > </#list> > > > > > > Scott Gray wrote: > > > > > > Hi Nashrul > > > > > > Try this: > > > delegator.findByAnd("SalesLevel", UtilMisc.toList( > > > new EntityExpr("lob", EntityOperator.EQUALS, "A"), > > > new EntityExpr("channelCode", > EntityOperator.EQUALS, > > > "1"), > > > new EntityExpr("incentive", EntityOperator.EQUALS, > > > "Y"), > > > new EntityExpr("salesLevelId", EntityOperator.LIKE > , > > > "LC"))); > > > > > > Regards > > > Scott > > > > > > On 16/08/07, nashrul <[hidden email]> wrote: > > >> > > >> > > >> Can we use method in GenericDelegator that does query using both > 'and' > > >> and > > >> like operator... > > >> I have a table Sales_Level which contains fields SALES_LEVEL_ID, > NAME, > > >> DESCRIPTION, LOB, CHANNEL_CODE, and INCENTIVE. i want to select sales > > >> level > > >> with lob=A, channelCode=1, incentive=Y, and salesLevelId like LC. > > >> -- > > >> View this message in context: > > >> > > > http://www.nabble.com/query-combining-and-and-like-tf4278148.html#a12177156 > > >> Sent from the OFBiz - User mailing list archive at Nabble.com. > > >> > > >> > > > > > > > > > > -- > > View this message in context: > > > http://www.nabble.com/query-combining-and-and-like-tf4278148.html#a12177860 > > Sent from the OFBiz - User mailing list archive at Nabble.com. > > > > > |
Free forum by Nabble | Edit this page |