Quantcast
Viewing all articles
Browse latest Browse all 6517

Commented Issue: SPDisplayRelatedInfo not working with matchOnId: true [10134]

From: http://spservices.codeplex.com/discussions/346508

Did anyone get this figured out? I have run into the same issue. Using 'matchOnId: true' causes the function to return 0 items. I believe I have the solution. I'm using SPServices 0.7.1a so if this has already been fixed in later releases, my apologies.

Looking at line ~1739, we're creating a query string as...

```
camlQuery += "<Eq><FieldRef Name='" + opt.relatedListColumn +
(opt.matchOnId ? "' LookupId='True'/><Value Type='Integer'>" : "'/><Value Type='Text'>") +
escapeColumnValue(columnSelectSelected[0]) + "</Value></Eq>";
```
When matchOnId = true, I beleive we should be filtering on the ID field of the target list and not the opt.relatedListColumn. So, I modified the source code to look like this....

```
camlQuery += "<Eq><FieldRef Name='" +
(opt.matchOnId ? "ID' /><Value Type='Integer'>" : opt.relatedListColumn + "'/><Value Type='Text'>") +
escapeColumnValue(columnSelectSelected[0]) + "</Value></Eq>";
```
I believe this comes up in other places in the code but I haven't gone through it. I wanted to get a second look at my madness before I press on.

Thanks,

Geoff

Comments: Fix in place in 2013.01ALPHA06. There were several ancillary changes, but here's the meat of it. // Need to handle Lookup columns differently than static columns var relatedListColumnType = relatedColumnsXML[opt.relatedListColumn].attr("Type"); if(relatedListColumnType === "Lookup") { camlQuery += "<Eq><FieldRef Name='" + opt.relatedListColumn + (opt.matchOnId ? "' LookupId='True'/><Value Type='Integer'>" : "'/><Value Type='Text'>") + escapeColumnValue(columnSelectSelected[0]) + "</Value></Eq>"; } else { camlQuery += "<Eq><FieldRef Name='" + (opt.matchOnId ? "ID' /><Value Type='Counter'>" : opt.relatedListColumn + "'/><Value Type='Text'>") + escapeColumnValue(columnSelectSelected[0]) + "</Value></Eq>"; };

Viewing all articles
Browse latest Browse all 6517

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>