Hello,
I'm using a customized sharepoin list. In the last step when I'm clicking on save I making a duplicate check via the "OnSave" Action in the SharepointIntegration:
If(IsBlank(LookUp(Products; ProductID=DataCardValue3.Text));
SubmitForm(SharePointForm1);
Notify("ProductID already on your list";NotificationType.Error))
It's working fine, as long I'm just using it to make a new entry. But the proplem occurs when for example I want to edit an item, then it also check for duplicates, and of course it finds its own entry as an item which is already on the list. So I can only cancel that and cannot edit entries from before.
How can I overcome this?
Thank you very much in advance. Best.
Solved! Go to Solution.
EditForm() is a function that affects the way a form handles data, NewForm() also affects the way the form ahndles data - To my knowledge, changing the formMode with a variable does not achieve the same result.
I would suggest creating a new list and comparing the code that is there by default when you customize the form, as this provides the most evidence for how a form should be initially before it is customized.
@iAm_ManCat |
Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you! |
Thanks! |
Hi,
You should reference the FormMode - when using New, it will be FormMode.New and the Other FormMode.Edit
So then your code just needs to include - if in formMode.Edit then submit, if new then do the duplicate check then submit
@iAm_ManCat |
Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you! |
Thanks! |
Hi @iAm_ManCat , thanks for your support. I don't understand where I should reference it to.
I did change the NewForm to FormMode.New. But it didn't help.
At the end why shouldn't the OnSave Action work with my nested If-Statement?
I found something which is half satisfying:
I created two global variables when OnEdit and OnNew got triggered to separate the two states wether I'm
doing a edit or a new entry:
OnEdit;; Set(Name;"EDIT")
OnNew;; Set(Name;"NEW")
Then I wrote in OnSave:
If(IsBlank(LookUp(Products; ProductsID=DataCardValue3.Text)) And Name="NEW";
SubmitForm(SharePointForm1);
If(!IsBlank(LookUp(Products; ProductsID= DataCardValue3.Text)) And Name="EDIT";
SubmitForm(SharePointForm1);
Notify("ProductsID is already on the list";NotificationType.Error)))
My initial wish was that I can edit my submitted forms like comments or creatorID etc. in case I submit them wrong.
With the old approach I could open a old entry, but cannot save them under the already submitted productID, because when Im in edit mode the record don't pass the duplication check.
So the gap I now have is that someone can make many duplication entries.
The optimal way would be to go into edit mode with the mask taking it out of the record temporarily .
I don't know it that is what you meant with FormMode.Edit?
Where to put it in the formula?
Best.
does your OnEdit also do EditForm(FormName) as this will define whether it is editing an item or creating a new item
@iAm_ManCat |
Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you! |
Thanks! |
@iAm_ManCat I see I got your point.
Isn't that the same what I reach with the global variable?
Of course I can do the following thing, logicwise:
if(EditForm1.Mode=FormMode.Edit, then do a duplicate search and then submit , if ( EditForm1.Mode=FormMode.New submit rightaway.
I can give an example why it wouldn't solve my problem:
When creating a new item it lookup for that ProductID in the sharepointlist, if lookup returns blank, then new item will created otherwise notify with error. Everything perfect so far.
Now imagine there is a ProductID already in the records ProductID= 12345678
No I'm edit a previous wrong submittted ProductID with number 987654321, and change it to 12345678. There is no protection of duplicate search in the edit mode now. Thats a big loophole.
How to solve this?
And when I now put back duplicate search also in the edit mode and I open a specific item and even without changing the productID itself, it won't let me save it again or change something else in that item.
I hope there is a workaround to this.
Best.
EditForm() is a function that affects the way a form handles data, NewForm() also affects the way the form ahndles data - To my knowledge, changing the formMode with a variable does not achieve the same result.
I would suggest creating a new list and comparing the code that is there by default when you customize the form, as this provides the most evidence for how a form should be initially before it is customized.
@iAm_ManCat |
Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you! |
Thanks! |
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
User | Count |
---|---|
190 | |
95 | |
65 | |
63 | |
58 |
User | Count |
---|---|
243 | |
163 | |
92 | |
80 | |
79 |