The dropdown options for 'Delete or keep columns:' only shows the enum int instead of the text values.
I have tried setting these in the resource file and nothing works. I fact, have tried setting Actions, InputArgument and OutputArguments there and they do not show either.
I have tried setting descriptions in the enum and the ActionSelector, but these do not work either:
I have 1.4.237.23279 of Microsoft.PowerPlatform.PowerAutomate.Desktop.Actions.SDK
This is my code:
using System;
using System.ComponentModel;
using System.Data;
using System.IO;
using System.Linq;
using Microsoft.PowerPlatform.PowerAutomate.Desktop.Actions.SDK;
using Microsoft.PowerPlatform.PowerAutomate.Desktop.Actions.SDK.ActionSelectors;
using Microsoft.PowerPlatform.PowerAutomate.Desktop.Actions.SDK.Attributes;
using Newtonsoft.Json;
namespace Modules.Actions
{
[Action(Id = "DataTableDeleteColumnsAction", Order = 1, Category = "DataTable", FriendlyName = "Delete columns from data table", Description = "Deletes all columns from data table, except ones given")]
[Throws("ActionError")] // TODO: change error name (or delete if not needed)
public class DataTableDeleteColumnsAction : ActionBase
{
[InputArgument(Order = 1, FriendlyName = "Data table", Description = "The data table variable to work with. This variable must have been previously specified by an action that produces a data table variable"), DefaultValue(null)]
public DataTable DataTable { get; set; }
[InputArgument(Order = 2, FriendlyName = "Columns list to save or delete", Description = "Comma delimited list of columns to save or delete."), DefaultValue("")]
public string Columns { get; set; }
[InputArgument(Order = 3, FriendlyName = "Delete or keep columns", Description = "Specify whether to delete or keep the columns listed."), DefaultValue(DeleteOrKeepSelector.DeleteColumns)]
public DeleteOrKeepSelector DeleteOrKeep { get; set; }
[OutputArgument(FriendlyName = "New data table", Description = "The new data table variable with columns removed")]
public DataTable NewDataTable { get; set; }
public override void Execute(ActionContext context)
{
try
{
// Parse the Columns string into a list of column names and trim spaces
var columnsList = Columns.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
.Select(column => column.Trim())
.ToList();
// Create a copy of the original DataTable
NewDataTable = DataTable.Copy();
if (DeleteOrKeep == DeleteOrKeepSelector.DeleteColumns)
{
// Delete columns not in the columnsList
foreach (DataColumn column in DataTable.Columns)
{
if (columnsList.Contains(column.ColumnName))
{
NewDataTable.Columns.Remove(column.ColumnName);
}
}
}
else if (DeleteOrKeep == DeleteOrKeepSelector.KeepColumns)
{
// Keep only the columns in the columnsList
foreach (DataColumn column in DataTable.Columns)
{
if (!columnsList.Contains(column.ColumnName))
{
NewDataTable.Columns.Remove(column.ColumnName);
}
}
}
}
catch (Exception e)
{
if (e is ActionException) throw;
throw new ActionException("ActionError", e.Message, e.InnerException);
}
}
public enum DeleteOrKeepSelector
{
//[Display(Name = "DeleteColumns")]
//[Description("DeleteColumns Description")]
DeleteColumns,
//[Display(Name = "KeepColumns")]
//[Description("KeepColumns Description")]
KeepColumns,
}
public class DeleteColumnsSelector : ActionSelector<DataTableDeleteColumnsAction>
{
public DeleteColumnsSelector()
{
UseName("DeleteColumns");
//WithDescription("Remove columns listed in columns");
//WithSummary("Summary Remove columns listed in columns");
Prop(p => p.DeleteOrKeep).ShouldBe(DeleteOrKeepSelector.DeleteColumns);
ShowAll();
}
}
public class KeepColumnsSelector : ActionSelector<DataTableDeleteColumnsAction>
{
public KeepColumnsSelector()
{
UseName("KeepColumns");
//WithDescription("Keep only columns listed in columns");
//WithSummary("Summary Keep only columns listed in columns");
Prop<DeleteOrKeepSelector>((DataTableDeleteColumnsAction c) => c.DeleteOrKeep).ShouldBe(DeleteOrKeepSelector.KeepColumns);
ShowAll();
}
}
}
}