Hi
I have customised a Sharepoint form using power apps, in the OnSave event I am doing a check, if all good submit, if not display an error.
- If there are validation issues it works correctly, doesnt submit the form & displays the error
- If there are no validation issues, it submits the form BUT STILL displays the error message
I have tried lots of different ways but always the the same behaviour, a valid submission looks like:
My OnSave event looks like:
Set(varApprovalStatus, "Pending"); Set(varCreateTotalSelectCount, VarContractSelectCount + VarTermSelectCount + VarApproverSelectCount); Set(varEditTotalSelectCount, VarEdiTermSelectCount + VarEditApproverSelectCount);
If(SharePointFormMode="CreateForm" And varCreateTotalSelectCount=3, SubmitForm(TerminationsSPFormNew), Notify("Check required fields",NotificationType.Error));
If(SharePointFormMode="EditForm" And varEditTotalSelectCount=2, SubmitForm(TerminationsSPFormEdit), Notify("Check required fields",NotificationType.Error));
Any idea why my Error message displays regardless of if the validation is true or false?
Solved! Go to Solution.
Hey,
Have you nested those If statements? If not, I think that'll be what's causing it.
On a "CreateForm", if it matches the criteria then the first If statement will submit the form, but then the second If statement will return "false" as it's not an EditForm but a CreateForm.
You need to do some nesting so that the form will only be interrogate against one of those IF statements
I don't know if this is causing your error, but there is no FormMode called CreateForm unless this is something you have set somewhere.
The valid form Modes are New, Edit and Display.
Oh yeah sorry should have said, I have a Var setup called SharePointFormMode to record the form mode, sorry 🙂
Hey,
Have you nested those If statements? If not, I think that'll be what's causing it.
On a "CreateForm", if it matches the criteria then the first If statement will submit the form, but then the second If statement will return "false" as it's not an EditForm but a CreateForm.
You need to do some nesting so that the form will only be interrogate against one of those IF statements
Fixed, swapped the ; for a , and all good:
Set(varApprovalStatus, "Pending"); Set(varCreateTotalSelectCount, VarContractSelectCount + VarTermSelectCount + VarApproverSelectCount); Set(varEditTotalSelectCount, VarEdiTermSelectCount + VarEditApproverSelectCount);
If(SharePointFormMode="CreateForm" And varCreateTotalSelectCount=3, SubmitForm(TerminationsSPFormNew), Notify("Check required fields",NotificationType.Error),
If(SharePointFormMode="EditForm" And varEditTotalSelectCount=2, SubmitForm(TerminationsSPFormEdit), Notify("Check required fields",NotificationType.Error)));
Thanks
Ah, swapped the ; for , and moved a bracket, took me a minute to spot that heh. Unfortunately I think that solution might only work for new forms. I believe you'll need a formula more like this.
If(
SharePointFormMode="CreateForm",
If(
varCreateTotalSelectCount=3, SubmitForm(TerminationsSPFormNew), Notify("Check required fields",NotificationType.Error)),
If(
varEditTotalSelectCount=2, SubmitForm(TerminationsSPFormEdit), Notify("Check required fields",NotificationType.Error))
);
User | Count |
---|---|
165 | |
90 | |
73 | |
64 | |
62 |
User | Count |
---|---|
211 | |
153 | |
96 | |
87 | |
66 |