Everything began from nothing.

Showing posts with label 2013. Show all posts
Showing posts with label 2013. Show all posts

Wednesday, 22 March 2017

PropretyBag with JavaScript in SharePoint 2013




Hello,
as we know, Property bag are very important in SharePoint development, and to get it with JavaScript is very simple :



//wait until client object model dependencies are loaded before executing our code
ExecuteOrDelayUntilScriptLoaded(getWebProperties, "sp.js");
var webProperties;
function getWebProperties() {
    var clientContext = new SP.ClientContext.get_current();
    webProperties = clientContext.get_web().get_allProperties();
    clientContext.load(webProperties);
    clientContext.executeQueryAsync(Function.createDelegate(this, this.getWebPropertiesSucceeded), Function.createDelegate(this, this.onQueryFailed));
}
function getWebPropertiesSucceeded() {
          //debugger; //use this to force a break here
    //returns an object with all properties. 
          //Use the quick watch to expand this out to see all of them.
    var allProps = webProperties.get_fieldValues();
    var customProp = "";
         //make sure the property is there before using it.
    if(webProperties.get_fieldValues().CustomSite_Version != undefined)
    {
        var customProp = webProperties.get_fieldValues().CustomSite_Version;
    }
    alert(customProp);
}
function onQueryFailed(args, sender)
{
     //handle errors here
}



-----------
var customProp = webProperties.get_fieldValues().CustomSite_Version;

Monday, 20 February 2017

SharePoint Framework / NodeJS ( setup envoriment)


Hello SharePointiens,

i will show you how we configure our workspace to work with Sharepoint Framework:
Tools :
NodeJS server.
Visual Studio Code.
Cmder.

Open cmder :
d:/
mkdir workspace
cd workspace
mkdir SPFramework
cd SPFramework
mkdir HelloWorld
cd HelloWorld



now we should install yoman :
# install yo & gulp


npm install yo gulp
# install Sharepoint generator
npm install --global @microsoft/sharepoint-generator
# create a new project
yo @microsoft/sharepoint














specify he solution name,the target of the project , ....
install the certification SSL : gulp trust-dev-cert
to test if its ok run
gulp serve

the browser will open a new workbench page to test your sharepoint webpart on your localhost machine.



if you have this errors :
Error - typescript - node_modules@types\lodash\index.d.ts(11444,21): error TS1005: ']' expected.
Error - typescript - node_modules@types\lodash\index.d.ts(11444,22): error TS1005: ';' expected.
Error - typescript - node_modules@types\lodash\index.d.ts(11444,23): error TS1128: Declaration or statement expected.
Error - typescript - node_modules@types\lodash\index.d.ts(11444,33): error TS1005: ']' expected.
Error - typescript - node_modules@types\lodash\index.d.ts(11444,34): error TS1005: ')' expected.
Error - typescript - node_modules@types\lodash\index.d.ts(11444,35): error TS1128: Declaration or statement expected.
Error - typescript - node_modules@types\lodash\index.d.ts(11444,37): error TS1128: Declaration or statement expected.
Error - typescript - node_modules@types\lodash\index.d.ts(19441,1): error TS1128: Declaration or statement expected.

Execute this : npm install @types/lodash@4.14.50
then : gulp serve