16
Views
3
Comments
Solved
save the unduplicated record when there are duplicate record in one click
Question

Please refer to UserTeam page

I have set TeamID and UserID as the unique attributes, and dropdown tag as the selection in assign the team. However, if I select more than one team for one user and there is at least one duplicate team, Save action is terminated.

What I expect: 

Even there is duplicated record in the selection, the system can skip the duplicate one and save the rest of them. 

Karen Lau is unduplicated record and I would like to save successfully on it. and the message maybe just advise when team is duplicated. Kindly advise on the solution.




Test1024.oml
Solution

hi @Winnie Lam ,

When you are saving team details, do foreach for list of teams selected for user then in that check if record with user and current team is already exist in database. if it exists then skip that record and if does not exist then create the record in database with user and current team.

PFA OML.

Regards,

Pramod.


 

Test1024.oml
Solution

Hi

Before inserting, do check whether the team is already been mapped to user and then insert.

Thanks

Solution

hi @Winnie Lam ,

When you are saving team details, do foreach for list of teams selected for user then in that check if record with user and current team is already exist in database. if it exists then skip that record and if does not exist then create the record in database with user and current team.

PFA OML.

Regards,

Pramod.


 

Test1024.oml

Hello Winnie,

This depends on you are saving the data in database entity. In your logic you are trying to save all records one after the other without committing the transaction. This way all the CreateUpdate are treated as part of single transaction, therefore if one fails all others fail too.

What you can do is introduce logic before CreateUpdate to check if current User-Team pair already exists

  •  If it exists then store the details in some local variable to be shown to the user, and move to the next User-Team pair in the list
  • If it does not exist then proceed with CreateUpdate operation

Hope it helps!

Solution

Hi

Before inserting, do check whether the team is already been mapped to user and then insert.

Thanks

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.