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 / My copied record is ov...
Power Apps
Unanswered

My copied record is overwriting the existing record. What did I do?.

(0) ShareShare
ReportReport
Posted on by 831 Moderator

I have a form that is used to enter a new record. It is also used when I copy a record from a gallery to create a new record. This was working for awhile until I ran into some issues with some combo boxes but that is another story. I fixed those combo boxes but now I have this issue.

 

  • When I click a copy button the selected gallery record is copied into a global variable. 
  • The user is redirected to the original form and the record values are populated into the form
  • When the form is submitted it is overwriting the record.

Do I need to switch the form back into New mode? I don't recall doing that when it was working before.

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

    Hi @futr_vision ,

    Yes - you will new New Mode on the Form if you want to write a new record.

     

    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

  • Ami K Profile Picture
    15,679 Super User 2024 Season 1 on at

    @futr_vision - I do not know the finer details of how you have set all this up. But the below is what way I would approach this. I assume you have already done many of these steps, but writing them all out for completeness:

     

    1. On the OnSelect property of the copy Button embedded into your Gallery control, use:

     

    Set(
     'Your Global Variable',
     ThisItem
    );
    Set(
     gbl_copy,
     true
    );
    NewForm('Your Form');
    Notify(
     "Record Copied",
     NotificationType.Success
    );//optional

     

    2. On the OnSelect property of your Gallery control, use:

     

    If(
     gbl_copy,
     Set(
     gbl_copy,
     false
     );
     Notify(
     "Copy cancelled",
     NotificationType.Warning
     )//optional
    );
    Set(
     'Your Global Variable',
     ThisItem
    );
    EditForm('Your Form')

     

    3. On the Default property for every DataCard, use:

     

    If(
     gbl_copy,
     'Your Global Variable'.'The field for this DataCard',
     ThisItem.'The field for this DataCard'
    )

     

    4. On the OnSuccess property of your EditForm:

     

    Set(
     gbl_copy,
     false
    );
    Set(
     'Your Global Variable',
     Self.LastSubmit
    );
    Notify(
     "Saved",
     NotificationType.Success
    )//optional

     

  • futr_vision Profile Picture
    831 Moderator on at

    Thanks

  • futr_vision Profile Picture
    831 Moderator on at

    @Amik 

     

    For my gallery item I don't have a button per se but clicking on the item writes the record to the global variable like this:

     

    Set(
     glbFormData,
     GAL_Campaigns.Selected
    );

     

     

    I did this because I have a form on the page, used for viewing and editing the record, that uses the global variable for the Item.

     

    Then I have a separate button for the copy function. That button uses this code when selected

     

     

    Set(
     glbFormData,
     GAL_Campaigns.Selected
    );
    Set(
     varCopy,
     true
    );
    EditForm(FRM_CampaignForm);
    Navigate('Create Campaign');

     

     

    Now, for the form being copied too my datacards are just using

     

     

    This.'The field for this DataCard'

     

     

    I didn't add in a check for the varCopy since I set the Item for this form also to the global variable (varGlobalForm)

     

    This all works great except when I submit the form it overwrites.

     

    After reviewing your code, it looks like I need to set the form to New First and then switch it to Edit. Is that the piece I am missing?

  • Ami K Profile Picture
    15,679 Super User 2024 Season 1 on at

    @futr_vision - in summary, you will need to follow the instructions provided rather than taking the parts you think you need. Some comments in blue below:

    -----------------------------------------------------------------------------------------------------------------------------

     

    For my gallery item I don't have a button per se but clicking on the item writes the record to the global variable like this:

     

    Set(
     glbFormData,
     GAL_Campaigns.Selected
    );

     

    That's fine, you would just use the OnSelect property of the Gallery control. I note however you are not setting the "gbl_copy" variable to false, which ideally, you should do.

     

    I did this because I have a form on the page, used for viewing and editing the record, that uses the global variable for the Item.

     

    Then I have a separate button for the copy function. That button uses this code when selected

     

    Set(
     glbFormData,
     GAL_Campaigns.Selected
    );
    Set(
     varCopy,
     true
    );
    EditForm(FRM_CampaignForm);
    Navigate('Create Campaign');

     

    You need to follow the instructions provided. We do not want to set the Form Mode to Edit on the Copy button, but to New.

     

    Now, for the form being copied too my datacards are just using

     

    This.'The field for this DataCard'

     

    I didn't add in a check for the varCopy since I set the Item for this form also to the global variable (varGlobalForm)

     

    You must use the formula provided for the Default property of the DataCard. Without this formula, the DataCard will simply return blank because we have set the EditForm mode to New Mode.

     

    This all works great except when I submit the form it overwrites.

     

    After reviewing your code, it looks like I need to set the form to New First and then switch it to Edit. Is that the piece I am missing?

  • Ami K Profile Picture
    15,679 Super User 2024 Season 1 on at

    @futr_vision - example:

    Recording 2024-06-18 041406.gif

  • futr_vision Profile Picture
    831 Moderator on at

    @Amik 

     

    Thanks. Can you help me out and explain steps one and two? It sounds like I am only using step one because I have a stand alone but I am confused. In step one you use NewForm and in step two you use EditForm. Do I not need to use EditForm?

     

    You also set the global copy variable to true in step one and the to false in step two. 

  • Ami K Profile Picture
    15,679 Super User 2024 Season 1 on at

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 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard