There is already a row with the key. .

Hey guys,

I have two different forms for the slice views of the same table (but both slice views showing different columns) and I would like to add data to both of them at different times. Obviously I get the error “There is already a row with the key. . .” if try to add on both forms something for the same key (a date).

Is there an option that if the key already exists, the row is updated instead rather than that the metioned error occurs?

Best regards,
Jil

@JilReg
Let say that these are Slice A and Slice B…
You want to add a record to the table with Slice A_Form and you want to edit the same record but add other values with Slice B_Form only OR can it be vice versa? Briefly I’m asking if you have a definite sequence for this operation?

Hey @LeventK,

thanks for asking. There is no defined sequence, it is possible to start with both forms and later do the other form.

Just “visualize” my situation:

  • 1 x Table with the columns: Date, A, B, C, D
  • 1 x Slice_AB with a Form_AB, which only allows filling in the values for Date, A and B
  • 1 x Slice_CD with a Form_CD, which only allows filling in the values for Date, C and D
  • Using Form_AB or Form_CD first and then the other one for the same date does not work and the first used form already filled in the Date (key) and the second form is not able to add another entry with the same Date (key). And it actually should not add another entry with the same date, it should just fill in the missing columns for that date.

Many thanks in advance!

Jil

@JilReg
What is the type of your initial view? I mean, how do your users choose to start with Form_AB or Form_CD? I can propose a couple of alternatives but I need to know about your design first.

Hey @LeventK

the initial view is a table which shows the table and both forms can be accessed from the bottom navigation bar. (Of course everything would be possible with just one form, but for the user convenience it is better with two forms.)

Warm regards,
Jil

EDIT: I am more or less trying to create a tracking app for all kind of habits / daily stuff.

@JilReg
I understand that the [Date] column is your Key column. So shall I understand that, only one record can be created per day?

Hey @LeventK

yes, exactly the [Date] column is the Key column. And of course multiple entries per day would be fine too, but it seems not like a clean solution to me, as then there would already be a row with the same date, just some columns would be empty.

Of course that’s somehow okay:
Date A B C D
1 X X
1 X X

but this seems cleaner:
Date A B C D
1 X X X X

@JilReg
I believe there is no way to provide this with assigning the AB & CD Form views to the bottom navigation bar. Rather than using a table view, I might advise an initial Deck View (i.e. Home) and assigning 3 actions on that Deck View and removing those Form Views from the bottom navigation bar, keeping only this “Home” Deck View.


Action 1: AB Form


Action Description/Expression
Do this Goto another view within this app
Target LINKTOFORM("SliceAB_Form","Date",TODAY())
Only if this condition is true COUNT(SELECT(Tablename[Date],[Date]=TODAY()))=0

Action 2: CD Form


Action Description/Expression
Do this Goto another view within this app
Target LINKTOFORM("SliceCD_Form","Date",TODAY())
Only if this condition is true COUNT(SELECT(Tablename[Date],[Date]=TODAY()))=0

Action 3: Data Edit


Action Description/Expression
Do this Goto another view within this app
Only if this condition is true COUNT(SELECT(Tablename[Date],[Date]=TODAY()))>0
Target
IFS(
	COUNT(SELECT(Tablename[Date],[Date]=TODAY()))>0,
	IFS(
		AND(
			ISBLANK(LOOKUP(TODAY(),"Tablename","Date","ColumnA")),
			ISBLANK(LOOKUP(TODAY(),"Tablename","Date","ColumnB")),
			ISNOTBLANK(LOOKUP(TODAY(),"Tablename","Date","ColumnC")),
			ISNOTBLANK(LOOKUP(TODAY(),"Tablename","Date","ColumnD"))
		),LINKTOROW(TODAY(),"SliceAB_Form"),
		AND(
			ISNOTBLANK(LOOKUP(TODAY(),"Tablename","Date","ColumnA")),
			ISNOTBLANK(LOOKUP(TODAY(),"Tablename","Date","ColumnB")),
			ISBLANK(LOOKUP(TODAY(),"Tablename","Date","ColumnC")),
			ISBLANK(LOOKUP(TODAY(),"Tablename","Date","ColumnD"))
		),LINKTOROW(TODAY(),"SliceCD_Form")
	)
)


2 Likes

Hey @LeventK

many thanks for the detailed answer! Looks like a lot, I’ll try the next days and let you know whether I got successful. :hugs:

Warm regards
Jil

You’re welcome

@JilReg
Just a small reminder here:
I have assumed that in either AB or CD Slice forms, both columns (A & B in AB_Form or C & D in CD_Form) are mandatory (required). If not, we should adjust the expression for Action#3 to get it work.

Many thanks @LeventK !! :hugs: