cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Post Patron
Post Patron

Unable to LOOKUP in DATACARD

Hi Power Apps Community,

I am trying to create an NewForm feature in Power Apps where one of the fields should be a lookup. I have tried the following, but have been unsuccessful:

LookUp(Collectionname, Field.Value = varCurrUser, ThisItem.Field)

Where varCurrUser = First(Split(Office365Users.MyProfile().UserPrincipalName, "@" )).Result

{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
  Value: LookUp(CollectionName, Field.Value = varCurrUser, ThisItem.Field)}

Note: The data is being stored in a Collection.

I would really appreciate any assistance.

Thank you in advance.

1 ACCEPTED SOLUTION

Accepted Solutions

@RandyHayes 

I managed to solve my issue:

Filter(Choices(List.Field), Value = (LookUp(List.Field, Field.Value = var, Field.Value)))

This hard locks the value required in the data card.

Thank you for providing clarity along the way. Got me thinking about what I was doing 😀 

View solution in original post

9 REPLIES 9
Super User III
Super User III

@Data_Enthusiast 

Can you explain more about what the actual issue is you're seeing?

I can see that your formula:

LookUp(Collectionname, Field.Value = varCurrUser, ThisItem.Field)

Is not going to work as you are trying to reference the column you want to return as a variable name (ThisItem.Field).  You would need to specify the column in the third parameter.

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

@RandyHayes 

I should have mentioned... I am receiving an error message: "Expected Text value" for the formula that you have highlighted. 

@Data_Enthusiast 

I'm sorry, I'm just not understanding your scenario.  

You have supplied two formulas - but where are these formulas being used (control and action)?  What is their purpose?  What is it that you are trying to do?  You only mention that you are trying to create a "NewForm feature".  I'm not sure what that means as the EditForms in PowerApps already have a new form capability. 

You mentioned that "one of the fields should be a lookup".  Does this mean that you want to lookup a value for a field, or that the field is a Lookup column in SharePoint?

Finally, you mention a collection...where does that come in to play in any of this?

 

Please provide more detail - it will greatly increase the chance of a good solution for you.

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

@RandyHayes 

Happy to give more context.

The two formulas provided are what I have tried - trying different options, but not knowing if one was more correct than the other -> these formulas were added individually to the 'Items' property of the Data Card.

NewForm in the sense that I am trying to add data to a SP List, and not edit existing data - which is what EditForm is (an explanation I got of what the two are).

With regards to the lookup field, it is a lookup field in SharePoint (which has the user name). I would like for the data card in Power Apps to be pre-populated with the user name of the current logged in user - currently, it is providing a list of all the users.

For the Collection, I am storing the data in a Collection to avoid delegation issues. I read on the community forum that Collections do not have delegation issues - I have not had any issue with this, hence why the data is in a Collection. As a result, the data source for my Form reference the Collection. 

This initial process made sense to me, but I am more than happy to receive advise on how to better the process of what I am trying to achieve.

@Data_Enthusiast 

So first off, EditForms are also NewForms.  In fact a form has three different modes - View, Edit, New  There is no need to recreate the logic.

 

The next bit is that you say you are trying to base your EditForm on a collection.  This is not possible for a Form.  It needs to be a viable datasource.  It will have no delegation issues as it is just a form.

 

The factor of having the current user selected in the control on your form is vastly different than the above.  So, let's resolve the above first.  

Please verify that you are using an EditForm or if you are attempting custom controls to simulate your form.

 

If you are using an EditForm, then tell me more about the column that holds the user name.  You say this is a Lookup column in SharePoint.  What is the list that it refers to and what is the value that it stores in your primary list?

 

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

@RandyHayes 

Thank you for the clarity.

I went back and selected the EditForm option.

I have a 'Products' table which has a lookup field called User Name. User Name comes from my main People list - set up provided below where 'EID' is the user name.

Data_Enthusiast_0-1602602148257.png

Then there are two fields in the Products list which the user may interact with.

Hope this helps.

@Data_Enthusiast 

Okay, very good.  So, the reality is that if you have this lookup column in your EditForm, PowerApps will already have the "mechanism" in place to get the information from the looked up list and then store the correct information when submitted.

 

Are you not seeing that ability, or where are you at this point?

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

Hi @RandyHayes 

I can see that ability. I have brought in the lookup field on the form, but it is currently listing all the users. This enables me to submit data against some else's name - which is not what I would like to have. I would need a formula to have the default value of the data card as the user name of the person signed in.

I am wondering though if I should create labels and text inputs and Patch the data entered to SP?

@RandyHayes 

I managed to solve my issue:

Filter(Choices(List.Field), Value = (LookUp(List.Field, Field.Value = var, Field.Value)))

This hard locks the value required in the data card.

Thank you for providing clarity along the way. Got me thinking about what I was doing 😀 

View solution in original post

Helpful resources

Announcements
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (3,388)