Getting Sub sites in top_navigation in SharePoint 2013


I have a site on share Point which contains some sub sites as well.I deployed my APP on main Site, I didn’t include sub sites in top navigation but when I am using following code , it gives me Top Navigation bar as well as sub sites. I just want only top navigation not the sub sites how can I exclude sub site.

function getTopMenuBar() {

    clientContext = new SP.ClientContext.get_current();

    if (clientContext != undefined && clientContext != null) {

        parent_web = clientContext.get_site().get_rootWeb();
        navigation = parent_web.get_navigation();
        clientContext.load(navigation);
        quickLaunchNodeCollection = navigation.get_topNavigationBar();
        clientContext.load(quickLaunchNodeCollection);

        clientContext.executeQueryAsync(Function.createDelegate(this, this.OnLoadingNavigation), Function.createDelegate(this, this.onQueryFailed));

    }
}

function OnLoadingNavigation() {
    var nodeEnumerator = this.quickLaunchNodeCollection.getEnumerator();
    while(nodeEnumerator.moveNext()) {
        var node = nodeEnumerator.get_current();
}
}


function onQueryFailed(sender, args) {
    // Some Code
}

SharePoint Hosted App Site Logo


How I can change site logo on the app page? I know several ways to do it.

  1. Updating the logo using javascript
  2. Using a custom master page

Are there another ways?

SharePoint 2013 REST response: jasonObject.d.result is undefined but jasonObject.d is fine


I am testing a SharePoint hosted app Menu Action.

I have written a REST call that brings back all the properties in a document item.

I get a valid response but when I unpick my response I run into difficulties

         var results = jsonObject.d;    // **note jsonObject.d.result is undefined**

Why is this? do I need add anything to my http header or url

This has a knock on effect in that for each below as ‘e’ is also undefined. I want my code to be robust an reusable – is there anything I need to do?

            $.each(results, function (i, e) {
                // ul.append("<li>" + e.Title + "</li>");
                itemHTML += "<li>" + e.Name + "</li>";
                console.log(e.Name);
            });

    // if not testing through the menu action
     itemurl = "/appsdev/Marketing lib/test.pdf";

     var urlItemAllFields = appweburl +
                 "/_api/SP.AppContextSite(@target)/web/getfilebyserverrelativeurl('" +     itemurl + "')/ListItemAllFields?@target='" + hostweburl + "'";


  setMessage(urlItemAllFields);


