NVM is a life saver when you want to work with multiple version of node.js

NVM

Fixing – Error: Cannot find module ‘C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js’

A very common issue most people face when working with nvm tool is that after a fresh setup of this tool the npm command does not seem to find the npm-cli.js. The reason being that the setup process fail to copy few needed files to the expected location.

Though there is no official fix available for this issue as of now, a work around is available as below:

Existing environment:

  • Windows 10 professional x64
  • nvm installed path – C:\nvm

Steps

Visit the url – https://nodejs.org/en/download/releases/ and download the source for the node.js version that you are trying to work with.

Extract the zip content and copy the npm folder to “C:\nvm\v8.16.0\node_modules

once you are done with the above, you can use the npm command without any issue:

Note: You will need to repeat the above steps for each version of node.js that you are intending to use

if you don’t patch the installation as shown above, you will face with the following error:

Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:188:16)
    at bootstrap_node.js:609:3
module.js:549
    throw err;
    ^

Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:188:16)
    at bootstrap_node.js:609:3

SharePoint Developer box configured with email send/receive capability using SMTP Service + Visendo SmtpExtender

So you are one of those guy who want to setup a simple email send/receive capability to test various SharePoint notification mechanism for bunch of domain users.

The following were configured and tested in an environment of:

1. Windows Server 2012 R2 + Active Directory Installed + Required users added.

2. SharePoint 2013

3. Outlook 2013 client

Steps:

1. First of all you need to configure SMTP service in your dev. box.

https://technet.microsoft.com/en-us/library/cc263462%28v=office.15%29.aspx

Note: Though you have an engine which can forward messages across, you still don’t have the POP3 service available within your box (the POP3 service no longer comes with windows server, which was available back in those days when Windows Server 2003 was there).

