Get Custom App Properties Values from the SharePoint App Using JavaScript

Please refer to my previous article regarding "Set Custom App Properties in SharePoint App Model."

Step 1: Create SharePoint hosted App using Visual Studio 2013. Go to solution explorer.

explorer

Step 2: Open App.js file.

App.js

Step 3: Open App.js file. Copy and paste the following function in App.js file.

  1. function getQueryStringParameter(param)  
  2. {  
  3.     var params = document.URL.split("?")[1].split("&");  
  4.     for (var i = 0; i < params.length; i = i + 1)  
  5.     {  
  6.         var singleParam = params[i].split("=");  
  7.         if (singleParam[0] == param)  
  8.         {  
  9.             return singleParam[1];  
  10.         }  
  11.     }  
  12. }  
Step 4: Copy and paste the following code in the App. js file. Here I will get the hostweburl, Appweburl, list name and Appname.

App
  1. var hostWebUrl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));  
  2. var appWebUrl = decodeURIComponent(getQueryStringParameter('SPAppWebUrl'));  
  3. var listName = decodeURIComponent(getQueryStringParameter('ListName'));  
  4. var AppName = decodeURIComponent(getQueryStringParameter('AppName'));  
  5. console.log("List Name: " + listName);  
  6. console.log("App Name: " + AppName);  
Step 5: Save and deploy the solution. The output shows as follows.

output

Summary

In this article we have explored how to get custom App properties value from the SharePoint App using JavaScript.