I'm trying to update a UserCustomAction that is set on a web. I am trying to update the ScriptSrc url of the action to include a query string parameter, ?rev=1, but it does not seem to be taking. mainly this is to "refresh" a custom action if the underlying JavaScript file is updated. The main portion of my function looks like this:
Begin {
$context = New-Object Microsoft.SharePoint.Client.ClientContext($Url)
$context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($credential.UserName,$credential.Password)
if($ActionType -eq "Site"){
$site = $context.Site
}
else{
$site = $context.Web
}
$customActions = $site.UserCustomActions
$context.Load($customActions)
}
Process {
try{
$customActions.GetById($Id).ScriptSrc = $ScriptSrc
$context.ExecuteQuery()
Write-Host "CustomAction $Id updated" -ForegroundColor Green
}
catch{
Write-Host -ForegroundColor Red $_.Exception.Message
}
}
End {
$context.Dispose()
}
When passing in my parameters for an existing UserCustomAction, it says it was successful, but the query string is not set. If I create the UserCustomAction initially with a query string parameter, it takes. It also says that ScriptSrc is a settable property, so I'm not understanding why it isn't updating in this case.