I am working on SharePoint site, where my requirement is backup the wiki page (its properties and web parts) and later if page is deleted then restore it from the backup copy.
I am able to backup the wiki page content from its WikiField property and web parts using LimitedWebPartManager.
Now as restore, while creating new wiki page I have used backed up WikiField for content and adding web parts into newly created wiki page using LimitedWebPartManager, however the web parts are not shown on the wiki page, after some RND, found that WikiField holds the web part data in some div and there is webpart id as well which is not matching with newly generated ids of web parts after adding ( and not matching with backed up web parts definition id).
I can not add the div with newly created webpart id at the end or beginning of WikiField as wiki page have other content as well and I want webparts to be added on the same place and in the same sequence.
I am using SharePoint CSOM(C#) for this.
How can I achieve this?
While backing up page, If I am able to map the webpart id from wiki content with webpartdefination id then I can keep this data somewhere and use the same while restoring, any idea around this?
This is the wiki page I have :
WikiField property content for the wiki page :
<div class="ExternalClassB6921781E82B446CB3BFC1E687ADA254">
<table id="layoutsTable" style="width:100%;">
<tbody>
<tr style="vertical-align:top;">
<td style="width:100%;">
<div class="ms-rte-layoutszone-outer" style="width:100%;">
<div class="ms-rte-layoutszone-inner">
<p>11111<br/>
<div class="ms-rtestate-read ms-rte-wpbox">
<div class="ms-rtestate-notify ms-rtestate-read 74353ad4-33f0-4df8-8cd9-c6f42659f92d" id="div_74353ad4-33f0-4df8-8cd9-c6f42659f92d"/>
<div id="vid_74353ad4-33f0-4df8-8cd9-c6f42659f92d" style="display:none;"/>
</div>
<p>
<br/>
<p>2222</p>
<p>
<br/>
<div class="ms-rtestate-read ms-rte-wpbox">
<div class="ms-rtestate-notify ms-rtestate-read 6fac0a22-1e28-4e70-8f63-97ab32cd728d" id="div_6fac0a22-1e28-4e70-8f63-97ab32cd728d"/>
<div id="vid_6fac0a22-1e28-4e70-8f63-97ab32cd728d" style="display:none;"/>
</div>
<p>
<br/>
</div>
</div>
</td>
</tr>
</tbody>
</table>
<span id="layoutsData" style="display:none;">false,false,1</span>
</div>
Hi @Yuvraj Patil ,
The webpart id from the WikiField property doesn't relate to the web part id. It's a div id and we are unable to change it. So there is no such function to link them.