Hi All,
I need to avoid different user be able to write same data on excel file by clicking a button.
If 2 users click the button contemporary they can write the same data also if I check data existing on excel before.
Is there some function helpful to lock excel data source on click button ?
Thanks in advance
Elia
Solved! Go to Solution.
@Anonymous ,
SharePoint has the ability you are seeking, as long as you use SubmitForm to write data. If the record has been changed from the one on the form, the second user will get an error message and their data will not write. The Excel interface does not do this (as you have discovered).
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
On your Submit button or Patch button put;
If(CountRows(Filter(DataSource,ColumnName = Textbox1.Text)) > 0,Notify(" Record Exist"), SubmitForm (FormName))
Please Change Textbox 1 Datasource and ColumnName to your actual name
------------
If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.
yes I do this check before to patch the excel but I noticed that 2 users are able to write same data if the button clicks are simultaneous.
It seems it take much to write on excel
Following the code
Refresh(BookingData);
if(CountRows(
Filter(//User has already booked for this date
BookingData,
BookingDate = Text(
selectedDate,
"[$-it-IT]dd/mm/yyyy"
),
Status = "Booked"
)
) > 0,
Set(
reason,
"userDateAlreayBooked"
);
Navigate(Unavailable),
Patch(
BookingData,
Defaults(BookingData),
{
BookingDate: Text(
selectedDate,
"[$-it-IT]dd/mm/yyyy"
),
Seat: Button1.Text,
BookingUser: User().FullName,
Status: "Booked",
Floor: "First",
Email: User().Email,
ActionDate: Text(
Today(),
"[$-it-IT]dd/mm/yyyy"
)
}
);
Navigate(Success)
)
Excel might be slow but Check the formatting of bookingDate in
BookingDate = Text(
selectedDate,
"[$-it-IT]dd/mm/yyyy")
Also what is the purpose of:
Status = "Booked"
------------
If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.
Is not possible to lock the datasource ?
You didn't respond to my post.
What is locking Datasource, you don't want users to Use the Datasource?
------------
If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.
What I mean is to lock datasource during read and write operation
To avoid writing the same data, I suggest you make that field automatic so that users will have nothing to do with it. So Auto numbering of the field or using Guid() could help prevent same data by different users
------------
If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.
yes , if the record is already written on excel I disable the button ant it works , but if I have 2 users at the same time that connect to the app and click the Seat button to book a place , they can because could happen they click at the same time the button, so the refresh operation read excel at the same time and my checks fail.
If I could do the refresh, the filter and the patch operations atomically I could solve the issue because only one user per time can have the lock to the data source
Thanks again
Then at the beginning of the Patch refresh the Datasource;
Refresh(Table1);Patch(......)
------------
If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.
User | Count |
---|---|
221 | |
99 | |
94 | |
55 | |
36 |
User | Count |
---|---|
273 | |
105 | |
104 | |
60 | |
60 |