How to fully defined and add a user custom action using PowerShell. I was able to define and add a custom action but I don't know how to point to a JS file that contains the JavaScript I would like to execute.
So far, I am there:
$web = Get-SPWeb $web;
$list = $web.lists[$listTitle];
$UCACollection = $list.userCustomActions;
$newUCA = $UCACollection.add();
$newUCA.CommandUIExtension = '<CommandUIExtension xmlns="http://schemas.microsoft.com/sharepoint/">' +
'<CommandUIDefinitions>' +
'<CommandUIDefinition Location="Ribbon.List.Actions.Controls._children">'+
'<Button Id="Ribbon.Documents.UCAID" '+
'Command="Notify" '+
'Sequence="0" '+
'Image16by16="/mysite/siteAssets/my-icon-16x16.png" '+
'Image32by32="/mysite/siteAssets/my-icon-32x32.png" '+
'Description="My description." '+
'LabelText="TitleofcustomAction" '+
'TemplateAlias="o1"/>' +
'</CommandUIDefinition>'+
'</CommandUIDefinitions>'+
'<CommandUIHandlers>'+
'<CommandUIHandler Command="Notify" '+
'CommandAction="javascript:JsFunctionInJsFileInSiteAssets();" />'+
'</CommandUIHandlers>'+
'</CommandUIExtension>';
$newUCA.Location = 'CommandUI.Ribbon.ListView';
$newUCA.Title = "MyTitle";
$newUCA.ScriptSrc = "/mysite/siteAssets/function.js";
$newUCA.update();
When using this script I receive :
Validation error has occurred. The property ScriptSrc can be used only if the property Location is set to "ScriptLink".
So, I do put ScriptLink inside, and then I receive :
Validation error has occurred. The property ScriptSrc can be used only if the property Location is set to "!ScriptLink".
What do I have to do to defined a complete and working list ribbon user custom action using PowerShell? When googling, I didn't find even a single example.