We have a customer that wishes to make it easier for the user to customize their webpart pages. We are therefor using javascript to build a simple grid where users can add, remove and move Add In Parts (both webparts and AppParts and both OOTB and custom) from the different webpart zones on the current page. Most of the features are working fine but we have two problems we can't seem to find the answer to. In this case we are working with a Farm Solution but we want it to work with Office365 as well.
- Is Add In Part shared or personal?
We want the users to be able to remove/hide Add In Parts they don't want and we are doing that with SP.WebParts.WebPartDefinition.deleteWebPart(). This works fine for Add In Parts the user has added to his/her personal site but if you try this with a shared Add In Part you get an error. We would like to find out if the Add In Part is shared and in that case set hidden=true. We can't seem to find anything about how to check if the Add In Part is shared or not other then to first try "deleteWebPart()" and if it gives an error try "hidden=true" instead.
- Get ClientWebPart (AppPart) xml
To be able to add an Add In Part to the page from the gallery you need it's xml in this method: importWebPart(). For webparts we can find the .webpart-files by checking the items in "~siteUrl/_api/web/getCatalog(113)/items" but AppParts does not exist in this list. To get all Apps we are using SP.AppCatalog.getAppInstances(context, web) and from this we get each apps name, guid etc but not it's xml. Where can we find that? Everywhere people asking the same are advised to just export the xml manually and use it in the code but that is not good enought. This needs to be dynamic and work with all AppParts.
Thank you for your help.
To admins: I first posted this question on sharepoint.stackexchange.com but I'm not sure if questions about Sharepoint regarding code should be posted here or there. If you tell me how it's supposed to be I will remove the other.