Domanda

Sto sviluppando Apps per SharePoint 2013.E voglio creare più elenchi nel mio pacchetto di app programmaticamente .
È come l'utente input nome elenco e quando fa clic sul pulsante Creazione L'elenco con lo stesso nome deve essere creato nella mia app non nel sito SharePoint.

Ho creato il AutoHosted App utilizzando la tecnologia del modello dell'oggetto laterale client.

Come posso ottenere questa funzionalità?

È stato utile?

Soluzione

I have found the solution.
When I was creating the ContextToken object in that I was passing the SPHostUrl of the request but instead of that I passed SPAppWebUrl So using that it get the token of the AppWebUrl and thus it created the list in my App not in SharePoint site.

Like bellow code:

var hostWeb = Page.Request["SPAppWebUrl"]; //This will get the URL of AppWeb not SharePoint site...

using (var clientContext = TokenHelper.GetClientContextWithContextToken(hostWeb, ContextToken, Request.Url.Authority))
{
     //Code for creating list or manipulating them...
     //This ClientContext is created for the AppWeb.
}

When I was searching the code for creating every time I was finding the hostWeb object is created using SPHostUrl Therefore I asked this question.
Thank you everyone for your help.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top