Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Copying values an item, but keep incrementing a value +1

Posted on by 48

Hi everyone,

 

We are building an app containing a form (based on a SharePoint list) which has about 11 datacardvalues.

 

One of those values (called 'AW') isn't available to edit and is a number value, incrementing by one everytime a new item is added in the SharePoint list. However, our app should also be able to copy items from that list (keeping all the other values), but still incrementing 'AW' by one. Thus, all values should be copied, except that one value, which still needs to change accordingly.

 

The code in 'Default' for 'AW' is: If(Form1.Mode=FormMode.New;Last('Listname').AW+1;Parent.Default), which works fine. The code in 'OnSelect' for our copy button is: Patch('Listname';Form1.Updates);;Navigate(HomeScreen). That does work, it copies everything, but it also copies the 'original' AW-number, which isn't correct, because it should be added +1 based on the last item that was added.

 

Any ideas on how to achieve this? Thanks in advance!

Categories:
  • BCBuizer Profile Picture
    BCBuizer 21,956 on at
    Re: Copying values an item, but keep incrementing a value +1

    Hi @AB_ ,

     

    Glad to see this is now working for you.

     

    The only way to "reset" the ID column is by replacing the existing list with a new one, however that seems overkill.

  • AB-18111337-0 Profile Picture
    AB-18111337-0 48 on at
    Re: Copying values an item, but keep incrementing a value +1

    Thanks for your reply! It works!

     

    And the reason why we don't use ID is that the number starts at 3780. Except if you also have a solution for that.

     

     

  • Verified answer
    BCBuizer Profile Picture
    BCBuizer 21,956 on at
    Re: Copying values an item, but keep incrementing a value +1

    HI @AB_ ,

     

    The idea behind the below is to use a patch to increment AW right after the copied item is created:

     

    Patch(
    	'Listname';
    	Form1.Updates
    );;
    Patch(
    	'Listname';
    	Last(ListName),
    	{AW:Form1.Updates.AW+1}
    );;
    Navigate(HomeScreen)

     

     

    On a different note, why not use the ID column, since that is automatically incremented?

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,591

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,090

Leaderboard