Create User Defined Operations and Rights
- Last UpdatedJul 25, 2023
- 6 minute read
AVEVA Work Tasks has set of custom operations and set of custom rights on Repository, List and ListItem level. The custom operations like add, edit, delete and security etc. AVEVA Work Tasks has provided an option to user to add own custom operation(menu item) in context menu and also can define own custom rights based on the requirements and can use these rights and operations in the application.
For example, user wants to create a 'order' operations in context menu in the enterprise console application to see order details by clicking on the 'order' operator from context menu.
Adding a New Custom Operations and Custom Rights
The following example demonstrates creating a new custom operation in a context menu and as well as adding new rights for the created custom operation to control this action.
Example: The user wants to add a new custom operation called 'View Orders' in the context menu of the 'Product Categories' List.
The following steps explain the process to be followed:
-
Create a aspx page called 'Products' as shown below.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Products.aspx.cs" Inherits="Orders" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table width="100%" cellpadding="0" cellspacing="5" border="1">
<tr>
<td> Sl.No </td>
<td> Product </td>
</tr>
<tr>
<td>1</td>
<td>Books</td>
</tr>
<tr>
<td>2</td>
<td>Computer and Peripherals</td>
</tr>
<tr>
<td>3</td>
<td>Consumer Electronics</td>
</tr>
<tr>
<td>4</td>
<td>Kitchen and Home Appliance</td>
</tr>
<tr>
<td>5</td>
<td>Memory cards, pen drives and Harddisk</td>
</tr>
<tr>
<td>6</td>
<td>Mobiles and Accessories</td>
</tr>
<tr>
<td>7</td>
<td>Musical Instruments</td>
</tr>
<tr>
<td>8</td>
<td>Tools and Hardware</td>
</tr>
<tr>
<td>9</td>
<td>Video and Computer Games</td>
</tr>
<tr>
<td>10</td>
<td>Services</td>
</tr>
</table>
</div>
</form>
</body>
</html>
Note: Place 'Products.aspx', and 'Products.aspx.cs' in the [AVEVA Work Tasks Installed Path]\AVEVA\AVEVA Work Tasks\Web\BPMUITemplates\Default\Repository\Site folder.
-
Create one more aspx page called 'Custom Operations' as shown below.
Implementation part is outlined below:
-
First you have to create the list definition object by passing the Application Name (Repository name) and List Name to get the actions which are associated with the list definition. In this example, Application name set as 'ListSecurityRepo' and List name as 'NavigationDetails'.
-
After creating the list definition object, you will get the existing actions associated with that list.
-
Store all existing actions to new object.
-
Create a new action and set the new action properties like name, type, pagepath, iconpath, DisplayValidRightValues, and ActionAllowValidRightValues.
Name - Mention a name for the context menu. Here name is mentioned as 'View Products'.
Type - Mention a type. Here type is mentioned as 'MenuItem'.
PagePath - Mention a path of the aspx page to navigate by clicking on 'View Products' custom operation.
IconPath - Mention a image path. Here icon path mentioned as 'Edit'. Which is a class under [AVEVA Work Tasks Installed Path]\AVEVA\Work Tasks\Web\BPMUITemplates\Default\Repository\ListControl\Scripts\JsdoMenu\themes\office_xp. Here edit image is used for newly created context menu.
DisplayValidRightValues - Mention right code. Here Right code is mentioned as 'ActionOrders' and set as true value for Value for the Rights.
ActionAllowValidRightValues - Mention right code. Here Right code is mentioned as 'ActionOrders' and set as true value for Follower specific value for the rights.
-
Add new action to the object which is created.
-
Finally call the save method on list definition object.
-
Right-click on 'Custom Operation' aspx page and then click on View in Browser. You will get a message like 'New action added successfully'.
See the Developer's Guide for more implementation about creating a new context menu.
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Skelta.Repository.List;
using Skelta.Repository.List.Action;
using Skelta.Core;
using System.Collections.Generic;
public partial class CustomOperations : System.Web.UI.Page
{
string ApplicationName = "ListSecurityRepo";
string ListName = "NavigationDetails";
ListDefinition _ListDef;
ListActions UpdatedActions;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnCreate_Click(object sender, EventArgs e)
{
try
{
// Creating ListDefinition object
_ListDef = new ListDefinition(new ApplicationObject(ApplicationName), ListName);
// Getting Existing actions in List<ListAction> collection
List<ListAction> _ExistingActions = _ListDef.Operations.Actions;
//Declaring ListActions Object
UpdatedActions = new ListActions();
// Looping through Existing actions and add each action ListActions object
foreach (ListAction action in _ExistingActions)
{
UpdatedActions.Actions.Add(action);
}
// Creating New Action
ListASPXUIAction NewAction = new ListASPXUIAction();
// Setting up new action properties
NewAction.Id = "_sys_Orders";
NewAction.Name = " View Products";
NewAction.Type = ListActionType.MenuItem;
NewAction.PagePath = "Products.aspx";
NewAction.IconPath = "Edit";
NewAction.DisplayValidRightValues = "ActionOrders<True>";
NewAction.ActionAllowValidRightValues = "ActionOrders<True>";
NewAction.ApprovalRequiredValidRightValues = "";
NewAction.ApprovalRequiredWithPromptValidRightValues = "";
// Adding new action
UpdatedActions.Actions.Add(NewAction);
// Setting opeartions of ListDefinition object
_ListDef.SetOperations(UpdatedActions);
// Finally calling Save method of ListDefinition object
_ListDef.Save();
Response.Write("New action added successfully");
}
catch (Exception ex)
{
Response.Write(ex.Message.ToString());
}
}
}
-
-
Login as an administrator user.
-
Click Repository Settings (top-right corner) > Advanced Settings > Manage Navigation List.
-
Right-click on any Navigation link and check the newly added context menu. 'View Products' is not added in the context menu.
-
Here, you need to define security settings at this level. Before defining security settings at this level, you need to create security rights for the created action to control.
-
To create a security right for this item, click Repository Settings (top-right corner) > Advanced Settings > Manage Security Rights > New . The following screen is displayed:

