Wednesday, December 9, 2020

How to trigger Power Automate during debug, test and production stage, to prevent infinite loop, with SharePoint item events

Some post recommends to set up a extra column to apply the control. It definitely works, but it needs extra column and extra actions.

Here is something much easier.

1. Define at least three dedicated user accounts

For example, tester1@company.com, developer1@company.com, PowerAutomateService@company.com

The first two accounts are for tester and developer. Power Automate runs under PowerAutomateService@company.com.

2. Change the settings of the trigger conditions


During debugging:

@equals(triggerOutputs()?['body/Editor/Email'],'developer1@company.com')

During testing:

@equals(triggerOutputs()?['body/Editor/Email'],'tester1@company.com')

During production:

@not(equals(triggerOutputs()?['body/Editor/Email'],'PowerAutomateService@company.com'))


PS: It needs three extra user subscriptions in this case, but hopefully our company doesn't mind.

Thursday, July 30, 2020

Use Power Automate to replace SharePoint workflows ...... serious?!

Two weeks ago, I got the notification email from Microsoft, which claimed that SharePoint workflow (2010) on SharePoint Online platform would retire by Nov 1st, 2020.

I was shocked. I thought the date should be around 2026!

My company have hundreds of SharePoint workflows. How can we migrate them to Power Automate in less than four months?!

To me, Power Automate is not mature enough yet. I planned to do the migration at around 2023 or 2024, but now ...... anyway, there is no other choice.

A few questions popped up.

1. Can I migrate those workflows directly?


No. I have to train end users how to develop Power Automate flow, and then ask them to do the migration!

Why? See below.

Power Automate per user plan 5,000
Office licenses (that include Power Apps/Power Automate) 2,000



If I do the migration, I would have to purchase an extra license for a service account, then use the service account to connect the flow to SPO, OUTLOOK, TEAMS, etc. Hundreds of flows would contain thousands of actions, then it would hit the daily limit immediately.

2. How long it would take to teach thousands of users to build complex Power Automate flow? And support them?


Forever?

3. When a user left company, what should I do with the Power Apps and Power Automate he/she created?


Microsoft support provides the link below. It works, but how many hours are needed for each Power Automate flow?




I feel sad and angry. The boat is sinking, and there is nothing I can do.


Tuesday, December 17, 2019

Resolved - cannot create list/document library/post/link/App from home page in SharePoint Online?

Normally we can create list/document library/post/link/App directly from home page, as the screenshot below shows.



However, sometimes, these links are missing.
 
 
What happened? Not sure. But you can reactivate the site feature "Wiki Page Home Page" to recover those links.



ps: During my test, no content in the home page is lost.


Monday, December 9, 2019

The possibly best way to return value from function in PowerShell

"Return value" from function is tricky in PowerShell.

By default, PowerShell functions work so that when executed, they write to the $Result array all the values that were displayed during the function’s operation.

This makes "Return value" useless.

How should we handle "return value" of function then? I don't want to use global variable, so, reference variable seems the only choice, as it chooses the correct data type automatically.

Below are some sample code. Please let me know if you have better idea!

  • Sample code 1
Function TestFunctionReturnValue{
    [cmdletbinding()]
    param(
        [Parameter(Mandatory=$true)][AllowEmptyString()][string]$Para1,
        [ref]$ParaReturnObject
    )
    $ParaReturnObject.Value = $false
    if ($Para1){
        $ParaReturnObject.Value  = $true
    }
}

$testResult1 = $null
$testResult2 = $null

TestFunctionReturnValue "hello" ([ref]$testResult1)
TestFunctionReturnValue "" ([ref]$testResult2)

Write-Host "testResult1 = $testResult1"
Write-Host "testResult2 = $testResult2"

$testResult1.GetType().FullName
$testResult2.GetType().FullName

Result:
  • Sample code 2
Function TestFunctionReturnValue2{
    [cmdletbinding()]
    param(
        [Parameter(Mandatory=$true)][AllowEmptyString()][string]$Para1,
        [ref]$ParaReturnObject
    )
    $ParaReturnObject.Value = 100
    if ($Para1){
        $ParaReturnObject.Value  = 200
    }
}

$testResult1 = $null
$testResult2 = $null

TestFunctionReturnValue2 "hello" ([ref]$testResult1)
TestFunctionReturnValue2 "" ([ref]$testResult2)

Write-Host "testResult1 = $testResult1"
Write-Host "testResult2 = $testResult2"

$testResult1.GetType().FullName
$testResult2.GetType().FullName

Result:

Friday, May 31, 2019

(fixed) Import-Module: The specified module was not loaded because no valid module file was found in any module directory

I tried to load module 'CredentialManager' through the script below:

Import-Module CredentialManager -DisableNameChecking

And got error:

Import-Module: The specified module "CredentialManager" was not loaded because no valid module file was found in any module directory

Then I ran "Get-InstalledModule" to check it.

No problem, the module was installed. Then why I cannot import it?

$env:PSModulePath shows:

C:\Users\username\AppData\Local\Apps\SharePointPnPPowerShellOnline;C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell
\v1.0\Modules;C:\Program Files\SharePoint Online Management Shell\

Emmm...."C:\Users\username\Documents\WindowsPowerShell\Modules
C:\Program Files\WindowsPowerShell\Modules" is not there.

I can fix the problem by adding this path to PSModulePath environment variable. But, I believe the better way is to re-install "CredentialManager".

Uninstall-Module CredentialManager
Install-Module CredentialManager

After the re-installation, this module appeared in "C:\Program Files\WindowsPowerShell\Modules"

Great!

Thursday, May 30, 2019

When to use folder in SharePoint list/library?

Just read a nice article. I agree with Joanne Klein, but I only see two practical reasons to use folder.

1. Permission control.
2. Too many items in one list/library.

So, if there is choices, go for metadata!

Office 365 is too complicated!

At the moment, I can see 23 Apps under Office 365.

How can we train thousands of users to understand when to use which one?

In my opinion, we only need three apps, and Dynamics 365 should not be part of Office 365.

1. Synchronous communication: Online chatting service(Teams)
2. Asynchronous communication: Email(Outlook)
3. Information management: SharePoint

Most of those apps should join SharePoint. They are:

Calendar,Delve, Excel, Flow, Forms, OneDrive, OneNote, People, Planner, PowerBI, PowerApps, PowerPoint, Stream, Sway, Tasks, To-Do, Video, Word, Yammer

So, why it is so complicated? For more subscription fees?

https://www.office.com/apps?auth=2&home=1