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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / PCF Parameter Get valu...
Power Apps
Answered

PCF Parameter Get values provided

(0) ShareShare
ReportReport
Posted on by 6

I would like to check whether an optional parameter was provided or not (to render the control differently based on that)

I declared the parameter with these attributes:

of-type="SingleLine.Text" usage="bound" required="false"

 

How could I check in the Typescript code whether this Input parameter was bound or not?

 

I tried setting a variable in the Init method, like

this.myVariable = context.parameters.theParameter.raw || ""

 

But I didn't really see the value reflected, so not sure if Init method would be the right approach, or there is another way to obtain this metadata

 

Thanks,

I have the same question (0)
  • Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at

    Hi @rgomezArctictec , 

     

    You could check if context.parameteres.<YOUR_PROPERTY>.type is null (or not SingleLine.Text). If so, the parameter was not defined in the customizing.

     

    Kind regards,

    Diana

     

  • rgomezArctictec Profile Picture
    6 on at

    Thanks Diana.

    Actually I realized I was using the context variable in the wrong spot, once I put it in the correct Init method, I could do something like this:

     

    myVariable = typeof (context.parameters.myParameter.attributes?.DisplayName) === "undefined" ? false : true

     

    The reason is that context.parameters.myParameter was like an empty object {}, when not provided from the CRM form designer

     

    Regards,

  • Verified answer
    Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at

    Hi @rgomezArctictec , 

     

    The property values can be static or dynamic (from a field): 

    DianaBirkelbach_1-1604388622797.png

     

     

     

    In case the customizing is done with a fixed value, then you have a type and a value, but the attribute is empty. So I still think that using property.type is safer than the property.attribute.DisplayName:

    context.parameters.myParameter?.type === undefined

     In case the property.type is undefined, then it was not set.

     

    Just in case it helps: the context.properties are not always provided in the init method. Sometimes you get them only in the "updateView" method.

     

    Hope it helps!

     

    Kind regards,

    Diana

     

    ----------
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • rgomezArctictec Profile Picture
    6 on at

    Thanks Diana. Will use type property instead 🙂

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 1,041

#2
11manish Profile Picture

11manish 676

#3
Valantis Profile Picture

Valantis 655

Last 30 days Overall leaderboard