Hello,
I'm trying to create a new record in Azure SQL DB where I have a primary key with an IDENTITY property set. I'm using this kind of syntax:
Patch('myTable',Defaults('myTable'),{Id:Blank()},{field:something.Text},etc)
My problem:I'm getting the message that my ID field is obligatory and no record is created...
I've tried a few different syntax (without the Defaults, without the Blank) but I'm still not able to get it to work. Since this is about the most classic CRUD pattern there is, I'm guessing it is supported and I'm just doing something silly.
Anyone has a hint ?
Thanks!
Solved! Go to Solution.
I had indeed a problem with my { } as you noticed. But that wasn't the root cause.
I did some further investigation and the main issue was that my back-end was using a SEQUENCE object rather than an IDENTITY to generate the ID value in Azure SQL DB. Power Apps didn't seem to like that. I changed it to a regular IDENTITY and that did the trick.
For the Blank() function, I tried it after reading another thread on the forums relating to Patch and Azure SQL DB.
So, in the end, the correct answer was : using IDENTITY rather than SEQUENCE and using the syntax
Patch('MyTable', Defaults('MyTable'), {Field1:Input1.Text, Field2:Input2.Text, ...})
Thanks a lot for the prompt help!
Hi @FredForest,
I think the issue here should be record format you specified under the Patch function.
Patch('myTable',Defaults('myTable'),{Id:Blank()},{field:something.Text},etc)
A single record is quoted by {}, so in the formula above, the formula is trying to create two records,and the second record
{field:something.Text}
is without the required primary key, which is not allowed in PowerApps.
Besides, if you would like to generate one record, please specify the different fields in the record within one brace.
In addition, would you please explain a bit for:
{Id:Blank()}
Blank() function is not available to patch null values in such a scenario, and the ability to patch Null values is still under developing.
So I assume the workable formula should be:
Patch('myTable',Defaults('myTable'),{Id:Idstring,field:something.Text})
Regards,
Michael
I had indeed a problem with my { } as you noticed. But that wasn't the root cause.
I did some further investigation and the main issue was that my back-end was using a SEQUENCE object rather than an IDENTITY to generate the ID value in Azure SQL DB. Power Apps didn't seem to like that. I changed it to a regular IDENTITY and that did the trick.
For the Blank() function, I tried it after reading another thread on the forums relating to Patch and Azure SQL DB.
So, in the end, the correct answer was : using IDENTITY rather than SEQUENCE and using the syntax
Patch('MyTable', Defaults('MyTable'), {Field1:Input1.Text, Field2:Input2.Text, ...})
Thanks a lot for the prompt help!
User | Count |
---|---|
140 | |
136 | |
77 | |
75 | |
69 |
User | Count |
---|---|
224 | |
186 | |
68 | |
64 | |
57 |