cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sperry1625
Helper V
Helper V

Component Data Retrieval

I am attempting to create a component that returns a string of text.  The component is amazingly simple, in the OnReset() for the component I create a table of data.  Each row contains three columns with text content.

There is one output property that takes a single parameter, GetText( ItemName ). It doesn't work. The calls to lookup the data return nothing. I use LookUp() to find and return the appropriate data. Sometimes it works, sometimes it doesn't.  Is there anything odd about trying to use a Component in this way that makes this impossible?

 

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@sperry1625 

Avoid creating any variables or data directly in the component.  There are issues with this in a component. 

Utilize the Input and Output properties as much as possible.

 

Do what you are trying to do in the GetText property instead.   

From your function signature, I am assuming you have already created a parameter for the GetText output property called ItemName, so, in the GetText property, consider something like this:

 

With({_myTable:
    Table({col1: "text1-1", col2: "text1-2", col3: "text1-3"},
          {col1: "text2-1", col2: "text2-2", col3: "text2-3"} //...etc...
    )
    {,

    LookUp(_myTable, col1 = ItemName, col2)
)

 

This will Lookup the value in the column col1 the value passed to the parameter ItemName and then return the value found in col2.

 

NOTE: for component flexibility, it is always best to have an Input property that will allow you to assign the table.

So, for example, if you create an input property and call it Items, then you would set the Items property in your component to:

Table({col1: "text1-1", col2: "text1-2", col3: "text1-3"},
      {col1: "text2-1", col2: "text2-2", col3: "text2-3"} //...etc...
)

And now your GetText property formula would be:

LookUp(Self.Items, col1 = ItemName, col2)

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

1 REPLY 1
RandyHayes
Super User
Super User

@sperry1625 

Avoid creating any variables or data directly in the component.  There are issues with this in a component. 

Utilize the Input and Output properties as much as possible.

 

Do what you are trying to do in the GetText property instead.   

From your function signature, I am assuming you have already created a parameter for the GetText output property called ItemName, so, in the GetText property, consider something like this:

 

With({_myTable:
    Table({col1: "text1-1", col2: "text1-2", col3: "text1-3"},
          {col1: "text2-1", col2: "text2-2", col3: "text2-3"} //...etc...
    )
    {,

    LookUp(_myTable, col1 = ItemName, col2)
)

 

This will Lookup the value in the column col1 the value passed to the parameter ItemName and then return the value found in col2.

 

NOTE: for component flexibility, it is always best to have an Input property that will allow you to assign the table.

So, for example, if you create an input property and call it Items, then you would set the Items property in your component to:

Table({col1: "text1-1", col2: "text1-2", col3: "text1-3"},
      {col1: "text2-1", col2: "text2-2", col3: "text2-3"} //...etc...
)

And now your GetText property formula would be:

LookUp(Self.Items, col1 = ItemName, col2)

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,677)