Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Repeater with Custom Query Where by Multiple Choice Form Control View modes: 
User avatar
Member
Member
justin-liquidprint - 8/14/2013 2:53:24 PM
   
Repeater with Custom Query Where by Multiple Choice Form Control
I have a document type which has a field of form control(multiple choice). The values in this column are being stored as "334|556|778" (Locations). I'm trying to use a Repeater with Custom Query web part to pull back matches against these values.

For example, I have a querystring parameter of 334. I want to match all the nodes which have a value in the Locations field matching this value.

I'm not sure how to setup my WHERE condition on the web part to handle this type of lookup.

User avatar
Member
Member
kentico_sandroj - 8/14/2013 3:32:35 PM
   
RE:Repeater with Custom Query Where by Multiple Choice Form Control
Hi Justin,

I believe you should be able to use context macros for this purpose. You may need a custom macro but you can also test something like this in the WHERE condition:
Location = '{%CurrentDocument.GetValue("Location")%}'

User avatar
Member
Member
justin-liquidprint - 8/14/2013 3:56:19 PM
   
RE:Repeater with Custom Query Where by Multiple Choice Form Control
Hi Sandroj,

Thanks for the quick response. I don't think that sample WHERE condition will work, because I'm trying to match a single ID against the list. I don't really have a problem getting back the values, just how to parse and match them correctly. But I will give the custom macro's a look see.

Thanks!

User avatar
Kentico Legend
Kentico Legend
Accepted solutionAccepted solution
Brenden Kehren - 8/15/2013 7:42:52 AM
   
RE:Repeater with Custom Query Where by Multiple Choice Form Control
Do a slight modification from what Sandro mentioned
Location LIKE '%|{%LocationID%}|%'
The resulting SQL query would look like this
Location LIKE '|%364%|'
By putting the pipes ( | ) at the beginning and end of the statement, you'll be sure you get a specific location. There could be the chance you will end up having something like 364 and 1364. This would return 2 records if you didn't have the pipes at the beginning and end. This will also require you put a URL alias on the Location page (/Location/{LocationID} for it to function properly and receive the LocationID via the querystring macro.

Read up on macros.

Good luck!

User avatar
Member
Member
justin-liquidprint - 8/15/2013 11:59:36 AM
   
RE:Repeater with Custom Query Where by Multiple Choice Form Control
Thanks FroggEye, think we're getting closer here. The only problem with the proposed solution is there may be data in the column which is not separated by a pipe. Or it might be the last record in the list, in which case it would only have a leading pipe and no trailer.

ex.
441|326
326

Any way to account for this in the WHERE condition?

Thanks!

User avatar
Certified Developer v7
Certified  Developer v7
Accepted solutionAccepted solution
atahir33-gmail - 8/15/2013 2:44:42 PM
   
RE:Repeater with Custom Query Where by Multiple Choice Form Control
@Justin,
You can try the following solution:
Select * FROM TableName
WHERE ColumnName LIKE '%|326|%' OR ColumnName = '326' OR ColumnName LIKE '%326|%' OR ColumnName LIKE '%|326%'

Thanks,
Abdel

User avatar
Member
Member
justin-liquidprint - 8/15/2013 5:03:53 PM
   
RE:Repeater with Custom Query Where by Multiple Choice Form Control
Thanks, Abdel!