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 / Canvas App - get contr...
Power Apps
Answered

Canvas App - get control's Data Source name from Component function

(0) ShareShare
ReportReport
Posted on by 42

The controls in my Gym Membership Canvas App currently connect to their associated SQL Server data source directly, i.e. on the control, the Data source property says  [@'[dbo].[Member]'].

 

This text occurs in a few places throughout my App.

 

However, I'd like to put that text somewhere reusable, so that if/when it changes, I can change it in one place.

 

To do this, I created a new Component called DataAccess,  and created an Output Property called Member which returns the text [@'[dbo].[Member]'].

 

To test it, in one of my controls, I replaced the function text fx: [@'[dbo].[Member]'] with [DataAccess.Member] (and variations including @ and/or quotes) thinking it would get the data source from the Component Output Property.

 

Instead, I get an error message that my function "has some invalid arguments" or "invalid use of '.'".

 

Is there a known good pattern for referencing SQL Server data source tables via indirection?

Categories:
I have the same question (0)
  • v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @ArtieLeech ,

     

    What you saved is a text (data source name) instead of a data source.

    Unfortunately, powerapps has no good way to dynamically reference data sources.

    You need to input its name in the Items property of controls.

     

    Best Regards,
    Wearsky
    If my post helps, then please consider Accept it as the solution to help others. Thanks.

  • ArtieLeech Profile Picture
    42 on at

    Thanks for your response, Wearsky.

     

    You've understand my point correctly - I want to dynamically refer to the data source rather than directly connect to it in every single place that references it.

     

    We've already had the case in our app where the database table names have been changed, and every control that referenced them had to be updated.   In some cases, e.g. the Member table, it was referenced in over a dozen places, and it meant a lot of renaming.

     

    Is there another way we can get a level of indirection between the control itself and the database, like adding a data layer?

  • v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @ArtieLeech ,

     

    I understand your needs.

    However, this is difficult to do in canvas.

    For example: If you want to use a patch() function, you have to use this: Patch(data source name ,...,...)

    You can not set a variable to save its name and use it in other controls or anthing else.

     

    Best Regards,
    Wearsky
    If my post helps, then please consider Accept it as the solution to help others. Thanks.

     

     

     

  • ArtieLeech Profile Picture
    42 on at

    Thanks again Wearsky.  Is there another way of moving the data connections to be reusable then, so that there's only one explicit connection to a particular table, in this case, Member?

     

    i.e. could I create some sort of reusable control containing a one data connection to Member, and map any canvas form or control that reads/writes to Member through the reusable control?

  • Verified answer
    v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @ArtieLeech ,

     

    Yes. You could set the Items proeprty of the gallery to:

    your data sourse name (in this case ,Member)

     

    Then other controls can use the data on gallery control.

    For example: Add a combo box control and set its Items property to:

    Your gallery name.AllItems

     

    Best Regards,
    Wearsky
    If my post helps, then please consider Accept it as the solution to help others. Thanks.

  • ArtieLeech Profile Picture
    42 on at

    Thanks for this suggestion, Wearsky, I'll give it a try once I'm back at work next week.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 335 Most Valuable Professional

#2
11manish Profile Picture

11manish 166

#3
sannavajjala87 Profile Picture

sannavajjala87 71 Super User 2026 Season 1

Last 30 days Overall leaderboard