web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Custom Actions - Not R...
Power Automate
Unanswered

Custom Actions - Not Reading Resource File, Showing Enum Values in Dropdown

(1) ShareShare
ReportReport
Posted on by 36
In my Power Automate Desktop custom action, I am having a similar issue to: Solved: Desktop Flow Custom Actions (preview) ActionSelector Problem, except the solution of putting the FriendlyName in the resource file is not working.
 
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();
            }
        }
    }
}
 
I have the same question (0)
  • Suggested answer
    Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 on at
    Hi,
     
    did you tried setting descriptions in resources file and see whether that appeared as label ? Just description only 
     
     
    See whether that helps !
     
    Thanks & Regards,
    Nived N
  • rkaiserhuyett Profile Picture
    36 on at
    I tried that, too, and I am still getting the same results with it showing the enum int values of 0 and 1.
     
     
    At this point, it appears that nothing it getting read from the Resources.resx file. 
  • Verified answer
    Deenuji_Loganathan_ Profile Picture
    6,250 Super User 2025 Season 2 on at
     
    I'm uncertain about using enum selectors with a resource file since the Microsoft documentation lacks clarity, and the suggested approach does not work correctly when incorporating the `usename()` declaration. However, without using selectors, we can still declare them as strings (either "Keep" or "Delete") and list both options in a dropdown list. Below is the code and a screenshot that might be helpful for your reference.
    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.Attributes;
    
    
    namespace Modules.Actions
    {
        [Action(Id = "CentralCustomAction", 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 CentralCustomAction : 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.", SuggestedValues = new string[] {"Keep", "Delete" })]
            public string Selector { 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 (Selector == "Delete")
                    {
                        // Delete columns not in the columnsList
                        foreach (DataColumn column in DataTable.Columns)
                        {
                            if (columnsList.Contains(column.ColumnName))
                            {
                                NewDataTable.Columns.Remove(column.ColumnName);
                            }
                        }
                    }
                    else if (Selector == "Keep")
                    {
                        // 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);
                }
            }
        }
    }
     
     
     
    Thanks,
    Deenuji Loganathan 👩‍💻
    Power Automate Desktop Community Champion 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and like my suggestion ❤️  Your feedback supports future seekers 🚀
     
  • rkaiserhuyett Profile Picture
    36 on at
     
    SuggestedValues = new string[] {"Keep", "Delete" })] was the key to making this work as a dropdown. 
     
    [InputArgument(Order = 3, FriendlyName = "Delete or keep columns", Description = "Specify whether to delete or keep the columns listed.", SuggestedValues = new string[] {"Keep", "Delete" })]
            public string Selector { get; set; }
     
    Thanks!
    rkaiserHuyett
  • Deenuji_Loganathan_ Profile Picture
    6,250 Super User 2025 Season 2 on at
    Yes, Exactly i was created couple of custom actions with dropdown but I gave shot in resource file logic also it was not successful :) 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard