Hello everyone,
I am doing a form where user should fill in all data but it seems that what (i think) should work is not working as expected.... the code below is assigned to the submit button (onselect) but if user would visit the list it self he could still bypass it with the save button... any idea how to prevent that?
//validation starts here
If(And(
//is the date free?
If(checkresult.Text = "not ok", false, true),
//do you have enough holiday and do we wory about that?
If(((Value(value_selected_days.Text) > value_available_days.Selected.RestVacationDays) And value_over_limit.SelectedText.Value="No"), false, true),
//are you trying to book more days in advance then we allow you to?
Not(If(DateDiff(Today(), todate.SelectedDate) > 30,true,false))
),
//if above is true it will create a variable like below:
Set(validationCheck,true),
Set(validationCheck,false)
);
//the actual collect if validation variable is true:
If(
validationCheck=true,
//this creates a new entry in the AR LIST (Absence request)
Patch(AR,Defaults(AR),{From:fromdate.SelectedDate,To:todate.SelectedDate,TypeOfRequest:"Holiday",AvailableVacationDays:value_available_days.Selected.RestVacationDays,RequestedVacationDays:Value(value_selected_days.Text),NewVacationDays:Value(value_available_days_new.Text),UPN:'upn-label_1'.Text});
//this updates the vacation status (substracts days) in the HR Settings list, right after the request ist placed
Patch(HR_settings,LookUp(HR_settings, UPN = 'upn-label_1'.Text),{RestVacationDays:Value(value_available_days_new.Text)});
//this udpates the column Status in table TNA to "Set"
UpdateIf(tna, (UPN = 'upn-label_1'.Text And DateInNr >= Value(fromdatenr.Text) And DateInNr <= Value(todatenr.Text)), {Status: "Set" });
//other required parameter so it will show sucsess is navigate to success screen
Navigate( Success, ScreenTransition.CoverRight ),
//else value starts here, if not all fields are filled
Navigate( 'FormHoliday-Error', ScreenTransition.CoverRight )
);
Solved! Go to Solution.
Hi @Sifu ,
Do you customize a form app in your SP List using Power Apps?
Do you add a additional "Submit" button in your custom form screen to submit form data?
If you want the validation formula to be worked as expected when you click the "Save" button in your custom form app, please try the following workaround:
Set the OnSave property of the SharePointIntegration control in your custom form app to following:
//validation starts here
If(And(
If(checkresult.Text = "not ok", false, true),
If(
Value(value_selected_days.Text) > value_available_days.Selected.RestVacationDays && value_over_limit.SelectedText.Value="No", false, true
),
Not(If(DateDiff(Today(), todate.SelectedDate) > 30,true,false))
),
Set(validationCheck,true),
Set(validationCheck,false)
);
If(
validationCheck=true,
Patch(
AR,
Defaults(AR),
{From:fromdate.SelectedDate,To:todate.SelectedDate,TypeOfRequest:"Holiday",AvailableVacationDays:value_available_days.Selected.RestVacationDays,RequestedVacationDays:Value(value_selected_days.Text),NewVacationDays:Value(value_available_days_new.Text),UPN:'upn-label_1'.Text});
Patch(HR_settings,LookUp(HR_settings, UPN = 'upn-label_1'.Text),{RestVacationDays:Value(value_available_days_new.Text)});
//this udpates the column Status in table TNA to "Set"
UpdateIf(tna, (UPN = 'upn-label_1'.Text And DateInNr >= Value(fromdatenr.Text) And DateInNr <= Value(todatenr.Text)), {Status: "Set" });
//other required parameter so it will show sucsess is navigate to success screen
Navigate( Success, ScreenTransition.CoverRight ),
//else value starts here, if not all fields are filled
Navigate( 'FormHoliday-Error', ScreenTransition.CoverRight )
);
Please try above solution, then check if the issue is solved.
Regards,
Rather than a long complex formula I've normally done this by adding code to each control's onChange property to increment a counter if the value is not empty and decrement if it is. Then put a simple IF() in your display mode for the submit button. Disable the button if the counter is greater than or equal to the number of controls on the page. You have to add things in a lot of places, but its much simpler to maintain.
@Pstork1 thanks for info, but i am not getting how this will prevent users from selecting the save button
Sorry, I didn't know you were talking about an integrated form. For that you can put something in the OnSave event that will keep the form from being submitted. I'm not aware of any way to disable the built-in menu entry.
If you do not want people interacting with the list you can create a view with no entries (ID=0) and then not allow others to create views. You can also keep the list from showing up in searches through a control in the list settings.
You can't keep people from making their own private views of a list in SharePoint online.
Ignore this.
you could stop them if you give them access only for "add only" and create a view which you find ok, ...this however does not solve the problem, i will test the on save feature on monday
Hi @Sifu ,
Do you customize a form app in your SP List using Power Apps?
Do you add a additional "Submit" button in your custom form screen to submit form data?
If you want the validation formula to be worked as expected when you click the "Save" button in your custom form app, please try the following workaround:
Set the OnSave property of the SharePointIntegration control in your custom form app to following:
//validation starts here
If(And(
If(checkresult.Text = "not ok", false, true),
If(
Value(value_selected_days.Text) > value_available_days.Selected.RestVacationDays && value_over_limit.SelectedText.Value="No", false, true
),
Not(If(DateDiff(Today(), todate.SelectedDate) > 30,true,false))
),
Set(validationCheck,true),
Set(validationCheck,false)
);
If(
validationCheck=true,
Patch(
AR,
Defaults(AR),
{From:fromdate.SelectedDate,To:todate.SelectedDate,TypeOfRequest:"Holiday",AvailableVacationDays:value_available_days.Selected.RestVacationDays,RequestedVacationDays:Value(value_selected_days.Text),NewVacationDays:Value(value_available_days_new.Text),UPN:'upn-label_1'.Text});
Patch(HR_settings,LookUp(HR_settings, UPN = 'upn-label_1'.Text),{RestVacationDays:Value(value_available_days_new.Text)});
//this udpates the column Status in table TNA to "Set"
UpdateIf(tna, (UPN = 'upn-label_1'.Text And DateInNr >= Value(fromdatenr.Text) And DateInNr <= Value(todatenr.Text)), {Status: "Set" });
//other required parameter so it will show sucsess is navigate to success screen
Navigate( Success, ScreenTransition.CoverRight ),
//else value starts here, if not all fields are filled
Navigate( 'FormHoliday-Error', ScreenTransition.CoverRight )
);
Please try above solution, then check if the issue is solved.
Regards,
User | Count |
---|---|
251 | |
102 | |
94 | |
48 | |
37 |