Skip to main content

Posts

Showing posts from 2021

NPM Dedupe

  What is NPM Dedupe? deduped  is short for "deduplicated" (duplicates were removed).  The documentation for   npm dedupe   explains how   npm does   this. The command searches the local package tree and attempts to simplify the overall structure by moving dependencies further up the tree, where they can be more effectively shared by multiple dependent packages.

Nintex form business days calculator

  function doCalc() {   var myDate = NWF$(‘.cssDateChosen’).find(‘input’);   var dFuture = new Date(“December 31, 2015”);   dFuture = new Date(myDate.val());   var dNow = new Date();   var result = calcBusinessDays(getDateOnly(dNow),getDateOnly(dFuture));   alert(‘Num of Business Day between Future date and now : ‘ + result + ‘ days’); } function dateBusinessDayValidation(source, arguments) {   arguments.IsValid=true;   var myDate = NWF$(‘.cssDateChosen’).find(‘input’);   var dFuture = new Date(myDate.val());   var dNow = new Date();   var result = calcBusinessDays(getDateOnly(dNow),getDateOnly(dFuture));   if(result < 30)   {        arguments.IsValid = false;   } } function calcBusinessDays(dDate1, dDate2) {  // input given as Date objects  var iWeeks, iDateDiff, iAdjust = 0;  if (dDate2 < dDate1)   return -1; // error code if dates transposed  var iWe...

Logged in user details

  var clientContext; var user; // Make sure the SharePoint script file 'sp.js' is loaded before your // code runs. SP.SOD.executeFunc( 'sp.js' , 'SP.ClientContext' , sharePointReady); function sharePointReady() { clientContext = SP.ClientContext.get_current(); user = clientContext.get_web().get_currentUser(); clientContext.load(user); clientContext.executeQueryAsync(onQuerySucceeded, onQueryFailed); } function onQuerySucceeded() { alert( 'The email address of the current user is ' + user.get_email()); alert( 'The account name is ' + user.get_loginName()); } function onQueryFailed(sender, args) { alert( 'Error: ' + args.get_message()); }

How to return internal field columns from SharePoint API query

  6 The query  /_api/lists/getbytitle('<list title>')/items?$select=*  returns list items for  visible fields  only ( SP.Field.hidden property  is set to  false ). To be more precise the expression  $select=*  returns: visible  fields values (query that returns visible field names:  /_api/Web/Lists/getByTitle('<list title>')/fields?$select=InternalName&$filter=Hidden eq false ) FileSystemObjectType  hidden field value not all  visible field values are returned, for example  ItemChildCount  is not available: How to return an additional fields In order to return  an additional fields , the field name(s) have to be specified explicitly using  $select  query option. For example, to return hidden system field  FileRef  you could utilize the following query: /_api/Web/Lists/getByTitle( '<list title>' )/items? $select =FileRef or /_api/Web/Lists/getByTitle( '<list title...

Get all fields from a library Javascript

  // Open current SPWeb: _spPageContextInfo.webServerRelativeUrl var ctx = new SP.ClientContext(_spPageContextInfo.webServerRelativeUrl); // Get Documents library var list = ctx.get_web().get_lists().getByTitle( 'TEST' ); //get_fields() returns SP.FieldCollection object --- contains all SP.Field object properties > https://msdn.microsoft.com/en-us/library/office/jj246815.aspx var fieldCollection = list.get_fields(); ctx.load(fieldCollection, 'Include(InternalName,StaticName)' ); var view = list.get_views().getByTitle( 'All Documents' ); //get_viewFields() returns SP.ViewFieldCollection object --- only field names (Internal Names), but not a SP.Field object > https://msdn.microsoft.com/en-us/library/office/jj244841.aspx var viewFieldCollection = view.get_viewFields(); ctx.load(viewFieldCollection); ctx.executeQueryAsync( function (){          var cont= 0 ;          var fields = 'SP.FieldCo...

SharePoint REST API QUERY

Ajax query construct $.ajax({    url: url, //THE ENDPOINT    method: "GET",    headers: { "Accept": "application/json; odata=verbose" },    success: function (data) {         console.log(data.d.results) //display result    } }); Selecting all items, all columns /_api/web/lists/getbytitle('listname')/Items?$select=*

The _spPageContextInfo

I f you are creating a SharePoint app using JavaScript and the Client side object model you need this friendly object. In the development of an app, you would require some basic properties- SharePoint as a framework provides these with the  _spPageContextInfo  object. _  spPageContextInfo  will provide these below properties:  webServerRelativeUrl  webAbsoluteUrl siteAbsoluteUrl serverRequestPath layoutsUrl webTitle webTemplate tenantAppVersion isAppWeb webLogoUrl webLanguage currentLanguage currentUICultureName currentCultureName env nid fid clientServerTimeDelta updateFormDigestPageLoaded siteClientTag crossDomainPhotosEnabled webUIVersion webPermMasks pagePersonalizationScope userId userLoginName systemUserKey alertsEnabled siteServerRelativeUrl allowSilverlightPrompt themedCssFolderUrl themedImageFileNames