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 / Desktop Flow Custom Ac...
Power Automate
Answered

Desktop Flow Custom Actions (preview) ActionSelector Problem

(1) ShareShare
ReportReport
Posted on by 19

Hi all,

I test and develop custom actions for Power Automate Deskop Flows.

 

I read the documentation, but in the sample file "CentralCustomAction.cs" I ask me for using the selector with friendly text inside of combobox and not just numbers.

 

In sample code we have this definition of enum:

quer13_0-1689241025430.png

I modified it to:

quer13_1-1689241099143.png

To use the nice enum description for the selector list text, I added the code as shown in the red box.

quer13_2-1689241161955.png

 

But the result of the action in Power Automate is this:

quer13_4-1689241374867.png

 

I still have the numbers as selection list text and not my description text from the enumeration.

Where is my mistake or is it just a bug in preview?

 

Regards,

Markus

 

I have the same question (0)
  • quer13 Profile Picture
    19 on at

    Is there no one who tries to create a new Custom Action (Preview) in PAD with use of selectors?

  • eJackson Profile Picture
    17 on at

    I've been having the exact same issue. The documentation doesn't do a great job in my opinion, and I've been unable to find anything about it online. 

    eJackson_0-1690476401514.png

    There's only ~500 people that have even downloaded the SDK for use, so I'm not super hopeful for the future of custom actions.

  • kinuasa Profile Picture
    795 Most Valuable Professional on at

    How about changing the "Selector" type?

     

    using System.ComponentModel;
    using Microsoft.PowerPlatform.PowerAutomate.Desktop.Actions.SDK.Attributes;
    using Microsoft.PowerPlatform.PowerAutomate.Desktop.Actions.SDK;
    
    namespace Modules.CustomModule
    {
     [Action(Id = "Action1")]
     public class Action1 : ActionBase
     {
     public enum SelectorChoice
     {
     [Description("one")]
     Selector1,
     [Description("two")]
     Selector2,
     [Description("three")]
     Selector3
     }
    
     [InputArgument(typeof(SelectorChoice), true, false), DefaultValue("two")]
     public string Selector { get; set; }
    
     [InputArgument(Order = 1)]
     public string FirstName { get; set; }
    
     [InputArgument(Order = 2)]
     public string LastName { get; set; }
    
     [InputArgument(Order = 3)]
     public int Age { get; set; }
    
     [OutputArgument]
     public string DisplayedMessage { get; set; }
    
     public override void Execute(ActionContext context)
     {
     if (Selector == "one")
     {
     DisplayedMessage = $"Hello, {FirstName}!";
     }
     else if (Selector == "two")
     {
     DisplayedMessage = $"Hello, {FirstName} {LastName}!";
     }
     else // The 3rd Selector was chosen 
     {
     DisplayedMessage = $"Hello, {FirstName} {LastName}!\nYour age is: {Age}";
     }
     }
     }
    }
  • eJackson Profile Picture
    17 on at

    The only problem with this is that to use the ActionSelector functionality, the input argument must be an enum: 

    eJackson_0-1690570222838.png

    The action selectors allows you to define constraints to match them to the value of the input argument at runtime:

    eJackson_1-1690570483066.png

    I wanna say I've identified at least one issue within the tests SDK that causes this behavior. There's a function called "ValidateSelectors" in the ActionValidator class that tries to compare the constraint value with the value of the input argument, which is cast to an int. This cast causes the validator to throw an exception when the input argument is a string, leaving us here:

    eJackson_2-1690571082757.png

    I'd go into more detail but it's honestly quite a bit to go through. 

  • Verified answer
    kinuasa Profile Picture
    795 Most Valuable Professional on at

    I understand what you are saying.
    I suggest specifying it in Resources instead of in the Description attribute.

     

     

    using System.ComponentModel;
    using Microsoft.PowerPlatform.PowerAutomate.Desktop.Actions.SDK;
    using Microsoft.PowerPlatform.PowerAutomate.Desktop.Actions.SDK.ActionSelectors;
    using Microsoft.PowerPlatform.PowerAutomate.Desktop.Actions.SDK.Attributes;
    using static Modules.CustomModule.CentralCustomAction;
    
    namespace Modules.CustomModule
    {
     [Action(Id = "CentralCustomAction")]
     public class CentralCustomAction : ActionBase
     {
     public enum SelectorChoice
     {
     Selector1,
     Selector2,
     Selector3
     }
    
     [InputArgument, DefaultValue(SelectorChoice.Selector1)]
     public SelectorChoice Selector { get; set; }
    
     [InputArgument(Order = 1)]
     public string FirstName { get; set; }
    
     [InputArgument(Order = 2)]
     public string LastName { get; set; }
    
     [InputArgument(Order = 3)]
     public int Age { get; set; }
    
     [OutputArgument]
     public string DisplayedMessage { get; set; }
    
     public override void Execute(ActionContext context)
     {
     if (Selector == SelectorChoice.Selector1)
     {
     DisplayedMessage = $"Hello, {FirstName}!";
     }
     else if (Selector == SelectorChoice.Selector2)
     {
     DisplayedMessage = $"Hello, {FirstName} {LastName}!";
     }
     else // The 3rd Selector was chosen 
     {
     DisplayedMessage = $"Hello, {FirstName} {LastName}!\nYour age is: {Age}";
     }
     }
     } // you can see below how to implement an action selector
    
     public class Selector1 : ActionSelector<CentralCustomAction>
     {
     public Selector1()
     {
     UseName("DisplayOnlyFirstName");
     Prop(p => p.Selector).ShouldBe(SelectorChoice.Selector1);
     ShowAll();
     Hide(p => p.LastName);
     Hide(p => p.Age);
     // or 
     // Show(p => p.FirstName); 
     // Show(p => p.DisplayedMessage);
     }
     }
    
     public class Selector2 : ActionSelector<CentralCustomAction>
     {
     public Selector2()
     {
     UseName("DisplayFullName");
     Prop(p => p.Selector).ShouldBe(SelectorChoice.Selector2);
     ShowAll();
     Hide(p => p.Age);
     }
     }
    
     public class Selector3 : ActionSelector<CentralCustomAction>
     {
     public Selector3()
     {
     UseName("DisplayFullDetails");
     Prop(p => p.Selector).ShouldBe(SelectorChoice.Selector3);
     ShowAll();
     }
     }
    }

     

     

    PAD_Custom action selectors.png

     

     

  • quer13 Profile Picture
    19 on at

    @kinuasaYes, great, with the resources it works well. Thank you for this hint. Also, it's more flexibel than the Description-Attribute way.

    Do you test more than the default resource file (Resources.res)?

    I also created "Resources.de-DE.resx" for german language. Does it work for you, if you choose another language?

    PAD does not take the german resource file, although I have a german account and Windows-OS.

  • kinuasa Profile Picture
    795 Most Valuable Professional on at

    I was able to localize it by copying the Resources.resx file and renaming it Resources.{locale}.resx file.
    This was confirmed in the Power Automate for desktop version 2.35.159.23221 environment (the figure below is in Japanese environment).

    PAD_Localization of custom actions by resource file.jpg

  • quer13 Profile Picture
    19 on at

    Hello kinuasa.

    I just noticed that you are showing me file "Resources.resx" and not the localized file. You made your localization in the default english resource file and not in the japanese one.

    For me localization is not possible.

    It seems that PAD has a bug.

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 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard