Sunday, 6 February 2022

Task never defined: serve SPFX upgrade

Problem - After upgrading spfx project you will see the problem when executing gulp serve. 

Solution -  upgrade gulpfile.js serve refrence.


Gulp version - 3.xxx

'use strict';


const build = require('@microsoft/sp-build-web');

build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);

build.initialize(require('gulp'));


Upgrade gulp v4.0xxx

 'use strict';


const build = require('@microsoft/sp-build-web');

build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);

var getTasks = build.rig.getTasks;
build.rig.getTasks = function () {
  var result = getTasks.call(build.rig);

  result.set('serve', result.get('serve-deprecated'));

  return result;
};

build.initialize(require('gulp'));

Friday, 18 August 2017

Retrieving Access Request Email from SharePoint Site

The access request feature allows users to request access to site that they do not currently have permission to see. As a site owner, you can configure the feature to send you mail when someone requests access to a site for approval.

use the below code find out the  Access request owner using below JSOM code  


function getAccessRequestOwner() {
    var clientContext = SP.ClientContext.get_current();
    this.oWeb = clientContext.get_web();
    clientContext.load(this.oWeb, 'RequestAccessEmail');

    clientContext.executeQueryAsync(
        Function.createDelegate(this, this.onQuerySucceeded),
        Function.createDelegate(this, this.onQueryFailed)
    );
}

function onQuerySucceeded(sender, args) {
    console.log('RequestAccessEmail: ' + this.oWeb.get_requestAccessEmail());
}
   
function onQueryFailed(sender, args) {
    alert('Request failed. ' + args.get_message() +
        '\n' + args.get_stackTrace());
}


//Call function
getAccessRequestOwner();