Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Pass value of two option to custom workflow

(0) ShareShare
ReportReport
Posted on by 1,695

|I have been trying to follow a tutorial passing input parameters to a custom workflow. Text is fine though I am getting stuck on how to read the value from 'UseFax'. In Crm new_usefax is a two option ( yes / no ). I need to read this value in the workflow

       <RequiredArgument>
        <Input("UseFax")>
        Public Property new_usefax() As InArgument(Of Boolean)
            Get
                Return m_new_usefax
            End Get
            Set
                m_new_usefax = Value
            End Set
        End Property
        Private m_new_usefax As InArgument(Of Boolean)


I have tried If new_usefax.[Get](executionContext) = True Then (do something)  but this fails

*This post is locked for comments

  • Suggested answer
    Alagunellaikumar Profile Picture
    Alagunellaikumar 6,210 on at
    RE: Pass value of two option to custom workflow

    Hi

    [Input("bool input")]

    public InArgument<bool> new_usefax{ get; set; }

  • Suggested answer
    Aiden Kaskela Profile Picture
    Aiden Kaskela 19,694 on at
    RE: Pass value of two option to custom workflow

    Hi Pete,

    Sorry I can't help with the VB syntax, but here's the breakdown of handling it in C# with enough comments where you should be able to make the transition

    [Input("Input Display Name")] // what should be presented to the user

    public InArgument<bool> InputBooleanParameter { get; set; } // Declaring a property of type InArgument<bool>

    protected override void Execute(CodeActivityContext context) // Inside the execute method

    {

      var inputAsBoolean = this.InputBooleanParameter.Get(context); // Get the working value from the InArgument<bool> type

      // do something with inputAsBoolean

    }

    You will need to check for null when getting values from InArguments depending on the type. Simple types like bool, int, decimal will return the default value if they aren't set (false, 0, 0 respectively), but complex types like Money and EntityReference will evaluate to null.

    Hope this helps! I'd appreciate if you'd mark this as Answering your question.

    Thanks,

     Aiden

  • Pete_N Profile Picture
    Pete_N 1,695 on at
    RE: Pass value of two option to custom workflow

    Hi David,

    Thanks for the suggestion, however when applying your code

           <RequiredArgument>

           <Input("UseFax")>

           Public new_usefax As InArgument(Of Boolean)

    I get the following error

    Attribute 'InputAttribute' cannot be applied to 'new_usefax' because the attribute is not valid on this declaration type.

  • David Jennaway Profile Picture
    David Jennaway 14,063 on at
    RE: Pass value of two option to custom workflow

    The issue may be that you're defining this as a Property, rather than a field. I'd try defining this as a field (i.e. just have a public property):

    <RequiredArgument>
            <Input("UseFax")>
            Public new_usefax As InArgument(Of Boolean) 

    If new_usefax.Get(Of Boolean)(executionContext) = True Then (do something)



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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,387 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans