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

OnChange not working..perhaps?

I have a form, Form_NonLinear, which has a about 50 Data Cards, two of which are related to each other.

 

Current_Update_DataCard1, which has Text Input DataCardValue9 in it, is used to collect the current project status update from a user.

 

DataCardValue9 has an OnSelect property of UpdateContext({CurrentUpdateChanged: true}), to set the variable CurrentUpdateChanged to true, if the user puts in a current update. 

 

Running_Log_DataCard1, which has Text Input DataCardValue7 in it, is used to keep a log of all of the Current Updates, along with the user's name and current date.  This data card is always in FormMode.View, so it is not directly editable, and has an Update property as follows:

 

If(CurrentUpdateChanged = true, Text(Now(), "[$-en-US]m/dd/yy") & Char(32) & Char(40) & User().FullName & Char(41) & Char(32) & DataCardValue9.Text & Char(32) & Char(32) & Char(32) & DataCardValue7.Text, DataCardValue7.Text)
 

The result of this would look something like "5/15/20 (John Doe) Called client today for briefing on project, good end result  5/13/20 (John Doe) Scheduled call with client for Friday.   5/11/20 (John Doe) Assigned project from client." and so on.

 

Here is what is intended to happen:

 

Screen Loads, Form is in FormMode.View.   User presses the Edit button, which triggers puts the form in Edit mode, updates a few variables, including CurrentUpdateChanged to false.:

 

EditForm(Form_NonLinear); UpdateContext({EditMode: true}); UpdateContext({LogUnlock: false}); UpdateContext({CurrentUpdateChanged: false});

 

User updates whatever they need to update on the form, and hits the Save button, which Submits the form, and then puts it into DisplayMode.View.

 

When it Submits, the intention is that if the DataCardValue9 has OnChange'd, DataCardValue7 is updated to DataCardValue9 + DataCardValue7.   If DataCardValue9 hasn't changed, DataCardValue7 just updates with its pre-existing data.

 

This all works flawlessly - EXCEPT - and only except - the first time the form is submitted.  DataCardValue9 updates, but DataCardValue7 is still the pre-existing DataCardValue7 value.  If I edit the form and do it again, DataCardValue7 is DataCardValue9 + DataCardValue7 (and the date, username, etc) as would be expected.   I've checked the state of the CurrentUpdateChanged variable, and it is true when DataCardValue9 is updated as it should be.  But for some reason it just isn't reflecting the first time the form is Submitted.

 

The even stranger part is that I've used this same code/functionality in another app that needed the same type of method of capturing updates, and it works fine.

 

Any help would be greatly appreciated.

 

 

 

 

 

 

6 REPLIES 6
Super User III
Super User III

Hi @Mattbart ,

I have a theory on this - to test it, put a label on the screen with the text Running_Log_DataCard1.Update and see if it changes when you change the value of CurrentUpdateChanged.

I have a feeling that the Update property of the card loads with the form and is not updating with the variable if set after this.

@WarrenBelz  Good thought - but nope.  See image.   The data cards in question are shown as "Log Update" and "Project Running Log" in purple.  The label I just added is at the bottom of the image.  It took the current update.  But never posted to the Running Log.    I did it again right after and It took.   I'm befuddled.

 

Screen Shot 2020-05-15 at 8.31.40 PM.png

 

 

@Mattbart ,

This has got to be a bug. You may have to Patch or UpdateIf the value - OnChange of DataCardValue9

UpdateContext({CurrentUpdateChanged: true});
UpdateIf(
   YourSPListName,
   ThisItem,
   {
      YourFieldName:
      Text(Now("[$-en-US]m/dd/yy") & Char(32) & Char(40) & 
      User().FullName & Char(41) & Char(32) & 
      DataCardValue9.Text & Char(32) & Char(32) & Char(32) & 
      DataCardValue7.Text
   {
)

Then the Update of your card

If(
   !CurrentUpdateChanged,
   DataCardValue7.Text
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

@WarrenBelz  Thank you for that suggestion.  Going to try this - but the only thing I'm not sure of is what YourFieldName should be? I'm a relative newbie to PowerApps and trying to make sense of this.

 

Thank you

@Mattbart ,

The field in your list you are storing this data in. You just had not given me the name.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

@WarrenBelzSo I didn't get a chance to try this yet - but strangely enough, yesterday the app started working as-is.  I guess there was some kind of bug on Microsoft's end, because i literally didn't change the code at all, and now it works.   I'll save your suggestion in case it goes crazy again.   Very odd.

 

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (69,824)