On your Developer Site, open the "Napa" Office 365 Development Tools and then choose Add New Project.
- Choose the App for SharePoint template, name the project Create Site and then choose the Create button
- Replace APP.js with the source code below
- Publish Your App.

Prerequisites
The following is an important procedure to be done before creating the app. Specify the permissions that your app needs as in the following. Choose the Properties button at the bottom of the page.
- In the Properties window, choose Permissions.
- In the Content category, set the Write permissions for the Tenant scope.
- In the Social category, set the Read permissions for the User Profiles scope.
- Close the Properties window.

Default Aspx

Source Code
- 'use strict';
- var hostweburl;
- var appweburl;
- // Get the URLs for the app web the host web URL from the query string.
- $(document).ready(function () {
- //Get the URI decoded URLs.
- hostweburl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
- appweburl = decodeURIComponent(getQueryStringParameter("SPAppWebUrl"));
- // Resources are in URLs in the form:
- // web_url/_layouts/15/resource
- // Load the js file and continue to load the page with information about the folders.
- // SP.RequestExecutor.js to make cross-domain requests
- $.getScript(hostweburl + "/_layouts/15/SP.RequestExecutor.js",getuserpermission);
- });
- function getuserpermission () {
- var executor;
- //var userEmail="[email protected]";
- // Initialize the RequestExecutor with the app web URL.
- executor = new SP.RequestExecutor(appweburl);
- executor.executeAsync({
- url: appweburl + "/_api/SP.AppContextSite(@target)/web/RoleDefinitions?@target='" + hostweburl + "'",
- method: "GET",
- headers: {
- "Accept": "application/json; odata=verbose"
- },
- success: getPermissionLevelsSuccessHandler,
- error: getPermissionLevelsErrorHandler
- });
- }
- //Populate the selectPermissionLevels control after retrieving all of the site permission levels.
- function getPermissionLevelsSuccessHandler(data) {
- var jsonObject = JSON.parse(data.body);
- var PermissionLevels = document.getElementById("retrivePermissionLevels");
- if (PermissionLevels.hasChildNodes()) {
- while (PermissionLevels.childNodes.length >= 1) {
- PermissionLevels.removeChild(PermissionLevels.firstChild);
- }
- }
- var results = jsonObject.d.results;
- for (var i = 0; i < results.length; i++) {
- var retrivegroup = document.createElement("option");
- retrivegroup.value = results[i].Name;
- retrivegroup.innerText = results[i].Name;
- PermissionLevels.appendChild(retrivegroup);
- }
- }
- function getPermissionLevelsErrorHandler (data, errorCode, errorMessage) {
- alert("Could not get site permission levels: " + errorMessage);
- }
- //Utilities
- // Retrieve a query string value.
- // For production purposes you may want to use a library to handle the query string.
- function getQueryStringParameter(paramToRetrieve) {
- var 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];
- }
- }

Output: Role permission retrieved Successfully.


Vijay SPosted Apr 8, 2015, 9:13 AM
Good article
Gowtham RajamanickamPosted Apr 1, 2015, 1:06 AM
thank so much all
Gowtham RajamanickamPosted Apr 1, 2015, 1:06 AM
thank u karthikl
Karthik Muthu KaruppanPosted Mar 31, 2015, 10:58 AM
cool