4

I am looking for a way to actually create a result source with C# CSOM. I only find examples where I specify an existing result source like this answer. I am developing a SharePoint provider hosted addin and I must create and configure a couple of search web parts with my CSOM code in a remote MVC application with an AppInstalled Event Receiver. I can't use any server code nor provision it. That is why I must do it with C# CSOM.

So does anyone know of a way to do this?

1 Answer 1

3
+50

It is possible to create a result source with CSOM. Basically what you do is:

  1. Manually create the result source in SharePoint (in the site, sitecollection or tenant level depending on your requirements)
  2. Export the search configuration, which gives you an XML file.

  3. Use CSOM to import the search configuration to another site, sitecollection or tenant.

Have a look at this PnP video and sample:

https://channel9.msdn.com/blogs/OfficeDevPnP/How-to-Export-and-Import-Search-Configurations-with-CSOM

https://github.com/SharePoint/PnP/tree/master/Samples/Core.SearchSettingsPortability

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.