Here's a snippet of the block class to show my usage of the selection query:
public class StaffMemberBlock : BlockData {
[Display(Name = "Staff Search", GroupName = SystemTabNames.Content, Order = 10)]
[AutoSuggestSelection(typeof(StaffMemberSelectionQuery))]
public virtual string Id { get; set; }
}
Hi Matthew,
Are you able to give an example of the Id string value?
The value is fetched via a GET request to the SelectionQueryStore (/episerver/Shell/stores/selectionquery
), can you take a look at what response you're getting from that (your request will look something like: /
episerver/Shell/stores/selectionquery/StaffMemberSelectionQuery/123
)? Using some unsafe URL characters in the LineItem value can ultimately screw this up and might cause the behaviour you're seeing.
Found the issue! A rewrite rule in my web config was adding a trailing slash, which that store does handle as I expected.
I checked the network requests from the web inspector and found this GET for /EPiServer/Shell/stores/selectionquery/PublicWebsite.Models.SelectionQueries.StaffMemberSelectionQuery/brian-m-wicklund/ which returns
{}&&{"name":"","id":""}
After removing the rule the request became /EPiServer/Shell/stores/selectionquery/PublicWebsite.Models.SelectionQueries.StaffMemberSelectionQuery/brian-m-wicklund which returns
{}&&{"name":"Wicklund, Brian M.","id":"brian-m-wicklund"}
I've implemented ISelectionQuery to provide a select items from an API. The GetItems query works and sets the property on my block, but when loading that block again the lookup is blank, even though the value is set.
I've ran this in a debugger and found that GetItemByValue always has a value of empty string rather than the string value stored in the property.
Is this a bug?