Sharepoint 2013 App access cross site collections

I’m using SharePoint 2013 and I wrote an AppPart that needs items of a list other than it’s host site collection. But it keeps popping up an error indicating that my request has been failed. Access denied!!

Here is my Code in App.js for query the list in another sitecollection:

context = new SP.ClientContext(appweburl);
factory = new SP.ProxyWebRequestExecutorFactory(appweburl);
appContextSite = new SP.AppContextSite(context, "http://pouyanserver/sites/Authoring");
this.web = appContextSite.get_web();
mylist = this.web.get_lists().getByTitle('Employees');
var camlQuery = new SP.CamlQuery();
var collListItem = mylist.getItems(camlQuery);
Function.createDelegate(this, successHandler),
Function.createDelegate(this, errorHandler)

I have tried these solutions but neither of these worked:

Solution 1:

In the AppManifest.xml , In permissions tab I’ve added SiteCollection and tenant as scopes who has full control.

Solution 2:
In the AppManifest.xml code, I’ve added an appPrincipal as follows:

     <Internal AllowedRemoteHostUrl="http://pouyanserver/sites/authoring"/>

What do you think ?

Get all user profiles to make a SharePoint 2013 app to show Org Chart(SP On Premise)

I made a dynamic org-chart app using KineticJS (on HTML Canvas) which is working using a dummy list of user from the parent site of app.
Here I get the users, make them an array of javascript objects then use the objects to populate the org chart. A manager field is used to connect the user and find the trees. I don’t know whether this is the best approach but it works…

Now I would like to use the SharePoint User Profiles to populate my Org-chart, Could you please help me pointing out how should I get the user info in this case?

thanks in advance

It is risky to modify the App part appearance setting (width & Height) using fixed pixel numbers

I have added many App parts to my team site web page, such as calendar, announcements, document management, etc.

Then I modify the App part width and height by defining 300 pixel for its height instead of using “Adjust height to it zone”. I tested the above inside my development machine which have a resolution of 1900 x 1050, and it will show a tool bar inside the App part and it worked fine.

But in general is it risky to define fixed pixel number to define the app part width and height?, since end users will be accessing the team site using different resolution settings , any advice eon this ?

Get context token for SharePoint 2013 provider hosted app (on-premise) with web project hosted on azure

I have an on-premise SharePoint environment for which I’m developing a provider hosted app using visual studio. The web project is hosted an azure. The app project contains a custom ribbon button that goes to the web project. Here I want to get the context token but when trying the following code the context token remains null:

SharePointContextToken contextToken = TokenHelper.ReadAndValidateContextToken(contextTokenString, Request.Url.Authority);

I have also tried the following but here I get that it is an unsupported token:

TokenHelper.GetAppContextTokenRequestUrl(hostWeb, Server.UrlEncode(Request.Url.ToString()));
SharePointContextToken contextToken = TokenHelper.ReadAndValidateContextToken(contextTokenUrl, Request.Url.Authority);

I figure that i get the unsupported token error is because contextTokenUrl contains an url and not an actual token.

How can I get the context token for a SharePoint 2013 on-premise environment with an app and the web project hosted on Azure?

How to pass custom claims from sharepoint site to Provider hosted App

I have sharepoint 2013 Server with configure ADFS for login provider.

and one MVC web application which is user for provided hosted app.

sharepoint site and MVC web application both are individual working fine with ADFS as identity provider.

now i create one high trust provider hosted app in visual studio and deploy it. so single sign on working fine between sharepoint site and provider hosted app.

Now in sharepoint i have configure one another Custom claim provided feature which is add one custom claim “Role” See below image,this image of sharepoint webpart which is display current user claims list.
Sharepoint Webpart

Now i redirect to my provider hosted app. and in landing page i print out the all list of claims which are get in User.Identity Role claims getting from ADFS ,not from sharepoint

MVC landing Page

So my problem is that i can’t get my Custom added claim “Role:Project Manager” in sharepoint is not getting in my MVC web application.

Please help me.
Thanks in advance.

Workflow SP 2013 – Cannot retrieve a UserMulti Field value

I’m developing a SharePoint-hosted App with a workflow working with a List that contains a UserMulti Field. I’m currently trying to retrieve this field value to a variable with a GetDynamicValueProperties but this isn’t working, the workflow execution is hanging.