so how do you get that as most of your client would look for POP3 at a minimal. this is where the Visendo comes into play (btw, if you want to really configure a fully fledged server go ahead and try the exchange server, but for development purposes you really don’t want to spend time configuring exchange isn’t it?.

Test whether the SMTP service is ready before moving to next step – :

2. Install the Visendo following the steps marked in here (the version I used was V1.1.2.637 Demo x64)

Refer to the manual I used here – https://www.dropbox.com/s/y54mkpojerlxfv6/VisendoSmtpExtender_manual_en.pdf?dl=0

The installation binary is here –

https://www.dropbox.com/s/wbrs0wu804xadql/VisendoSMTPExtender_Plus_x64.msi?dl=0

 

My setting for a test user tariqa@readylab.net is as follows:

image

image

Any settings you play with either Visendo / SMTP service, you need to restart both services

To restart Visendo service (click the Settings top tree node in the UI):

image

To restart the SMTP service:

WIN + R > Services.msc  > Look for “Simple Mail Transfer Protocol (SMTP) (right click and restart):

image

 

By now I am assuming that you have added necessary users to the Visendo to try the next step:

3. Configure outlook mail client to send/receive emails (since the idea is to test send/receive email for multiple users, I have set the configuration of outlook mail to prompt to choose the profile at start up):

How to make outlook prompt to choose profile:

image

image

 

Now to configure my test user tariqa@readylab.net, follow the screenshots:

image

image

image

 

image

 

image

 

Tested sending and receiving emails from/to outlook client:

image

 

Finally Testing the whole with SharePoint:

$email = "tariqa@readylab.net" $subject = "SharePoint routed email test" $body = "Email test body.. yey yey" $site = New-Object Microsoft.SharePoint.SPSite "http://pwcs.com.au" $web = $site.OpenWeb() [Microsoft.SharePoint.Utilities.SPUtility]::SendEmail($web,0,0,$email,$subject,$body) // A True or False will confirm the message has been sent or not

 

Throw it all to a console:

image

 

Observation/outcome:

1. Worried since the email did not come to outlook Sad smile, then started the usual check at the drop folder location:

– Found an unserved .eml reflecting the time that the email was sent. – wait.. just disappeared, hmm… just now the batch processing got invoked

2. now the email is received at the outlook end.

image

 

Happy configuring….

Some useful links I referred:

http://weblogs.asp.net/hpreishuber/free-pop3-for-windows-2012-server

http://www.visendo.com/download/visendosmtpextender/docs/VisendoSmtpExtender_manual_en.pdf

http://blogs.perficient.com/microsoft/2010/11/email-configuration-within-a-sharepoint-2010-development-environment/

http://www.falconitservices.com/support/KB/Lists/Posts/Post.aspx?ID=105

https://technet.microsoft.com/en-us/library/cc732046%28v=ws.10%29.aspx

http://blogs.msdn.com/b/pareshg/archive/2010/04/23/how-to-configure-incoming-and-outgoing-emails-in-sharepoint-server-2010.aspx

http://webvaultwiki.com.au/(S(02oa34jugewqyznj3f0qg1q3))/Default.aspx?Page=Switch-Between-Multiple-Outlook-Profiles&NS=&AspxAutoDetectCookieSupport=1

Client-side SharePoint PowerShell–Feature Activate/DeActivate

# Include SPPS Import-Module .\spps.psm1 # Setup SPPS Initialize-SPPS -siteURL "https://example.sharepoint.com/" -online $true -username "sitecollectionadmin@example.onmicrosoft.com" -password "password" # Activate Publishing Site Feature Activate-Feature -featureId "f6924d36-2fa8-4f0b-b16d-06b7250180fa" -force $false -featureDefinitionScope "Site" #Activate Publishing Web Feature Activate-Feature -featureId "94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb" -force $false -featureDefinitionScope "Web"

https://sharepointpowershell.codeplex.com/

Excel Service Configuration & OData access

Verify Application Pool.
Get-SPServiceApplicationPool | Select Name
Get the existing Application Pool.
$SvcAppPool = Get-SPServiceApplicationPool "SvcApp_SPServiceApplicationPool_01"
If you are creating a new application pool:
Determine which service account you will use to run the application pool that will be assigned to the.  If you need to, create and register a service account to run the Subscription Settings Service Application.
Create the Service Application Pool and register it to the Service Account.
$SvcAppPool = New-SPServiceApplicationPool -Name "SvcApp_SPServiceApplicationPool_01"$AppPool = New-SPServiceApplicationPool -Account (Get-SPManagedAccount Domain\SvcAccount)
Verify Application Pool.
Get-SPServiceApplicationPool | Select Name
Get the existing Application Pool.
$SvcAppPool = Get-SPServiceApplicationPool "SvcApp_SPServiceApplicationPool_01"
Open the SharePoint 2013 Management Shell as Administrator.
Create the Service Application and assign it to the Application Pool.
$SvcApp = New-SPExcelServiceApplication –ApplicationPool $SvcAppPool -Name "SvcApp_New-SPExcelServiceApplication_01"
Verify Service Application.
Get-SPServiceApplication | Select Name
Verify Service Application Proxy
Get-SPServiceApplicationProxy | Select Name

Fixing – The workbook cannot be opened

When opening an Excel workbook (.xlsx) in the browser the error "The workbook cannot be opened" is thrown:

This is caused by the account running Excel Services not having proper permissions to the Content Database.  When you upload an Excel workbook to a SharePoint library, the workbook is stored as blobs in the Content Database.  When you choose to open this in Excel Services, the account running Excel Services needs to retrieve and reassemble the workbook.  If the account running Excel Services lacks proper permissions, "The workbook cannot be opened".

We have a KB on how to resolve this issue:

The Excel Services Application for SharePoint 2010 does not load or display workbooks

http://support.microsoft.com/kb/981293

In this blog, I will step you through this KB; where to collect data and explain what the two below SharePoint Management Shell Commands do:

$w = Get-SPWebApplication –Identity <URL of the Web application>
$w.GrantAccessToProcessIdentity("<insert service account>")

e.g.

$w = Get-SPWebApplication –Identity http://win12sp13:7864
$w.GrantAccessToProcessIdentity("Readylab\svcDEVSvcApps")

You need to find the <URL of the Web application>.  To do this:

1. Browse to the report library where the failing workbook is located and make note of the URL.

2. Central Administration > Application Management > Manage web applications compare the URL to the list of Web Apps.  Find the correct Web App URL and add it to “URL of the web application”.

You now have the first command:

$w = Get-SPWebApplication –Identity http://tschauer

3. Central Administration > Security > Configure Service Accounts > from the first dropdown, select the application pool running "Excel Services Application" and add that account where is says “<insert service account>”.

You now have the second command:

$w.GrantAccessToProcessIdentity("Devtest\Excel_Services_Account")

So now you can run these commands by following the below steps:

1. Click Start, click All Programs.
2. Click Microsoft SharePoint 2010/2013 Products.
3. Click SharePoint 2010/2013 Management Shell.
4. At the Windows PowerShell command prompt (PS C:\>), type the following command, and then press ENTER:

$w = Get-SPWebApplication –Identity http://tschauer
$w.GrantAccessToProcessIdentity("Devtest\Excel_Services_Account")

When you run these commands you are:

1. Adding the account running Excel Services as a User to the Content Database (Security > Users).
2. Giving the account running Excel Services the SPDataAccess Membership (Account > Membership)
3. Giving the account running Excel Services Full Control to the Web Application (Via "Policy for Web Application")

Consuming OData feeds from Excel Services 2013

 

http://win12sp13:7864/_vti_bin/ExcelRest.aspx/ExcelStore/UnitRefs.xlsx/OData/

Service Host – http://win12sp13:7864/_vti_bin/ExcelRest.aspx

Library name – ExcelStore

ExcelSheet (which contains a table data, creating a data is VERY IMPORTANT) – UnitRefs.xlsx

oData – Call indicate that its a OData call.

 

image

 

You need to fully construct the Url for oData service call, just call up to the point of:

http://win12sp13:7864/_vti_bin/ExcelRest.aspx/ExcelStore/UnitRefs.xlsx/OData, then within the connection import wizard select the excel table to select.

image

http://win12sp13:7864/_vti_bin/ExcelRest.aspx
/ExcelStore/ProjectTenderMemberSizeInfo.xlsx/OData
/MemberSizeTable?$top=20

Calling a function from SP.JS (Open word document directly using client application)

When calling a function from SP.JS during the page load, just make sure that you allow the page to load before you call any method, otherwise you will get undefined error.

in my case, I was trying to open a word document using the function “editDocumentWithProgID2” defined in SP.JS as below:

<script type="text/javascript">

   $(function () {

        ExecuteOrDelayUntilScriptLoaded(LoadDoc, "sp.js");

        function LoadDoc() {

            JSRequest.EnsureSetup();
            var file2Open = JSRequest.QueryString["file2Open"];
            var baseUrl = JSRequest.QueryString["return2address"];
            if (typeof file2Open != "undefined" && file2Open != "") {

                var host = location.protocol + "//" + location.host;
                var docUrl = file2Open.replace(host, "");
                var i = file2Open.lastIndexOf("/");
                var listUrl = file2Open.substr(0, i);
                editDocumentWithProgID2(docUrl, ”, ‘SharePoint.OpenDocuments’, ‘0’, baseUrl, ‘0’);
                location.href = listUrl;
            }

        }
    });
   
</script>

without the document ready check this will complain that the “editDocumentWithProgID2” is undefined.

Btw, make sure that these two lines are present in your masterpage:

 

<SharePoint:ScriptLink Language="javascript" runat="server" Name="SP.js" Localizable="false" LoadAfterUI="true" OnDemand="true" />
        <SharePoint:ScriptLink Language="javascript" runat="server" Name="SP.Runtime.js" Localizable="false" LoadAfterUI="true" OnDemand="true" />

Formatting Number value with Percentage Mark (sign)

<td>
              <xsl:call-template name="percentformat">
                <xsl:with-param name="percent"
                     select="@_x007B_1585273a_x002D_2f76_x002D_47f7_x002D_9170_x002D_adc12250ce65_x007D_"/>
                  </xsl:call-template>
          </td>

    <xsl:template name="percentformat">
      <xsl:param name="percent"/>
      <xsl:value-of
         select="format-number($percent, ‘#,##0%;-#,##0%’)" />
    </xsl:template>

Content Query WebPart Examining Fields Available to Use

To examine the fields available within CQWP (Content query webpart) have this snippet available within your template:

e.g.

<xsl:template name="WMCustom" match="Row[@Style=‘WMCustom’]" mode="itemstyle">

<xsl:for-each select="@*"> 
    <xsl:value-of select="name()" />
</xsl:for-each>

To Print everything around the fields:

<xsl:for-each select="@*">
            <xsl:value-of select="name()"/><xsl:value-of select="." />
        </xsl:for-each>

<xsl:for-each select="@*">
  <br/>
  Name:<xsl:value-of select="name()"> </xsl:value-of>  Value:
  <xsl:value-of select="."></xsl:value-of>
</xsl:for-each>

When you have this above piece of code, the output would be something similar to:

You need to fish out the column name with known data, for example I know this item in list has a value “Amber” for status

ListId{D926A3A4-96F2-42E2-B640-994A7E2A5C76}WebId{96657F9F-CEE9-4903-9994-AA50173CDE20}ID1_x007B_fa564e0f_x002D_0c70_x002D_4ab9_x002D_b863_x002D_0177e6ddd247_x007D_Find a file_x007B_94f89715_x002D_e097_x002D_4e8b_x002D_ba79_x002D_ea02aa8b7adb_x007D_sites/WMHHS01/OfficeofCE/SPO/Project1/Lists/Project Summary/1_.000_x007B_1d22ea11_x002D_1e32_x002D_424e_x002D_89ab_x002D_9fedbadb6ce1_x007D_1_x007B_28cf69c5_x002D_fa48_x002D_462a_x002D_b5cd_x002D_27b6f9d2bd5f_x007D_2014-09-08 16:11:02_x007B_1df5e554_x002D_ec7e_x002D_46a6_x002D_901d_x002D_d85a3881cb18_x007D_Haylee Fox_x007B_d31655d1_x002D_1d5b_x002D_4511_x002D_95a1_x002D_7a09e9b75bf2_x007D_Haylee Fox_x007B_8c06beca_x002D_0777_x002D_48f7_x002D_91c7_x002D_6da68bc07b69_x007D_2014-09-08 13:02:08_x007B_30bb605f_x002D_5bae_x002D_48fe_x002D_b4e3_x002D_1f81d9772af9_x007D_0_x007B_ba3c27ee_x002D_4791_x002D_4867_x002D_8821_x002D_ff99000bac98_x007D_0x400000300c231061_x007B_c5c4b81c_x002D_f1d9_x002D_4b43_x002D_a6a2_x002D_090df32ebb68_x007D__x007B_8fca95c0_x002D_9b7d_x002D_456f_x002D_8dae_x002D_b41ee2728b85_x007D__x007B_39360f11_x002D_34cf_x002D_4356_x002D_9945_x002D_25c44e68dade_x007D__x007B_543bc2cf_x002D_1f30_x002D_488e_x002D_8f25_x002D_6fe3b689d9ac_x007D__x007B_43bdd51b_x002D_3c5b_x002D_4e78_x002D_90a8_x002D_fb2087f71e70_x007D_1_x007B_9da97a8a_x002D_1da5_x002D_4a77_x002D_98d3_x002D_4bc10456e700_x007D__x007B_d83a244e_x002D_e318_x002D_485e_x002D_b7fa_x002D_4a805041379c_x007D_Haylee Fox_x007B_0ab9ab33_x002D_4988_x002D_4786_x002D_9808_x002D_e5f24a488a7b_x007D_Amber_x007B_4ea8f163_x002D_c004_x002D_4fb2_x002D_a59f_x002D_7e33b8a46fc7_x007D_2014-09-08 00:00:00_x007B_b9e6f3ae_x002D_5632_x002D_4b13_x002D_b636_x002D_9d1a2bd67120_x007D__x007B_197cd0f9_x002D_80e7_x002D_4f87_x002D_83d7_x002D_9575e79ec29e_x007D_0.250000000000000_x007B_691b9a4b_x002D_512e_x002D_4341_x002D_b3f1_x002D_68914130d5b2_x007D_PubDateMon, 08 Sep 2014 06:11:02 GMTFileExtensionFileSizeDocumentIconImageUrl/_layouts/15/IMAGES/icgen.gifTitleFind a fileStreamLeadHaylee FoxLinkUrlhttps://healthqld.sharepoint.com/sites/WMHHS01/OfficeofCE/SPO/Project1/Lists/Project Summary/1_.000StylewmrollupstyleGroupStyleDefaultHeader__begincolumnFalse__begingroupFalse

now to use status column you need to grab the green highlighted column in front of the Amber value and use it as below:

<xsl:value-of select="@_x007B_0ab9ab33_x002D_4988_x002D_4786_x002D_9808_x002D_e5f24a488a7b_x007D_"/>

Making the DVWP (DataView/XSLT WebPart) reusable in any site collection

  1. Before exporting the data view webpart add an additional parameter using SharePoint designer parameter ribbon option, the final code for the parameter should look like the following: <WebPartPages:DataFormParameter Name="WebURL" ParameterKey="WebURL" PropertyName="ParameterValues" DefaultValue="/sites/toplvlsite/"/>
  2. Once a dataview webpart is created using SharePoint designer, perform an export using [WEB PART]\To File.
  3. Open the exported webpart file content in NotePad++
  4. Search for a line  <property name="ListName" type="string" and remove it. E.G: <property name="ListName" type="string">{2AA6099D-238B-4692-8BB4-48EFFB0952B1}</property>
  5. Remove the following elements and their content out of the file as we are only using the dataview to display content:
  6. <UpdateParameters>[Any Content]</UpdateParameters>
    <InsertParameters>[Any Content]</InsertParameters>
    <DeleteParameters>[Any Content]</DeleteParameters>

  7. Before doing the next step, replace the GUID assigned to the ListID parameter with ListName value (Get from List Settings > Name value) – Look for GUID with parenthesis as well { and }.
  8. Replace all occurrence of "ListID" to "ListName" and replace the defaultValue with the Name of the list.
  9. The following entry needs to be adjusted as well for string entry : <property name="ListName" type="System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">Issues</property>