Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Search within the drop down in edit mode.

Vote:
 

How can I create a selection factory with seach option in cms edit view

#312684
Nov 17, 2023 5:36
Vote:
 

Can you provide bit more detail on what you are trying to achieve ? Maybe some screenshots / diagrams so we can better understand 

#312691
Nov 17, 2023 10:57
Vote:
 

Vaibhav,

It sounds like you want to implement an Auto Suggestion property within the CMS editor interface, have you tried following this documentation:

https://docs.developers.optimizely.com/content-management-system/docs/built-in-auto-suggestion-editor

#313164
Nov 27, 2023 10:20
Vote:
 

The below code has the same logic as Mark mentioned but I have created a searchable dropdown in one of my commerce projects so maybe that code will help.

[ServiceConfiguration(typeof(ISelectionQuery))]
 public class SearchOrganizatonsSelectionQuery: ISelectionQuery
 {
     public ISelectItem GetItemByValue(string value)
     {    
	  var val = value.Replace("%20", " "); // if the name contains blank spaces e.g. 'searchable  dropdown' then replace the value else it will not be display as selected
	  return GetItemsInternal(val)?.FirstOrDefault();
     }

     public IEnumerable<ISelectItem> GetItems(string query)
     {
         return GetItemsInternal(query);
     }

     IEnumerable<ISelectItem> GetItemsInternal(string query)
     {
         return Task.Delay(500) //Provide buffer time to type the query completely else modify this code as per requirement
             .ContinueWith(task => Search(query))
             .Result;
     }

     IEnumerable<ISelectItem> Search(string query)
     {
        // Replace the below code as per your requirement 
         var filter = new FilterElement(OrganizationEntity.FieldName, FilterElementType.Contains, query?.Trim());
         var response = (ListResponse)BusinessManager.Execute(new ListRequest(OrganizationEntity.ClassName, new[] { filter }, null, null, 50));
         var orgList = response.EntityObjects?.OfType<Organization>()?           
             .OrderBy(x => x.Name)?
             .ToList();

         if (orgList  != null)
         {
             foreach (var org in orgList)
             {
                 yield return new SelectItem { Text = org.Name, Value = org.Name };
             }
         }

         yield return new SelectItem { Text = "", Value = "" };
     }
 }
#313171
Nov 27, 2023 14:40
Mark Stott - Nov 27, 2023 15:09
Upvoted for practical example :)
* 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.