cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Applicable88
Helper II
Helper II

sharepoint form duplicate search when editing a item

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. 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

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!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


View solution in original post

5 REPLIES 5
iAm_ManCat
Super User
Super User

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!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


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!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


@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!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (2,680)