Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Work Tasks

Correct Custom Activities

  • Last UpdatedJul 01, 2024
  • 2 minute read

When you design or install a package for custom activity with workflow, follow the steps given below if you need to correct the custom activity in the target environment.

  1. Run the following SQL query in the SKAddInProviders table for the target repository database.

    INSERT INTO SKAddInProviders (Type,[Name],ClassName,Assembly) VALUES ('PackageWorkflow','SampleApproval','SampleApprovalActivity.SampleApprovalCorrection','bin\SampleApprovalActivity.dll')

    --'SampleApproval' is the name of the custom activity.

    --'SampleApprovalActivity.SampleApprovalCorrection' is the namespace of the custom activity.

    --'SampleApprovalActivity.dll' is the DLL in the BIN path of the target environment.

  2. Implement IWorkflowCorrection interface in your custom activity by referring to the following DLLs, if you want to correct the custom activity in the target environment.

    Skelta.Package.AdvancedPackageObjects;

    Skelta.Forms.Core;

Example

SampleApprovalCorrection.cs

using Skelta.Package.AdvancedPackageObjects;

using Skelta.Package.Common;

using Skelta.Repository.List;

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Xml;

using Workflow.NET;

namespace SampleApprovalActivity

{

public class SampleApprovalCorrection: IWorkflowCorrection

{

public Skelta.Package.Common.WorkflowResponseObject GetAssociatedObjects(Skelta.Repository.List.IListItem item, Skelta.Forms.Core.Controls.BaseForm settingsForm, string settingsFormXml, Workflow.NET.IAction action)

{

// Employee is the list name.

string listName = "Employee";

var responseObject = new WorkflowResponseObject();

var associatedListItemObjectsList = new List<CommonLib.PackageObjectInfo>();

// Access list item related information from the property of the activity. For example, the list item name.

string listItemName = GetValueFromProperty(action);

if (!string.IsNullOrEmpty(listItemName))

{

var repositoryName = item.List.Application.ApplicationName;

var listDataHandler = new ListDataHandler(repositoryName, listName);

IListItem associatedListItem = listDataHandler.GetListItem(listItemName);

if (associatedListItem != null)

{

var objectInfo = this.GetBasicInfoOfListItem(associatedListItem);

if (!associatedListItemObjectsList.Contains(objectInfo))

{

associatedListItemObjectsList.Add(objectInfo);

}

}

}

else

{

throw new ArgumentException("ListItem cannot be null.");

}

responseObject.SettingsFormXml = settingsFormXml;

responseObject.AssociatedObjects = associatedListItemObjectsList;

return responseObject;

}

public Skelta.Package.Common.WorkflowResponseObject PreinstallValidate(Skelta.Package.Deploy.IManagePackage package, string repositoryName, Skelta.Package.Common.CommonLib.PackageObjectInfo selfDetails, Skelta.Forms.Core.Controls.BaseForm settingsForm, string settingsFormXml, string activityDefinition, string actionName)

{

throw new NotImplementedException();

}

public Skelta.Package.Common.WorkflowResponseObject UpdateActivityDefinition(Skelta.Package.Deploy.IManagePackage package, string repositoryName, Skelta.Package.Common.CommonLib.PackageObjectInfo selfDetails, Skelta.Forms.Core.Controls.BaseForm settingsForm, string settingsFormXml, string activityDefinition, string actionName)

{

// Replace GUID and Return XML.

WorkflowResponseObject responseObj = new WorkflowResponseObject();

Workflow.NET.Log log = new Workflow.NET.Log();

XmlDocument xmlMaindoc = new XmlDocument();

xmlMaindoc.LoadXml(activityDefinition);

try

{

// Correction.

string propertyName = "Custom Sample Property";

xmlMaindoc.SelectSingleNode("//properties//property[@name='" + propertyName + "']").InnerText = "83bef27b-987f-46c1-a7b6-7da52f6a7462"; //// correct the guid based on your requirement

}

catch (Exception ex)

{

log.LogError(ex, "Error while resolving Custom Activity Correction property " + selfDetails.Name, repositoryName);

}

responseObj.CorrectedActivityXml = xmlMaindoc.InnerXml;

return responseObj;

}

// Access list item related information from the property of the activity. For example, the list item name.

private static string GetValueFromProperty(IAction action)

{

string dataValue = string.Empty;

if (action != null && action.Properties.Contains("configCustomActivity"))

{

// configCustomActivity is the property name.

Workflow.NET.Property customActivityProperty = action.Properties["configCustomActivity"];

if (!string.IsNullOrEmpty(customActivityProperty.Value.ToString()))

{

dataValue = (customActivityProperty.PropertyHandler).Value;

}

}

return dataValue;

}

// Method to get the basic information about the list item.

private CommonLib.PackageObjectInfo GetBasicInfoOfListItem(IListItem listItem)

{

var packageObjectInfo = new CommonLib.PackageObjectInfo();

packageObjectInfo.Name = listItem.Title;

packageObjectInfo.Id = listItem.Id;

packageObjectInfo.Type = listItem.List.Name;

packageObjectInfo.Version = string.Empty;

packageObjectInfo.ItemType = CommonLib.GetActualItemType(listItem.List.Name, listItem.ItemType);

packageObjectInfo.IsFolder = listItem.IsFolder;

if (!listItem.ParentItemId.Equals(Guid.Empty))

{

packageObjectInfo.ParentItem = listItem.ParentItem.Title;

}

else

{

packageObjectInfo.ParentItem = string.Empty;

}

return packageObjectInfo;

}

}

}

Note:
- If custom activities are not created using AVEVA Work Tasks 2023 or later versions, then ensure you follow the steps given above to create DLLs for modifying custom activities.
- If you add a custom XML file for a custom activity, then ensure you remove the category data from the action.xml file.

TitleResults for “How to create a CRG?”Also Available in