I am building a Timesheet App tied with a SharePoint List. To ensure that there is only one entry for each date, I am using a single form as both an Edit Form and New Form. If there is an existing entry for a selected date in a date picker, it will pull the existing data from the list for that date and display it to make edits if necessary. If there is NO existing entry, it will display a new form. I am achieving this with Lookup and Isblank.
With the App, an Employee can either book hours for a day OR identify it as Holiday/Leave. To prevent double booking, whenever Holiday/Leave toggle is turned on (yes), logging Hrs will be greyed out and vice versa. Also, an Employee can't book hours for a future date in advance, but can select Holiday/Leave toggles to plan their leave in advance,if needed. I have set conditions for each of the Datacards to meet this requirement. However, when we switch from an existing date with logged hours to a future date by picking a date from the Datepicker, the hrs are NOT resetting to 0.0. They just retain the hours for the last selected date and become greyed out. With my other logic, this also disables the Holiday and Leave toggles. How can I reset the Hrs in the Datacard to 0.0, before I switch to a future date and the datacards become greyed out(disabled). I tried ResetForm, but it causes other issues (like allowing duplicate entry for a given date). ResetControl with a Variable didn't do anything. Can you please suggest a solution on how to reset specific Datacards/Dropdown Boxes in Editforms without using ResetForm.
Also, if you have any thoughts on any other approach to avoid duplicate entries for each date, please share. I couldn't use a primary key, as we need two columns, Username and Date. If I understand correctly, SharePoint doesn't support composite keys.
Also I am using DateNumber field (a separate number field to indicate a given date) to avoid Delegation issue with Dates Filters in SharePoint. Do we have Date Serial Numbers in SharePoint like we do in Excel (a unique number identifying a date, when we switch number formatting to General in Excel)?
Edit forms have two main states, Edit and New. Are you using these states? You would use Edit when a record exists and New when a record doesn't exist which would include future LEAVE dates, going off your stated business rules.
When using NewForm(yourFormName) it will clear all the form fields for you leaving only Default settings.
Its sounds like you have a lot of cross over logic going on which maybe difficult to untangle? Could you try (or is this your process) when a date is picked AND a record exists for this date, set your form to Edit Mode, else set it to New Mode.
Hi @Eelman, Thanks for your response. Yes, I have it set up that way. If the Lookup returns Blank(), it will be a New Form and if it fetches a record, it will display details of that record using Edit Form. The problem is when I pick a future date in the DatePicker at the top, the Hrs are greyed out (per requirement, its correct), but it doesn't reset the value to "0" before it does that.
As I said previously, you have a lot of cross over logic using the same controls which could be, IMO, better handled with either more screens or more controls.
As a start though, I assume the OnChange of your DatePicker has some code? Does this code do something like
some code ... If( DatePicker1.SelectedDate > Today(), NewForm(myForm), EditForm(myForm) ) ... more code
Without seeing all the logic across all of your controls it's going to be a little hard to troubleshoot though. You could try generating a GIF using ScreenToGIF demo'ing the issue/s which may make things easier to spot?
@Eelman Sorry for my delayed response, I took a different approach with the UI of the App, showing a Calendar now similar to the Calendar Screen for Meetings in Power App.
I had some questions on that, but posted as a separate one.
Learn how to create your own user groups today!
Check out the new Power Platform Community Connections gallery!
Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.