Recently working with Sitecore, I had a scenario where I was trying to set a filter key and value to pass to Sitecore Search from XM Cloud via rendering parameter. I have a rendering that gets back search results, but the client wanted to sometimes restrict those by a certain field to a certain value. Since we have all those taxonomy values in Sitecore, we hooked up both key and value as droplink fields. Which makes sense, because you don't want to lose track of the item if it moves.
Here's the catch...by default, Sitecore Search doesn't capture IDs, but textual values. Well, you can make it capture what you want with the API Push, but you don't want to throw everything in necessarily. Plus by default, you're going to think of getting the textual value in case you want to use it for faceting somewhere else. So you need the name (or display name, or a value in a field) back instead. But by default (a lot of that "default" going around!) you get just the ID in a rendering parameter.
Enter this Sitecore setting value: LayoutService.DetailedRenderingParams. If you set this to true, then your Edge output will show the custom field output automatically in the spot for the rendering parameters instead of the ID. So there you go, an easy mapping, you get whatever value you need, and you're off to the races!
Well...close. So close. What if you actually do need the ID of the item? Or its name or path? Unfortunately, those aren't available in the output. Why I'm not sure, but I had another scenario where I was taking that droplink ID and passing it to an API call for another purpose. If I can't have it both ways, I have to defer to what data I can get (the ID) and get the other data I want another way. In my case, I switched to droplist for the key and text for the value, for now at least. I do have a feature request in for adding these basic values with Sitecore, so hopefully we'll see this become more complete soon.
An additional reminder, if you turn this feature on, it'll be on for all rendering parameters. You'll want to make sure you review any "link" field types you've used (droplink, treelink, etc etc) for how you're using that parameter value. Even after the ID is added, it won't be as simple as just getting the parameter anymore and having the value, you'll need to map to a model to pop about that ID. So definitely do your regression testing!
Top comments (0)