cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TechBrain64
Frequent Visitor

Update Gallery Record Field OnSelect Button

I have been working a couple weeks now trying to get what seems to be simple, but will not work. I've tried several other posts suggestions and nothing works. To be honest, I don't like posting in forums as it's been my experience people aren't has helpful as forums proclaim (my first post here). And no, it's not due to my lack of providing details.

 

I have a main SP list with sublists hosting related data used in main list lookups. For this scenario I've built a gallery in a data table format view where I've set icon button at the end. This gallery displays a case list for that day. The icons will be used as a button (OnSelect) for when one of my team members click it they take ownership of that case and their name is updated/saved in case Engineer field for said record.

 

The Engineer field is a lookup into Engineers sublist of all our names. I've already worked out the substitution of icon with name with IF statement and manually updating a record Engineer. But I cannot get the icon button OnSelect property statement syntax to work and have tried several things. Any help would be greatly appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@TechBrain64 

Very helpful!  Thank you!

 

So, you mention that Engineer is a Lookup column to the Engineers list.

Lookup columns are stored as records in SharePoint.  The record has two required columns - the Id and the Value.

For a Lookup, the Id is the ID of the list item in the foreign list (Engineers) and Value needs to be the field that is looked up (usually Title, but whatever is defined in your lookup column definition in SharePoint).

 

So your statement would be:

With({_eng: LookUp(Engineers, Title=varEngineer)},

    UpdateIf('Case Management', ID=ThisItem.ID, 
       {Engineer:
           {Id: _eng.ID,
            Value: _end.Title
           }
       }
    )
)

 

So, in the above...if you are going to populate a lookup column, then you need to provide a valid record that references a real record in your Engineers list.

So, the above formula, looks up the record in that list based on the varEngineer variable.  Now, I used Title in the lookup...replace that with the column that would have the full name in it.

 

Now that we have that record (in a scoped with variable called _eng), then we do the actual update.  In this case it is more efficient to use UpdateIf over patch.  Try to avoid using ThisRecord by itself as it might not always match what you expect (highly dependent on the Items property) and really, the only thing you ever need is the primary key - ID in this case.

Then in the UpdateIf, the formula updates the Engineer column and provides a valid Lookup record based on the values gathered in the first LookUp in the formula...the ID and the Title.  Replace the Title if that is not the correct column.

 

 

_____________________________________________________________________________________
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.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
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

5 REPLIES 5
RandyHayes
Super User
Super User

@TechBrain64 

Welcome to your first post on the PowerApps forum.  Here you will get answers!!

 

Can you share the formula you currently have on your OnSelect action of the icon? That would be helpful to understand your scenario a little better.

 

_____________________________________________________________________________________
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.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

Hi @RandyHayes ,

 

I'm truly not sure it would be helpful as I've tried a multitude of different formulas based on post I've found. But here is: Patch('Case Management'. ThisItem, {Engineer: {Value: varEngineer}} )

 

varEngineer is a variable used to format User().FullName because some of our names are appended with CONTRACTOR and I strip it off.

 

Update: I did at one point use this:

Patch('Case Management', Defaults('Case Management'), ThisItem, {Engineer: txtEngineer})

Which didn't display red swiggly line, but txtEngineer is the gallery field name and doesn't allow for setting value. 

RandyHayes
Super User
Super User

@TechBrain64 

Very helpful!  Thank you!

 

So, you mention that Engineer is a Lookup column to the Engineers list.

Lookup columns are stored as records in SharePoint.  The record has two required columns - the Id and the Value.

For a Lookup, the Id is the ID of the list item in the foreign list (Engineers) and Value needs to be the field that is looked up (usually Title, but whatever is defined in your lookup column definition in SharePoint).

 

So your statement would be:

With({_eng: LookUp(Engineers, Title=varEngineer)},

    UpdateIf('Case Management', ID=ThisItem.ID, 
       {Engineer:
           {Id: _eng.ID,
            Value: _end.Title
           }
       }
    )
)

 

So, in the above...if you are going to populate a lookup column, then you need to provide a valid record that references a real record in your Engineers list.

So, the above formula, looks up the record in that list based on the varEngineer variable.  Now, I used Title in the lookup...replace that with the column that would have the full name in it.

 

Now that we have that record (in a scoped with variable called _eng), then we do the actual update.  In this case it is more efficient to use UpdateIf over patch.  Try to avoid using ThisRecord by itself as it might not always match what you expect (highly dependent on the Items property) and really, the only thing you ever need is the primary key - ID in this case.

Then in the UpdateIf, the formula updates the Engineer column and provides a valid Lookup record based on the values gathered in the first LookUp in the formula...the ID and the Title.  Replace the Title if that is not the correct column.

 

 

_____________________________________________________________________________________
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.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

@RandyHayes ,

 

You just knocked ME out of the park, "It works!!!". With the exception of a small typo where you had 

Value: _end.Title

it should be " Value: _eng.Title " eng not end. I'm not being picky; just took a minute to find typo.

 

Which also begs the question? I had renamed the column "Name" and yet it's still only is recognized as "Title".

 

I see you're identified as "Super User" which is also typo; it should say "Super Hero". I would have never figured this out, Thank You! 

RandyHayes
Super User
Super User

@TechBrain64 

Oops, sorry about the typo.  They happen here on the forum as we type all of our formulas by hand - without the aid of the formula editors.  It's funny but I caught myself typing _end in a couple places in that post and thought I had fixed each as I went along.  Glad you noticed it and understood what to correct.

 

As for column names...you can actually never rename a SharePoint column.  It will always retain its original name.  It "appears" that you are renaming it, but it is only visual.  If you go into your List Settings and then click on a column definition, if you then look at the address bar in your browser, at the very end will be the "real" column name.

That said - some formulas in PowerApps will honor the changed name and some will require the real name.  Just depends on which function.  AND, for those that do honor the "changed name" they will also accept the "Real name".  For those that don't, well, they'll only accept the "real name".

 

Thanks for the Super Hero title and I hope that your first post to this forum was better than you expected!!  Some of us on this forum really go the Nth mile to make sure the information is accurate, correct and helpful!

_____________________________________________________________________________________
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.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

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