-
In the Title text box, enter right name as Can View Products.
-
In the Rights Code text box, enter right code as Action Orders.
-
From Scope for the Rights drop-down list, select scope as 'ListSpecificforListItemLevel'. See List Level Security Settings for more information on scope.
-
After selecting the relevant scope for the new security right and setting the values for the right. This allows the you to select the Lists to which the new right can be applied for and you can also set the value for the new right.
-
From Value for the Right drop-down list, select AllowDisallow from the list.
-
Select Yes for Is this Right applicable to the Follower Rights?
-
Select AllowDisallow from the Follower specific value for the Right drop-down list.
-
Select list from the available list. Here you have to select Navigation List.
-
Click Save. The right has been created.
-
Click Repository Settings (top-right corner) > Advanced Settings > Manage Security Group.
-
You have to customize administrator security group because only administrator user has rights to update the security rights. Select Administrator security group and then click Edit on the ribbon bar or else right-click and then click Edit from the context menu. The Modify a Security Group page appears.
-
Select Can View Products from the Follower specific value for the Rights column and then click Save.
-
Click Cancel from the Synchronization window.
-
Click OK.
-
Click Repository Settings (top-right corner) > Advanced Settings > Manage Navigation List.
-
Right-click any navigation list and check the newly created menu is displayed.
-
Click View Products, this will redirect you to the Product Details page.
-
Right-click and then select Back.
-
For some of the list menus, the newly created context menu is not displayed. For example, right-click the Inbox menu. Here, the newly created menu item is not displayed. This is because security settings have been defined at this list item level.
-
Right-click the Inbox menu list and click Security Settings to enable the created custom operation.
-
Click Advanced Settings > Enable List specific Security.
-
Click Customize Security Group for this List Item. The Security Group screen is displayed.
-
You have to customize the administrator security group because only the administrator user has rights to update the security rights. Select the Administrator security group and then click Edit on the ribbon bar or else right-click and then click Edit from the context menu. The Modify a Security Group page appears.
-
Select Can View Products for both Value for the Rights and the Follower specific value for the Rights column and click Save.
-
Click Cancel from the Synchronization window.
-
Click OK.
-
Click Repository Settings (top-right corner) > Advanced Settings > Manage Navigation List. The Navigation Details page appears.
-
Now you are able to see the View Products context menu for the Inbox menu list.