executor.executeAsync(
    {

        url: urlItemAllFields,
        method: "GET",
        headers: { "Accept": "application/json; odata=verbose" },
        success: function (data, errorCode, errorMessage) {
            alert('Sucess');
            var jsonObject = JSON.parse(data.body);

            var jsonObjectText = JSON.stringify(jsonObject);

Sharepoint 2013 bridging apps images lists


I have an employee list on SharePoint and need to store 2 or more different sets of images related to that employee. These image sets are related to the employee but not related to each other, hence 2 separate sets, and there may be additional sets later.

My plan was to create 2 separate apps of images, one for training and one for hiring. I would enable incoming email on both folders with separate addresses. When an employee was hired or trained those related document images would be scanned into the email address of the corresponding folder with the subject of employee id. This will create folders per employee in each library that will grow every time a new even occurs.

The third app is the actual list that holds the employee information. In this list I would create two non-editable fields that contain the urls back to their corresponding folders of the related images.

I would like thoughts as to what I am missing, how I am over thinking this, how I could simplify this, or what I could do differently that would make it more functional.

how to only get title of subsite and not display title of app also


right now this code writes out the subsites title and relativeurl, but it also includes my title of my app, but i only want to display the subsites title and not title of the app also,

Any sugesstions what i should do?
Here is my code

 function execCrossDomainRequest() {
        var executor = new SP.RequestExecutor(appweburl);
        var queryUrl = appweburl + "/_api/SP.AppContextSite(@target)/web/webs?$select=Title,ServerRelativeUrl&@target='" +hostweburl + "'" ;

        executor.executeAsync(
             {
                 url: queryUrl,
                 method: "GET",
                 headers: { "Accept": "application/json; odata=verbose" },
                 success: successHandler,
                 error: errorHandler
             }
                 );
                    }
                        })
function successHandler(data) {
$("#subSiteTitle").keypress(function () {
    var jsonObject = JSON.parse(data.body);
    var dataArr = $.makeArray(jsonObject.d.results);
    var resultArr = $.map(dataArr, function (item) {

        return { label: item.Title + " (" + item.ServerRelativeUrl + ")", value: item.ServerRelativeUrl };

    });

The type '*', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element could not be found


I have created my provider hosted app and successfully debugged it locally and it works perfect, its ready for the test environment

But when I deploy it to Azure I have this error in the Web service:

The type 'MyCompanyName.IntranetWeb.Services.AppEventReceiver', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.

The URL is this: (at least I should see the Web service page, right)

http://pru-MyCompanyName-intranet.azurewebsites.net/AppEventReceiver.svc

Project structure here: you can see the root has the web service.
http://screencast.com/t/Q8XEzjkBPG

My web.config is like this:

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit

http://go.microsoft.com/fwlink/?LinkId=301880

  -->
<configuration>
  <appSettings>
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    <add key="ClientId" value="f4fcb686-xx-4938-a676-a1ba50c202e5" />
    <add key="ClientSecret" value="ljguTvxHR+xx+Pl1IMg1Hjt5rsQ=" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <customErrors mode="Off" />
  </system.web>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <!--Used by app for SharePoint-->
        <binding name="secureBinding">
          <security mode="Transport" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <protocolMapping>
      <add binding="basicHttpBinding" scheme="https" bindingConfiguration="secureBinding" />
    </protocolMapping>
  </system.serviceModel>
  <system.webServer>
    <handlers>
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <remove name="OPTIONSVerbHandler" />
      <remove name="TRACEVerbHandler" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
  </system.webServer>
</configuration>

the webservice markupp

<%@ ServiceHost Language="C#" Debug="true" Service="MyCompanyName.IntranetWeb.Services.AppEventReceiver" CodeBehind="AppEventReceiver.svc.cs" %>

the webservice first line

namespace MyCompanyName.IntranetWeb.Services
{
    public class AppEventReceiver : IRemoteEventService
    {

Get Item from content type using Microsoft.SharePoint.Client.Search.Query.KeywordQuery(context) and display data in app part


How can I get a list item using Microsoft.SharePoint.Client.Search.Query.KeywordQuery(context) instead of a list query. I want to use the content type and not depend on the list to get the items.

Custom Display / Edit / New Forms in a O365 Provider Hosted App


Is it possible to change the Display / Edit / New Form Urls, so when a user clicks on an existing list item or tries to add a new item it will redirect them to the App?

I have tried changing the Forms in the List Schema.xml but this results in build errors.

Schema.xml

<Forms>
  <Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pagesform.aspx" WebPartZoneID="Main" />
  <Form Type="EditForm" Url="EditForm.aspx" SetupPath="pagesform.aspx" WebPartZoneID="Main" />
  <Form Type="NewForm" Url="NewForm.aspx" SetupPath="pagesform.aspx" WebPartZoneID="Main" />
</Forms>

How to access list of website users from SharePoint hosted app?


My app is hosted here:

https://mySite.sharepoint.com/sites/path/myApp/

And user information is hosted here:

https://mySite.sharepoint.com/sites/path/_catalogs/users/simple.aspx

I already use this code to access lists outside of my app

    function getLists() {

        print("retrieving list");

        var hostUrl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
        currentcontext = new SP.ClientContext.get_current();
        hostcontext = new SP.AppContextSite(currentcontext, hostUrl);
        web = hostcontext.get_web(); // hostcontext instead of currentcontext

        listCollection = web.get_lists();
        list = listCollection.getByTitle(LIST_NAME);

        listItemCollection = list.getItems(""); // use CAML query for specific requests

        context.load(listItemCollection);
        context.executeQueryAsync(sharePointReady, queryFailed);
    }

How can I adjust this code to get a list of all the users in my website like their name and contact information? Or is there another method?

Thanks in advance.

SharePoint-hosted app access a list while the user has no access permissions on the list


I have created a simple SharPoint-hosted app. I have modified the manifest file and added Full Control permission to List scope. I created a list in one of my SharePoint sites with unique permissions (break inheritance). I deployed the SharePoint-hosted app to the web site and chose the list when it asked to choose a list. I logged on to the site using a user which has no permissions on the list. The user can click on the app and get information from a list which he has no permissions on it.

How do I prevent users who have no access permissions to the list to write or read data to/from the list?

Question and Answer is proudly powered by WordPress.
Theme "The Fundamentals of Graphic Design" by Arjuna
Icons by FamFamFam