Using PNPJavascript Block - Calling a Custom Javacript Function

Copper Contributor

I am able to to register a block but calling the booMonster function is not possible as the custom javascript library is not loaded yet?   Can I load a Block from a javascript file?

 

I am trying have a function called on every pages?

 

#
#

$ScriptName = "SayBoo"
$scriptBlock = "booMonster('monsterhere');"

try
{
#Connect to the SPO site
Connect-PNPOnline -Url https://myteams.qqq.com/sites/tmnaisa/IS/PlayArea -Credential sp

#Remove script if added before
Remove-PnPJavaScriptLink -Name $ScriptName

#Add the script
Add-PnPJavaScriptLink -Name $ScriptName -script $scriptBlock -Sequence 2000

}
catch
{
Write-Host "$_.Exception.Message"
}

Write-Host "Completed successfully." -ForegroundColor Green

1 Reply
I thought it is only possible with JSlink and not in libraries but i could be wrong here.Do not know how to add it via PowerShell