My workflow configuration is OK since I can retrieve the Title to a string variable for example but when I try to get the USerMulti Field (called ‘Members’) to a Object variable, nothing happen.

After setting up my environment to catch the HTTP traffic I was able to find something in the XML conversation :

<WorkflowStatusDetails>RequestorId: d05baf50-adbc-6aa7-0000-000000000000. Details: RequestorId: d05baf50-adbc-6aa7-0000-000000000000. Details: An unhandled exception occurred during the execution of the workflow instance. Exception details: System.InvalidOperationException: Looking up a value using a key is not supported on an instance of 'Microsoft.Activities.Dynamic.DynamicJsonPrimitive'.
  at Microsoft.Activities.Dynamic.DynamicItem.TryGetValue(String key, DynamicItem& value)
  at Microsoft.Activities.Dynamic.DynamicValueBuilder.PathSegmentFactory.ObjectPathSegment.Get(DynamicItem obj)
  at Microsoft.Activities.Dynamic.DynamicValueBuilder.PathSegmentFactory.ObjectPathSegment.Get(DynamicItem obj)
  at Microsoft.Activities.Dynamic.DynamicValueBuilder.PathSegmentFactory.ArrayPathSegment.Get(DynamicItem obj)
  at Microsoft.Activities.Dynamic.DynamicValueBuilder.PathSegmentFactory.ObjectPathSegment.Get(DynamicItem obj)
  at Microsoft.Activities.Dynamic.DynamicValueBuilder.PathSegmentFactory.ObjectPathSegment.Get(DynamicItem obj)
  at Microsoft.Activities.GetODataProperties.Execute(CodeActivityContext context)
  at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
  at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)</WorkflowStatusDetails>

Can somebody enlighten me on that error or how to properly use a UserMulti Field in a Workflow ?

Thanks and regards.

Unable to add an app on sharepoint online 2013 of O-365?

The app is already in the corporate store but while adding the app it gives error “You can’t add this app here.”. for details “Ask your administrator to turn on Web Site Autohosting”

Details Description : There is no description available.
Supported Languages : Supported languages are not specified.

If anyone can let me know how to enable Website auto hosting.

Deploy SharePoint App as trusted using PowerShell

Using power shell, we deploy and install Sharepoint Apps to host web.
It works very well, the apps are installed without any problem.

However, If I start the application on host web, the login window appears, since the application is not trusted.
I need to go to options > permissions menu of each app and need to click “retrust” link manually in order to make it work.

How can I deploy and install a Sharepoint hosted app as “trusted” using power shell?

Thanks a lot in advance.

SharePoint App download file from url

I have a SharePoint 2013 app where I want to download a file.
in the web project I get the url from a file in SharePoint and I want to download it using the following code:

WebClient webClient = new WebClient();
webClient.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f");
webClient.Credentials = new NetworkCredential(userName, password, domain);
byte[] fileData = webClient.DownloadData(docUrl);
FileStream file = System.IO.File.Create(@"C:local");
file.Write(fileData, 0, fileData.Length);

But i get an error 401: Unauthorized

How can I download the file from SharePoint in the web project with the URL of the file?

field 'choices' not initialized not requested

Hi im using the following code to get choices of a Choice site column.
some times Im getting ‘Chices’ not initialized error in console.

var searchtaxonomy_context = SP.ClientContext.get_current();

                  var field = searchtaxonomy_context.castTo(searchtaxonomy_context.get_web().get_availableFields().getByTitle('Business Plan Year'), SP.FieldChoice);
                  searchtaxonomy_context.executeQueryAsync(function () {
                      var businessplanyearchoices = field.get_choices();
                      for (i = 0; i < businessplanyearchoices.length; i++) {
                          BusinessPlanYearsOptions.push({ id: businessplanyearchoices[i], name: businessplanyearchoices[i] });
                      //add options to business plan year drop down
                      addOptions('businessplanyearselector', BusinessPlanYearsOptions);
                  }, function (sender, args) {
                      alert('Error Loading the Business Plan Year Column data.'+args.get_message());
Question and Answer is proudly powered by WordPress.
Theme "The Fundamentals of Graphic Design" by Arjuna
Icons by FamFamFam