Configure SharePoint APPs in development Server

—————–Steps for Creation of an isolated app domain on development computer —————————-
1:Start the SharePoint 2013 Management Shell.

net start spadminv4
net start sptimerv4

Create your isolated app domain your apps, for example “apps.developement.local”.
1:Set-SPAppDomain “apps.developement.local”

Ensure that the SPSubscriptionSettingsService and AppManagementServiceInstance services are running.
1:Get-SPServiceInstance | where{$_.GetType().Name -eq “AppManagementServiceInstance” -or $_.GetType().Name -eq “SPSubscriptionSettingsServiceInstance”} | Start-SPServiceInstance

Verify that the SPSubscriptionSettingsService and AppManagementServiceInstance services are running.
1:Get-SPServiceInstance | where{$_.GetType().Name -eq “AppManagementServiceInstance” -or $_.GetType().Name -eq “SPSubscriptionSettingsServiceInstance”}
–To create new Manage account [run the below command if manage account is not present——

$account = New-SPManagedAccount

After that run below commands:

$account = Get-SPManagedAccount “domainname\username”
$appPoolSubSvc = New-SPServiceApplicationPool -Name SettingsServiceAppPool -Account $account
$appPoolAppSvc = New-SPServiceApplicationPool -Name AppServiceAppPool -Account $account
$appSubSvc = New-SPSubscriptionSettingsServiceApplication –ApplicationPool $appPoolSubSvc –Name SettingsServiceApp –DatabaseName SettingsServiceDB
$proxySubSvc = New-SPSubscriptionSettingsServiceApplicationProxy –ServiceApplication $appSubSvc
$appAppSvc = New-SPAppManagementServiceApplication -ApplicationPool $appPoolAppSvc -Name AppServiceApp -DatabaseName AppServiceDB
$proxyAppSvc = New-SPAppManagementServiceApplicationProxy -ServiceApplication $appAppSvc
Set-SPAppSiteSubscriptionName -Name “app” -Confirm:$false

 

Advertisements

Rest API code to add folders to SharePoint Library

I have a requirement to add folders to library from client side .The requirement is like when a file will upload to a library it will check for the folder structure like current year->current Month->current Date .If folders are not there folder should be created and file will be upload to the current date folder.So here I am uploading the iterative folder creation with a structure of   lib name->2016->6->13062016  .

This is basically a rough code not managed well.

 

var date = new Date();
var month = date.getMonth() + 1;
var year = date.getFullYear();
//var dateF = date.format(‘d-M-Y’);dd-MM-yy
var dateF = date.format(‘dd-MM-yyyy’);
var dateURL = “”;
var list = [];
var flag;

$(document).ready(function () {

$(“#btnClick”).click(function () {

var folderURL = “test”;
var numbers = { “year”: year, “month”: month, “date”: dateF, “listarray”: “” };
var folderDisplyURL=””;
$.each(numbers, function (index, value) {

if (index == “year”) {

folderURL1 = publicMethod.GetFolder(year, folderURL, “year”);

}
else if (index == “month”) {

folderURL1 = publicMethod.GetFolder(month, folderURL + “/” + year, “month”);

}
else if (index == “date”) {

folderURL1 = publicMethod.GetFolder(dateF, folderURL + “/” + year + “/” + month, “date”);

}
else if (index == “listarray”) {
$.each(list, function (index, value) {

var pCreate = $.ajax({
“url”: _spPageContextInfo.webAbsoluteUrl + “/_api/Web/Folders/add(‘” + value + “‘)”,
“type”: “POST”,
async: false,
“headers”: {
“accept”: “application/json; odata=verbose”,
“content-type”: “application/json; odata=verbose”,
“X-RequestDigest”: $(“#__REQUESTDIGEST”).val()
}
});

$.when(pCreate).always(function (data) {

try {
flag = “created”;
folderDisplyURL = _spPageContextInfo.webAbsoluteUrl + data.d.ServerRelativeUrl;
}
catch (err) {

}

});

});
}

if (folderDisplyURL != “”) {

if (flag == “created”) {
alert(“Folder created URL :” + folderDisplyURL);
}
}
});

});
});

var publicMethod =
{
GetFolder: function (folderName, folderURL, flag) {

var folderURL2 = “”;

var requestUri = _spPageContextInfo.webServerRelativeUrl + “/_api/Web/GetFolderByServerRelativeUrl(‘” + folderURL + “‘)/Folders?$filter=Name eq ‘” + folderName + “‘”;
)
var returnURL = “”;
$.ajax(
{
url: requestUri,
type: “GET”,

data: JSON.stringify({ ‘__metadata’: { ‘type’: ‘SP.Folder’ }, ‘ServerRelativeUrl’: folderURL }),
headers: {
“accept”: “application/json;odata=verbose”
},
success: onSuccess,
error: onError,
async: false
}
);

function onSuccess(data) {

if (data.d.results.length == 0) {
list.push(folderURL+”/”+folderName);

}
}

function onError(error) {

}
return folderURL2;

},

getFormDigest: function (webUrl) {
return $.ajax({
url: webUrl + “/_api/contextinfo”,
method: “POST”,
headers: { “Accept”: “application/json; odata=verbose” }
});
},
CreatF: function (folderURL, folderName)
{
var requestUri = _spPageContextInfo.webAbsoluteUrl + “/_api/web/folders”;
$.ajax({
url: requestUri,
type: “POST”,
data: JSON.stringify({ ‘__metadata’: { ‘type’: ‘SP.Folder’ }, ‘ServerRelativeUrl’: folderURL + “/” + folderName }),
headers: {
“accept”: “application/json;odata=verbose”,
“content-type”: “application/json;odata=verbose”,
“X-RequestDigest”: $(“#_REQUESTDIGEST”).val()
},
success: onSuccess1,
error: onError1
});

function onSuccess1(data) {
debugger;
alert(folderName+’Folder created successfully’);
}

function onError1(error) {
debugger;
alert(JSON.stringify(error));
}
},
CreateFolder: function (folderURL) {

var requestUri = _spPageContextInfo.webAbsoluteUrl + “/_api/web/folders”;
return publicMethod.getFormDigest(_spPageContextInfo.webAbsoluteUrl).then(function (data) {
$.ajax(
{
url: requestUri,
type: “POST”,
async: false,
data: JSON.stringify({ ‘__metadata’: { ‘type’: ‘SP.Folder’ }, ‘ServerRelativeUrl’: folderURL }),
headers: {
“accept”: “application/json;odata=verbose”,
“content-type”: “application/json;odata=verbose”,
//”X-RequestDigest”: $(“#_REQUESTDIGEST”).val()
“X-RequestDigest”: data.d.GetContextWebInformation.FormDigestValue
},
success: onSuccess1,
error: onError1

}
);
function onSuccess1(data) {
debugger;
alert(folderURL + ‘ Folder created successfully’);

}

function onError1(error) {
debugger;

alert(JSON.stringify(error));
}
});
return folderName;

},
}

How to connect to AZURE DB from your local SSMS

Full Post :

Connect to SQL Server on Azure VM via Local SSMS

Working with SPservices

Reference :

 

SPServices Stories #2 – Charting List Data with HighCharts

Caml Query For User Type field

Option 1 –  If you know the display name of the user

 <Where>
   <Eq>
      <FieldRef Name='User_x0020_ID' />
      <Value Type='User'>System Account</Value>
   </Eq>
 </Where>

Option 2 – If you know the User Id ( not the login id)

 <Where>
    <Eq>
       <FieldRef Name='User_x0020_ID' LookupId='True'  />
       <Value Type='User'>1073741823</Value>
    </Eq>
 </Where>

Option 3 – If you would like to filter based on current user (logged in User )

 <Where>
    <Eq>
       <FieldRef Name='User_x0020_ID'/>
       <Value Type='User'><UserID/></Value>
    </Eq>
 </Where>

Key Up Function in Jquery

$.event.special.inputchange = {
setup: function() {
var self = this, val;
$.data(this, ‘timer’, window.setInterval(function() {
val = self.value;
if ( $.data( self, ‘cache’) != val ) {
$.data( self, ‘cache’, val );
$( self ).trigger( ‘inputchange’ );
}
}, 20));
},
teardown: function() {
window.clearInterval( $.data(this, ‘timer’) );
},
add: function() {
$.data(this, ‘cache’, this.value);
}
};

$(‘input’).on(‘inputchange’, function() {
$(‘p’).text(this.value);
});
$(“input”).keyup(function () {
$(‘h1’).text(this.value);
});

The difference between Keyup and the custom function inputchange is
the keyup function will not work while you will click on the cross x (which cames after you write something on the text box).

Ref- http://jsfiddle.net/LGAWY/

Update Sharepoint list item using REST API

$(document).ready(function () {

var itemProperties = { ‘Name’: ’19’ };
updateListItem(_spPageContextInfo.webAbsoluteUrl, ‘KVI’, ‘__bg40002300’, itemProperties, printInfo, logError);
function printInfo() {
console.log(‘Item has been created’);
}
function logError(error) {
console.log(JSON.stringify(error));
}
});

function updateJson(endpointUri, payload, success, error) {
$.ajax({
url: endpointUri,
type: “POST”,
data: JSON.stringify(payload),
contentType: “application/json;odata=verbose”,
headers: {
“Accept”: “application/json;odata=verbose”,
“X-RequestDigest”: $(“#__REQUESTDIGEST”).val(),
“X-HTTP-Method”: “MERGE”,
“If-Match”: “*”
},
success: success,
error: error
});
}

function getItemTypeForListName(name) {
return “SP.Data.” + name.charAt(0).toUpperCase() + name.slice(1) + “ListItem”;
}

function updateListItem(webUrl, listTitle, listItemId, itemProperties, success, failure) {
var listItemUri = webUrl + “/_api/web/lists/getbytitle(‘” + listTitle + “‘)/items(” + listItemId + “)”;
var itemPayload = {
‘__metadata’: { ‘type’: getItemTypeForListName(listTitle) }
};
for (var prop in itemProperties) {
itemPayload[prop] = itemProperties[prop];
}
updateJson(listItemUri, itemPayload, success, failure);
}