Try our conversational search powered by Generative AI!

Possible ISelectionQuery bug for GetItemByValue

Vote:
 

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?

#204921
Jun 20, 2019 20:42
Vote:
 

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; }
}
#204922
Jun 20, 2019 20:47
Vote:
 

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.

#204923
Edited, Jun 20, 2019 22:38
Vote:
 

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"}

#204924
Jun 20, 2019 23:29
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.