web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / updating a powerapps f...
Power Apps
Unanswered

updating a powerapps form field based on another field value

(1) ShareShare
ReportReport
Posted on by 33

Hello, 
I have a customised form for a sharepoint list. 
I want to update field B with the value of field A 
Is there an easy way to do this? 
I tried update context (varfieldA_value) onchange of field A and then setting the "default" value of field B to be varfieldA_value.
This updates Field B with the correct value. It writes successfully to sharepoint onsubmit.
I thought that was all there was too it, but of course when I subsequently open the form field B shows as blank (presumably because the variable varfieldA_Value is now blank.).

I hope this makes sense, how can I use the variable to make the change but also have the default as "Parent.Default" so I can see the value from the sharepoint list when I open the record again? 
I am not sure if I have to use Patch to achieve this? I am new to the whole environment. Very grateful for any advice. Thanks 

Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    Hi @seangorm ,

    You cannot set the value of a field or control directly like that with a Variable. You can set a Variable and then make that the Default of the control (as you have done). If you also want to see any saved value and only have the Variable if the underlying data field is blank, then you would do this in the Default

    Coalesce(
     Parent.Default,
     varFieldA_Value
    )

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

     

  • seangorm Profile Picture
    33 on at

    Thanks so much for that Warren, That seems to be working as I had hoped, but only if I change the order of the default on the target field to be, - the Variable gets set onchange of the source field.  I hope that makes sense. Thank you - this was driving me mad. 

    Coalesce( 
     varFieldA_Value,
     Parent.Default
    )

     

  • seangorm Profile Picture
    33 on at

    Actually Warren....pardon me - your solution works exactly as you describe. I must have had a weird caching issue. 
    Can I just ask, is it possible to add more than one command in e.g. "Default" on "OnChange"?
    Could I have Set(varA, "A"); Set(varB, "B")? 
    i.e. 2 actions, separated by a ";"?
    Thanks again for all your help. 

  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    Hi @seangorm ,

    Yes - exactly as you have it.

  • seangorm Profile Picture
    33 on at

    Thanks Warren.
    For anyone else having this issue, I also needed Jeff's advice as outlined here 
    https://powerusers.microsoft.com/t5/Building-Power-Apps/Global-or-context-variable-unchanged-if-page-not-refreshed/td-p/140570 - there seems to be a bug whereby variables were not being refreshed as-expected and this lead to major confusion when testing - until I implemented Jeff's fix,

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard