سؤال

I would like to add multiple User Custom Actions on several sites using PowerShell. The custom actions must be added in the top ribbon that is visible when selecting a list item. Is that even possible? When looking at SPList userCustomActions property, it is readonly, according to MSDN . Am I taking the wrong path? The property is readonly but the custom actions are there, so they must have been added.

So far I've been there.

$w = get-spweb $webUrl;
$l = $w.lists[$listTitle];
$userCustomActions = $l.userCustomActions;

Of course, custom Actions can be added via JS, C# + feature, SharePoint Designer. But I can't use those methods, So I'm only interested in PowerShell procedures.

هل كانت مفيدة؟

المحلول

You can use the UserCustomActions.Add() method to add the custom action.

Try and modify the below code:

$web = get-spweb $webUrl;
$list = $web.Lists[$listTitle];
$action = $list.UserCustomActions.Add();

$action.Url = "someurlhere";
$action.Location = "Ribbon.ListItem.Actions.Controls._children";
$action.Sequence = 85;
$action.Title = "Test Action";
$action.Description  = "Test Action description";

$action.Update();

MSDN - SPUserCustomActionCollection.Add

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى sharepoint.stackexchange
scroll top