• Aucun résultat trouvé

Adding Custom Actions

Dans le document Microsoft SharePoint Designer 2010 (Page 126-130)

The term custom actions is used twice in SharePoint Designer . First , it refers to the abil-ity to extend SharePoint Designer workflows by adding custom actions and custom conditions created by a developer and installed on the Web server . Second, and new to SharePoint Designer 2010, it refers to the ability to add new actions to the list item menu (LIM) and the server ribbon that you see in the browser on the list views and forms . This allows you to add content to the list item menu or server ribbon without involving a de-veloper or the IT department .

Custom actions should be added to facilitate the tasks needed to complete a business process . For example, if you commonly need to create a task item every time you create an announcement item, then place a custom action on the server ribbon of list views . Custom actions appear as buttons and can be accompanied by an image .

When you define a custom action for the list item menu or the server ribbon, you can specify a number, known as a sequence number, that defines the order in which the ac-tion appears on the list item menu or the server ribbon .

For example, in the browser, when you display an Announcements list and then select the arrow to the right of an announcement item, the list item menu contains the actions View Item, Edit Item, Alert Me, Manage Permissions, and Delete Item . On a site created using SharePoint Server, additional actions are displayed, such as Compliance Details . These default actions are also associated with a sequence number . The sequence num-bers for the default actions are not visible in SharePoint Designer, but with some testing you can discover them by trying different numbers as the sequence number when you add your own actions . For example, if you want users to quickly create a new Task item by using the Tasks list’s NewForm .aspx page, choose a sequence number of 50 to place the New Task Item action at the top of the item menu . A sequence number of 2,000 places the New Task Item action below the Delete Item action . To create the New Task Item action between the Edit Item and Alert Me actions, choose a sequence number be-tween 300 and 1,000 .

When you define your custom action, you can also specify a Rights Mask that de-fines which users can see the custom action . The Rights Mask can contain any of the SPBasePermission member names that are listed at http://msdn.microsoft.com/en-us/

library/microsoft.sharepoint.spbasepermissions.aspx . When you want the custom action to appear for any user of the list, leave the Rights Mask empty or type EmptyMask .

Using SharePoint Designer, you cannot remove a custom action, add other forms of actions (such as check boxes, combo boxes, drop-down lists, text boxes, and flyout an-chors), or add tabs or groups . Developers can create such actions and extend the server ribbon on pages other than the view and form pages, as well as the list item menu, by creating a feature in Visual Studio 2010 with the SharePoint Ribbon project template, which can be found at http://code.msdn.microsoft.com/vsixforsp . This Web site also con-tains a hands-on lab and a walkthrough video .

In this exercise, you upload new image files to the Site Assets library and then use those images when you add a custom action to a list item menu .

SET UP Using SharePoint Designer, open the team site you used in the previous exercise, if it is not already open.

1.

In the Navigation pane, click Site Assets, and then click Import Files in the New group on the ribbon .

The Import dialog box opens .

2.

Click Add File to display the File Open dialog box .

mpor Fi es

3.

Navigate to the Chapter03 practice file folder and use the CRTL or SHIFT key to select the images you want to import, such as b NewTask16x16 .png, b NewAnn16x16 .gif, and b NewAnn32x32 .png .

4.

Click Open, and then click OK to close the File Open and Import dialog boxes . The image files are imported .

5.

In the Navigation pane, click Lists and Libraries, and then in the workspace click Announcements to display the list settings page in the workspace .

6.

In the Custom Actions area, click New .

Tip The Custom Actions area is at the bottom right on the list settings page. You might need to scroll down to see it. Alternatively, collapse the Views, Forms, and Workflows areas by clicking their titles or by clicking the up arrow to the right of the area titles.

The Create Custom Action dialog box opens .

7.

In the Name box, type New Task Item, and in the Description box, type Custom action to create a new task item .

8.

Under Select the type of action, select Navigate to URL, and then click Browse . The Insert Hyperlink dialog box opens .

9.

Navigate to the Tasks list’s New form by double-clicking Lists and then Tasks . Click NewForm.aspx .

Note You can navigate to another Web site or Internet site from this dialog box.

10.

Click OK to close the Insert Hyperlink dialog box .

11.

In the Create Custom Action dialog box, scroll down . Under Advanced Custom actions options, to the right of the Button image URL (16x16) box, click Browse . The Insert Hyperlink dialog box opens .

12.

Navigate to SiteAssets by using the Up One Folder button to the right of the Look In box . Click the image you want to use, such as b NewTask16x16, and then click OK to close the Insert Hyperlink dialog box .

New

Up One Fo der

Tip If you plan to create a site template, do not use absolute URL addresses. Instead, use the ~site token to point to the location of the file, such as ~site/SiteAssets/b NewTask16x16.png. Then, when you create a site from your site template, the custom action will search for the image file in the new site’s Site Assets library.

13.

In the Rights mask box, type EditListItems .

This custom action will appear only on the item menu if the user has permission to edit list items on the Announcements list .

14.

In the Sequence number (optional) box, type 2000 .

15.

Click OK .

The Create Custom Action dialog box closes . In the Custom Actions area, the cus-tom action New Task Item appears as a list item menu (LIM) action with a sequence number of 2,000 .

CLEAN UP Leave SharePoint Designer open if you are continuing to the next exercise.

Dans le document Microsoft SharePoint Designer 2010 (Page 126-130)