SP is undefined in sharepoint hosted app client Webpart

Hello All,
For a client web part in sharepoint hosted app, I am getting the following error
"SP is undefined".
My code is bel0w
   <script
 type="text/javascript"
 src="//ajax.aspnetcdn.com/ajax/4.0/1/MicrosoftAjax.js">
</script>
    <script type="text/javascript" src="../Scripts/jquery-1.9.1.min.js"></script>
     <script  type="text/javascript" src="/_layouts/sp.core.js"></script>
    <script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>
        <script type="text/javascript" src="/_layouts/15/sp.js"></script>
    <script type="text/javascript">
        'use strict';
        $(document).ready(function () {
                    ExecuteOrDelayUntilScriptLoaded(loadConstants, "sp.js");
                var  clientContext = SP.ClientContext.get_current();
               var  web = clientContext.get_web();
</script>     ....
I am getting the error ExecuteOrDelayUntilScriptLoaded is undefied. This script is in client Web part
Any help is appreciated.
Vishnu

Thanks for the reply Geetanjali.
var  clientContext = SP.ClientContext.get_current();
 var  web = clientContext.get_web();
These two lines of code is supposed to be inside "loadConstants" method.
After changing the code as below, I am able to get SPClientContext and SPWeb.Also, host and appweb url as well
<script
type="text/javascript"
src="../Scripts/jquery-1.6.2.min.js"></script>
 <script
type="text/javascript"
src="//ajax.aspnetcdn.com/ajax/4.0/1/MicrosoftAjax.js"></script>
 <script
type="text/javascript"
src="../Scripts/App.js"></script>
$(document).ready(
    function () {
var spHostUrl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
      var appWebUrl = decodeURIComponent(getQueryStringParameter('SPAppWebUrl'));
var layoutsRoot = spHostUrl + '/_layouts/15/';
        $.getScript(layoutsRoot +
"SP.Runtime.js",
function () {
            $.getScript(layoutsRoot +
"SP.js", loadConstants);
function loadConstants() {
            context =
new SP.ClientContext.get_current();
            web = context.get_web();
Thanks
Vishnu
dfd

Similar Messages

  • __REQUESTDIGEST is undefined in sharepoint hosted app ( Client WebPart ) but its working in full page app

    I have found the answer in below url. but howerver i am not sure from where the "accessToken" coming.
    Any idea?
    http://social.msdn.microsoft.com/forums/windowsapps/en-us/816291e7-8081-46e0-8ec3-e67613d1621f/requestdigest-is-undefined-in-sharepoint-hosted-app?forum=appsforsharepoint
    Navaneeth

    Okay. Finally i found solution after 2 weeks :)
    Below is the way to use. Note its working in both Single Page App and Client App Part as well
    var formDigest; //Declare the variable
    //Document Ready
    $(document).ready(function () {
        hostweburl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
        appweburl = decodeURIComponent(getQueryStringParameter('SPAppWebUrl'));
        scriptbase = hostweburl + '/_layouts/15/';
        CharacterAnimation();
        $.getScript(scriptbase + 'SP.Runtime.js', function ()
            $.getScript(scriptbase + 'SP.js', function ()
                $.getScript(scriptbase + 'SP.RequestExecutor.js', getFormDigest);
    //Get  Form Digest Value
    function getFormDigest() {
        var appweburl = decodeURIComponent(getQueryStringParameter('SPAppWebUrl'));
        $.ajax({
            url: appweburl + "/_api/contextinfo",
            type: "POST",
            headers: {
                "accept": "application/json;odata=verbose",
                "contentType": "text/xml"
            success: function (data) {
                requestdigest = data;
                var formDigest = data.d.GetContextWebInformation.FormDigestValue;
                DoSomething(formDigest);
            error: function (err) {
                alert(JSON.stringify(err));
    //Do Something Method
    function  DoSomething(formDigest) {
    var urltest = appweburl + "/_api/SP.AppContextSite(@target)/web/lists/getByTitle('List1')/getitems(query=@v1)?@v1={\"ViewXml\":\"<View><Query><Where><BeginsWith><FieldRef Name='Title'/><Value Type='Text'>A</Value></BeginsWith></Where></Query><RowLimit>1</RowLimit></View>\"}&@target='"
    + hostweburl + "'";
            $.ajax({
            url: urltest,
            type: "POST",
            headers: {
                "Accept": "application/json; odata=verbose",
                "Content-Type": "application/json; odata=verbose",
                "X-RequestDigest": formDigest
            contentType: 'application/json',
            success: function (data) {
                alert(data); // Finally found [Object][Object] :)
            error: function (data) {
                alert(data.responseText);
    Navaneeth

  • SharePoint hosted app error log

    Hi,
      I'd like to log the error in ULS log from sharepoint hosted app [Client side]. Is it possible, if yes, please let me know how to do it..
    Balaji -Please click mark as answer if my reply solves your problem.

    Hi,
    You could write informations to the "App Error Log".
    Have a look at these links :
    http://exxlence.com/2013/01/07/add-logging-to-your-sharepoint-app-using-logcustomapperror-method/
    http://sp2013.blogspot.fr/2013/01/sharepoint-apps-logging.html
    Regards
    Gilles Martinez
    Twitter
    Blog
    Please mark as helpful/answer if this resolved your post

  • How to get inputted value in a RTE field on custom page and submit by REST call in 'Sharepoint hosted app'.

    Hi I am facing the three questions below.
    1. How to use default RTE in custom page in Sharepoint hosted app.
     I saw the article of Rich text Editor (ribbon based) in a webpart in SharePoint 2013 and tried it. But it did not work well. I guess it needs code-behind setting, however sharepoint hosted app does not support code-behind.
    Does anybody know how to do this?
    2. In above case, I placed the below code on custom page and tried to get the field's value when submit button was clicked.
    <SharePoint:InputFormTextBox ID="rftDefaultValue"
    RichText="true"
    RichTextMode="FullHtml" runat="server"
    TextMode="MultiLine" Rows="5">
    </SharePoint:InputFormTextBox>
    In debugger, the returned value was 'undefined'.
    var note = $('#hogehoge').val();
    Is it possible to get the RTE value? If yes, please let me know how to do this.
    3. I need to submit the RTE value using REST call.
    In this
    article in MSDN, the item creation sample treats single line text field. Does anybody know the sample for RTE?

    Hi,
    According to your description, you might want to use Rich Text Editor control in your SharePoint hosted app.
    First of all, I would suggest you post one question in one thread to make it easier to be discussed, which would also help you get a quick solution.
    Though we can add this control into a SharePoint hosted app, however, as we can’t add code behind for it, plus with the potential compatibility issues in different
    browsers, I would suggest you use other JavaScript Rich Text Editor plugins instead.
    Two JavaScript Rich Text Editor plugins for your reference:
    http://quilljs.com/
    http://nicedit.com/
    If you want to submit the value of Rich Text Editor control to a SharePoint list using REST call, since the content in the Multiple Line of Text column is wrapped
    with nested HTML tags, the similar requirement would also be applied to the content to be submitted.
    Here is a code snippet about how to update a Multiple Line of Text column for your reference:
    updateListItem(_spPageContextInfo.webAbsoluteUrl, "List018", 1);
    function updateListItem(siteUrl, listName, itemId)
    var itemType = GetItemTypeForListName(listName);
    var item = {
    "__metadata": { "type": itemType },
    "MultiTextEnhanced": "<div><a href='http://bing.com/'>Bing</a><br></p></div>",
    "Title": "123"
    $.ajax({
    url: siteUrl + "/_api/web/lists/getbytitle('" + listName + "')/items(" + itemId + ")",
    method: "GET",
    headers: { "Accept": "application/json; odata=verbose" },
    success: function (data) {
    console.log(data);
    $.ajax({
    url: data.d.__metadata.uri,
    type: "POST",
    contentType: "application/json;odata=verbose",
    data: JSON.stringify(item),
    headers: {
    "Accept": "application/json;odata=verbose",
    "X-RequestDigest": $("#__REQUESTDIGEST").val(),
    "X-HTTP-Method": "MERGE",
    "If-Match": data.d.__metadata.etag
    success: function (data) {
    console.log(data);
    error: function (data) {
    console.log(data);
    error: function (data) {
    console.log(data);
    // Getting the item type for the list
    function GetItemTypeForListName(name)
    return"SP.Data." + name.charAt(0).toUpperCase() + name.slice(1) + "ListItem";
    Thanks
    Patrick Liang
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support,
    contact [email protected]
    Patrick Liang
    TechNet Community Support

  • SharePoint hosted App that listens and log SharePoint Events

    Basically, what I need, is something that can listen to all events fired in SharePoint and write them to a custom list.
    I was thinking of making this as a SharePoint hosted app because it has to work on SP Online as well.
    The idea is then, to let a provider hosted app read the custom list every x minutes and do it's own logic depending on the events it reads from the custom list.
    So the question is, how do I catch all the events fired in SharePoint and should it be a SharePoint hosted app that does it?
    Any thoughts on how to solve this?
    Thanks.
    Thomas Bomann, simplySo

    Hi,
    According to your description, my understanding is that you want to track all the event fired in SharePoint .
    Listen to the events in SharePoint needs Server side code, see the article below:
    Programming Event Handling in Windows SharePoint Services
    In SharePoint hosted app, it needs to use Client Object Model, so there is no such Client API to meet the requirement.
    More information:
    JavaScript Client Object Model in SharePoint 2013
    Thanks
    Best Regards,
    Jerry Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • SharePoint hosted app part and SPHostUrl + SPAppWebUrl

    Hi,
    I have sharepoint hosted app that gets hostweburl and appweburl with the next lines 
    function getUrl() {
    hostweburl = getQueryStringParameter("SPHostUrl");
    appweburl = getQueryStringParameter("SPAppWebUrl");
    hostweburl = decodeURIComponent(hostweburl);
    appweburl = decodeURIComponent(appweburl);
    var scriptbase = hostweburl + "/_layouts/15/";
    $.getScript(scriptbase + "SP.Runtime.js",
    function () {
    $.getScript(scriptbase + "SP.js",
    function () { $.getScript(scriptbase + "SP.RequestExecutor.js", execOperation); }
    function execOperation() {
    context = new SP.ClientContext(appweburl);
    appContextSite = new SP.AppContextSite(context, hostweburl);
    And this works fine. But when I'm creating app part those hostweburl and appweburl fields are undefined. So I cant get the context and everything is broken. Is this done in some other way in app parts? 

    Like this in the ClientWebPart   
    <Content
          Type="html"
          Src="~appWebUrl/Pages/Welcome.aspx?{StandardTokens}&amp;ShowImage=_ShowImage_" />
    The {StandardTokens} contains all the queryString parameters you need.
    Author,
    Microsoft SharePoint 2013 App Development
    Author,
    Professional Business Connectivity Services
    Author,
    Inside SharePoint 2013
    Blog, www.shillier.com
    Twitter, @ScotHillier
    SharePoint Trainer, Critical Path Training

  • Issue with REST POST call: CopyTo in a SharePoint hosted App not working

    Hi Community
    I have been really struggling to get a cross domain copy to work both in an App or even using REST Tools such as Postman or Google Advanced REST Client. 
    Ok there are various blog posts by Scott G et al.  that shows how you can post say in a single domain.  Now that's fairly straight forward
    in my case I took a .apsx page and added the following lines of code - Checkin - refresh and great the file gets copied via  the document ready function
    (document).ready(function () {
    alert('ready!');
    var src = "/appsdev/Shared Documents/SrcDoc.docx";
    var dst = "/appsdev/Shared Documents/DestDocCopiedByRestTestASPXPage.docx";
    jQuery.ajax({
    type: "POST",
    contentType: "application/json;odata=verbose",
    headers: {
    "accept": "application/json;odata=verbose",
    "X-RequestDigest": jQuery("#__REQUESTDIGEST").val()
    url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/getfilebyserverrelativeurl('" + src + "')/copyto(strnewurl='" + dst + "',boverwrite=true)",
    success: function (data, errorCode, errorMessage) {
    alert('Success: copied the damn file');
    var jsonObject = JSON.parse(data.body);
    var jsonObjectText = JSON.stringify(jsonObject);
    error: errorHandler
    Now I make the call in my SharePoint hosted App and I simple can' t  get this to work. Fiddler doesn't exactly help a lot
      var src = "/appsdev/Shared Documents/SrcDoc.docx";
      var dst = "/appsdev/Shared Documents/DestDocCopiedByMyApp.docx";
        var urlWriteLocalFileDebug = appweburl +
       "/_api/SP.AppContextSite(@target)/web/Getfilebyserverrelativeurl('" + src + "')/copyTo(strNewUrl='" + dst + "', bOverWrite=true)?@target='" + hostweburl + "'";
    executor.executeAsync(
    method: "POST",
    contentType: "application/json;odata=verbose",
    headers: {
    "accept": "application/json;odata=verbose",
    "X-RequestDigest": jQuery("#__REQUESTDIGEST").val()
    url: urlWriteLocalFileDebug,
    success: function (data, errorCode, errorMessage) {
    alert('Success: copied the damn file');
    var jsonObject = JSON.parse(data.body);
    var jsonObjectText = JSON.stringify(jsonObject);
    error: errorHandler
    I can happily run a GET and see the properties of my file but POST no way.   Curriously, when I try to run the same command for say Google Advanced Rest Client I get nowhere
    Is this a new mensa test!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
    Freelance consultant

    Hi
    I have now tested against a trail Office  365 Developer site and I had to make a few adjustments
    - change the url
    - change the target to SharePoint Onlne
    - change the url 
    I still wasn't happy so I created a new SharePoint Hosted app and pointed at the above developer site.  I copied my CrossDomainExec.js and stripped all my code except my CopyItemInSameLIbrary method which hasn't changed since I created this post. 
    - changed the App Manifest permissions to Web -full Control ( was previously tenant)
    I still got errors which is really painful as you don't even see the POST request in Fiddler
    The URL used for my POST is as follows ( note host URL is fictitious)
    "https://myapphell-547d8061d39e38.sharepoint.com/sites/appsdev/RESTTestSHA/_api/SP.AppContextSite(@target)/web/Getfilebyserverrelativeurl('/sites/appsdev/Shared Documents/SrcDoc.docx')/copyTo(strNewUrl='/sites/appsdev/Shared Documents/DestDoc.docx', bOverWrite=true)?@target='https://myapphell.sharepoint.com/sites/appsdev'" String
    Ran the app a second time and now I see......Wow it WORKS!!!!!! ..Can't be true can it?
    .... next I will switch the target url to my on prem farm to see if this still works so watch this space!
    Daniel
    Freelance consultant

  • Unable to update rating (rating column) on host document using JavaScript Object Model API inside sharepoint hosted apps

    Hi Everyone,
    We are developing SharePoint hosted apps for Office 365, for that we are going
    to implement document rating functionality inside Sharepoint app. The host web contain document library (“Documents”) and from apps we need to rate each document. The rating functionality working fine with CQWP in team site  using
    JavaScript Object Model API.
    But the same code is not working inside apps and giving error:-
    If we are using app context than error will be:-
    "List does not exist.
    The page you selected contains a list that does not exist.  It may have been deleted by another user."
    And for Host context than error will be:-
    "Unexpected response data from server."
    Please help on this
    Please see below code..
    'use strict';
    var web, list, listItems, hostUrl, videoId, output = "";
    var videoLibrary = "Documents";
    var context, currentContext;
    var lists, listID;
    var list, parentContext;
    var scriptbase;
    (function () {
        // This code runs when the DOM is ready and creates a context object which is 
        // needed to use the SharePoint object model
        $(document).ready(function () {
            hostUrl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
            context = SP.ClientContext.get_current();      
            SP.SOD.executeFunc('sp.js', 'SP.ClientContext', sharePointReady);
        function sharePointReady() {
            scriptbase = hostUrl + "/_layouts/15/";
            // Load the js files and continue to the successHandler
            $.getScript(scriptbase + "SP.Runtime.js", function () {
                $.getScript(scriptbase + "SP.js", function () {
                    $.getScript(scriptbase + "SP.Core.js", function () {
                        $.getScript(scriptbase + "reputation.js", function () {
                            $.getScript(scriptbase + "sp.requestexecutor.js", execCrossDomainRequest);
        //Query list from hostweb
        function execCrossDomainRequest() {       
            //Load the list from hostweb
            parentContext = new SP.AppContextSite(context, hostUrl);
            web = parentContext.get_web();
            list = web.get_lists().getByTitle(videoLibrary);
            context.load(list, 'Title', 'Id');
            var camlQuery = new SP.CamlQuery();
            camlQuery.set_viewXml('<View><Query><OrderBy><FieldRef Name="Modified" Ascending="FALSE"/></OrderBy></Query><RowLimit>1</RowLimit></View>');
            listItems = list.getItems(camlQuery);        
            context.load(listItems);
            context.executeQueryAsync(onQuerySucceeded, onQueryFailed);
        //Process the image library
        function onQuerySucceeded() {       
            var lstID = list.get_id();
            var ctx = new SP.ClientContext(hostUrl);       
            var ratingValue = 4;
            EnsureScriptFunc('reputation.js', 'Microsoft.Office.Server.ReputationModel.Reputation', function() {      
            Microsoft.Office.Server.ReputationModel.Reputation.setRating(ctx, lstID, 1, ratingValue);       
            ctx.executeQueryAsync(RatingSuccess, RatingFailure);
        function onQueryFailed(sender, args) {
            alert('Failed' + args.get_message());
        function failed(sender, args) {
            alert("failed because:" + args.get_message());
        function RatingSuccess() {
            alert('rating set');
            //displaystar();
        function RatingFailure(sender, args) {
            alert('Rating failed : : ' + args.get_message());
        //Gets the query string paramter
        function getQueryStringParameter(paramToRetrieve) {
            var params;
            params = document.URL.split("?")[1].split("&");
            for (var i = 0; i < params.length; i = i + 1) {
                var singleParam = params[i].split("=");
                if (singleParam[0] == paramToRetrieve) return singleParam[1];
    Thanks & Regards
    Sanjay 
    Thank you in advance! :-)
          

    Hi,
    According to your post, my understanding is that you want to update list column in SharePoint hosted apps using JavaScript Client Object Model.
    Based on the error message, it seems not retrieve the list object in context. I suggest you debug the code step by step using Internet Explorer Developer Tools to
    find the problem.
    Here are some demos about using JavaScript Client Object Model in SharePoint hosted app:
    http://blogs.msdn.com/b/officeapps/archive/2012/09/04/using-the-javascript-object-model-jsom-in-apps-for-sharepoint.aspx
    http://sharepoint.stackexchange.com/questions/55334/how-to-access-list-in-sharepoint-hosted-app
    http://www.dotnetcurry.com/showarticle.aspx?ID=1028
    Best regards
    Zhengyu Guo
    TechNet Community Support

  • Call EWS from SharePoint 2013 SharePoint Hosted App (JavaScript) in Office 365

    I am trying to call the exchange web service (EWS) of an exchange online server from a SharePoint hosted app. I am limited thus to the use of Javascript. During my call i am always getting an access denied error.
    The body of the SOAP request is good since I have tested it using a client application, but I am not being able to get it to work via a jquery ajax call. I am sure that this is an authentification issue and I have no problem sending the credentials during
    the call. I have added them in the header. This is what I have ended up doing but still no luck.
    functionGetUnReadEmailCount() {
    varsoapPacket = "<?xml version='1.0' encoding='utf-8'?>"+
    "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'xmlns:t='http://schemas.microsoft.com/exchange/services/2006/types'>"+
    '<soap:Header>'+
    '<wsse:Security>'+
    '<wsse:UsernameToken>'+
    '<wsse:Username>******</wsse:Username>'+
    '<wsse:Password>******</wsse:Password>'+
    '</wsse:UsernameToken>'+
    '</wsse:Security>'+
    '</soap:Header>'+
    "<soap:Body>"+
    "<FindItem xmlns='http://schemas.microsoft.com/exchange/services/2006/messages' xmlns:t='http://schemas.microsoft.com/exchange/services/2006/types'Traversal='Shallow'>"+
    "<ItemShape>"+
    "<t:BaseShape>IdOnly</t:BaseShape>"+
    "</ItemShape>"+
    "<IndexedPageItemView MaxEntriesReturned='50' Offset='0' BasePoint='Beginning' />"+
    "<Restriction>"+
    "<t:IsEqualTo>"+
    "<t:FieldURI FieldURI='message:IsRead' />"+
    "<t:FieldURIOrConstant>"+
    "<t:Constant Value='false' />"+
    "</t:FieldURIOrConstant>"+
    "</t:IsEqualTo>"+
    "</Restriction>"+
    "<ParentFolderIds>"+
    "<t:DistinguishedFolderId Id='inbox' />"+
    "</ParentFolderIds>"+
    "</FindItem>"+
    "</soap:Body>"+
    "</soap:Envelope>";
    $.support.cors = true;
    $.ajax({
            url: "https://outlook.office365.com/EWS/Exchange.asmx",
            type: "POST",
            dataType: "xml",
            data: soapPacket,
            complete: processResult,
            error: OnError,
            contentType: "text/xml; charset=\"utf-8\""
    Any help is highly appreciated.
    Thanks.
    Elie

    Hi Elie,
    Since this forum is discussing about Developing Apps for Office 2013, and your issue is more related about Exchange development. I will move this thread to the more related forum.
    Reference:
    https://social.msdn.microsoft.com/Forums/en-US/home?forum=exchangesvrdevelopment
    Thanks for your understanding.
    Best Regards,
    Edward
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to get IdP Token (SAML Response) in Office 365 using SharePoint hosted app parts.

    Hi All
    We have a requirement to retrieve data from SQl azure & consume it O365 Sharepoint hosted app parts. to expose SQL azure data we implemented Web API .  Now we are struck at securing Web API. I found below flow in internet search.
    In this process
    Client component (App part) get  IdP token ( signed SAML Responce) from sharepoint & sends IdP token to ACS, which validates the token signature & claims & issues Access Token(valid for 600sec) to client ,which would be forwarded to
    Web API. where web Api validates & provides data.
    Client - SharePoint Site (App parts)
    Identity provider : Onelogin is our Identity provider.
    Application : Web API
    In this whole process . how to get IdP Token (SAML Response) from sharepoint in Sharepoint hosted appparts using client object model? 
    can any one help on this.
    ragava_28

    Hi,
    According to your post, my understanding is that you want to enable/disable the custom ribbon button accordingly.
    We can use the EnabledScript attributes to achieve this scenario.
    The EnabledScript attribute of the CommandUIHandler that will enable or disable the button depending on whether the function returns true or false. 
    There are some articles about this topic, you can refer to them.
    http://dannyjessee.com/blog/index.php/2013/01/javascript-to-conditionally-enable-a-sharepoint-custom-ribbon-button/
    http://aaclage.blogspot.com/2014/07/how-to-enabledisable-ribbon-buttons-by.html
    http://dannyjessee.com/blog/index.php/2014/06/enabling-custom-ribbon-buttons-dynamically-based-on-multiple-selected-item-values-using-refreshcommandui-and-jsom/
    Thanks,
    Jason
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Jason Guo
    TechNet Community Support

  • Issue with Workflow in a SharePoint-hosted App Application

    Hi,
    I have created a Sharepoint-hosted app which has a list workflow in it. After I deploy it to the sharepoint server,  I can not find any workflow under the associated list.
    However, I did have target list associated with workflow in workflow project property.  
    (My app and worflow is developed in VS 2012)
    I have searched the forum and found some similar question. However, all of them don't have useful answers.....
    Can anyone give me some help~?

    Hi Baron123,
    I can reproduce your scenario, that create an app with list, and add a workflow associates with it, the workflow is not working, that seems doesn’t associates successfully.
    Before I can tell why this happens, I found a helpful blog about keeping the list definitions and workflow definitions separate, use Handle APP installed event receiver to wire up a workflow to lists in app web or host web.
    As it is not a good solution to deploy the list and workflow in the same app solution, because that if you redeploy the app the date will be lost, the list will be new created, so I would suggest you to reference the blog, check whether this can meet your
    requirement.
    SharePoint Apps and Workflow:
    http://jonfancey.azurewebsites.net/2013/03/22/SharePointAppsAndWorkflow.aspx
    Thanks,
    Qiao Wei
    TechNet Community Support

  • How to open List when Page loads in SharePoint Hosted App?

    I  want to create an app same like InstantPracticeManager by InstantQuick.
    Now I want to know that in a SharePoint Hosted App How can I show the Whole List in a page. 
    Here I have added one image:
    Here there is one list and there are 4 views of that list.
    Now the App will be like when I load the page It will show like the image above. Now how can we show the list like this in sharepoint hosted app?
    I want the same scenario which is shown in the following blogs:
    http://sp2013.blogspot.in/2012/08/use-list-view-in-sharepoint-2013-apps.html
    and
    http://www.sharepointnutsandbolts.com/2013/08/working-with-web-parts-within.html
    where they add a list to an app
    Can any one suggest me the idea? I am bit confused.
    thanks in advance.

    Hi,
    According to your post, my understanding is that you want to show the different list view in a page in SharePoint Hosted App.
    We can use jQuery and cross-domain library to achieve it.
    The following articles for your reference:
    Adding a Tabbed View to A Web Part Page Using jQueryUI
    http://sympmarc.com/2011/11/09/adding-a-tabbed-view-to-a-web-part-page-using-jqueryui/
    How to: Access SharePoint 2013 data from apps using the cross-domain library
    http://msdn.microsoft.com/en-us/library/office/fp179927(v=office.15).aspx
    SharePoint 2013: Get list items by using the cross-domain library (JSOM)
    http://code.msdn.microsoft.com/office/SharePoint-2013-Get-items-d48150ae/view/SourceCode#content
    Thanks,
    Dennis Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Dennis Guo
    TechNet Community Support

  • Getting error while uploading multiple files in sharepoint hosted app in 2013 with REST API

    Hi All,
    In one of my tasks, I was struck with one issue, that is "While uploading multiple files into custom list with REST API".
    Iam trying to upload multiple files in library with REST calls for an APP development, my issue is if i wants to upload 4 image at once its storing only
    3 image file and further giving "Conflict" error". Below is the attached screenshot of exact error.
    Error within screenshot are : status Code : 409
    status Text :conflict
    For this operation i am uploading different files as an attachment to an list item, below is the code used for uploading multiple files.
    my code is
    function PerformUpload(listName, fileName, listItem, fileData)
        var urlOfAttachment="";
       // var itemId = listItem.get_id();
        urlOfAttachment = appWebUrl + "/_api/web/lists/GetByTitle('" + listName + "')/items(" + listItem + ")/AttachmentFiles/add(FileName='" + fileName + "')"
        // use the request executor (cross domain library) to perform the upload
        var reqExecutor = new SP.RequestExecutor(appWebUrl);
        reqExecutor.executeAsync({
            url: urlOfAttachment,
            method: "POST",
            headers: {
                "Accept": "application/json; odata=verbose",
                "X-RequestDigest": digest              
            contentType: "application/json;odata=verbose",
            binaryStringRequestBody: true,
            body: fileData,
            success: function (x, y, z) {
                alert("Success!");
            error: function (x, y, z) {
                alert(z);

    Hi,
    THis is common issue if your file size exceeds 
     upload a document of size more than 1mb. worksss well for kb files.
    https://social.technet.microsoft.com/Forums/office/en-US/b888ac78-eb4e-4653-b69d-1917c84cc777/getting-error-while-uploading-multiple-files-in-sharepoint-hosted-app-in-2013-with-rest-api?forum=sharepointdevelopment
    or try the below method
    https://social.technet.microsoft.com/Forums/office/en-US/40b0cb04-1fbb-4639-96f3-a95fe3bdbd78/upload-files-using-rest-api-in-sharepoint-2013?forum=sharepointdevelopment
    Please remember to click 'Mark as Answer' on the answer if it helps you

  • OnPremise: Sharepoint Hosted App gives 401 unauthorized error while accessing UserProfile Rest Service

    Hi All,
    I have SharePoint hosted app deployed on On-Premise using(F5) which reads User Profile data consumes WCF(Hosted on same server) through REST API to insert data in to SQL DB(Different server).
    SharePoint hosted app was working as expected and suddenly it started asking for credential and not login(any user) to the application landing page.
    Checked SharePoint Logs, IIS Logs and Windows log but did not get any clue.
    WCF is accessible, User Profile access is also happening but not sure what changes done on server or infra level which causing this issue.
    I have an On-Premise Environment for SharePoint 2013. where we have created SharePoint hosted app which calls "http:///_api/SP.UserProfiles.PeopleManager/GetMyProperties" to get current user's data. but this gives me 401 unauthorized error.
    Notes:
    I had given read permission to user profile and full control to sitecollection in appmanifest. If I run this app on Office 365 developer site it works fine, but on premise environment it give 401 error.
    On premise environment when I deploy this app 3 times it prompt for  credential and finally gives the following error
    Error message after login 3 times:
    {"error":{"code":"-2147024891, System.UnauthorizedAccessException","message":{"lang":"en-US","value":"Access
    denied. You do not have permission to perform this action or access this resource."}}}
    -Lovekush Kumar 

    Add your site (http://*.app.contoso.com) to your local intranet sites in IE. 
    "app.contoso.com" is app domain.
    My Blog- http://www.sharepoint-journey.com|
    If a post answers your question, please click Mark As Answer on that post and Vote as Helpful

  • Permissions required to deploy an "SharePoint hosted App" using VS 2013

    Hello,
    I'm trying to deploy a SharePoint Hosted App to an OnPrem SP2013 server.
    When i hit F5 (from VS 2013) i get the below error:
    "Error occurred in deployment step 'Uninstall app for SharePoint': The local SharePoint server is not available. Check that the server is running and connected to the SharePoint farm."
    I'm added to the Farm Administrators group, site collection admin and to the admin group of the box. But i do not have any db_Owner permissions the the config / content database.
    Do I need DB Access to deploy the apps? Please advice. 
    Thanks,
    Keerth
    Keerth R

    >>Do I need DB Access to deploy the apps? Please
    advice.
    Yes, you need to have db_owner permissions for the account which you are using to deploy the apps.
    http://www.sharepoint-journey.com/app-development-in-sharepoint.html
    My Blog- http://www.sharepoint-journey.com|
    If a post answers your question, please click Mark As Answer on that post and Vote as Helpful

Maybe you are looking for