Dear all,
I have the following OnSelect function that supposes save all form details to the SharePoint list. Unfortunately, after this function is executed the new item does appear in the SharePoint list even though I get a successful notification message. Could someone please help me find a mistake in the code?
I would like to note that, if I select an existing item in the SharePoint list, edit it, and then use the following OnSelect function to save the updates, the item in the SharePoint list seems to be updated correctly.
/*set status var*/
Set(
varStatus,
"Draft"
);
/*Save form details into a variable varFormData and if the form's mode is New, save as new. If it is not not new update the item.*/
Set(
varFormData,
If(
FormMode = FormMode.New,
Defaults('Demo Test'),
SharePointIntegration.Selected
)
);
/*Patch information that are associated to the forms' instances*/
Patch(
'Demo Test',
varFormData,
form_1.Updates,
form_2.Updates
);
If(
IsEmpty(Errors('Demo Test')),
Notify(
"Success",
NotificationType.Success
);
Navigate(
screen_Confirmation,
ScreenTransition.None
),
Notify(
First(Errors('Demo Test')).Message,
NotificationType.Error
)
)
Solved! Go to Solution.
found an error in the code:(
instead of FormMode = FormMode.New it has to be to varFormMode = FormMode.New
Not sure that there is any particular problem with your formula. The only slight change I would make would be to get rid of the extraneous variable, and not sure what varStatus is used for, but I would get rid of that as well.
/*set status var*/
Set(
varStatus,
"Draft"
);
/*Patch information that are associated to the forms' instances*/
Patch(
'Demo Test',
If(FormMode = FormMode.New, Defaults('Demo Test'), SharePointIntegration.Selected),
form_1.Updates,
form_2.Updates
);
If(
IsEmpty(Errors('Demo Test')),
Notify(
"Success",
NotificationType.Success
);
Navigate(
screen_Confirmation,
ScreenTransition.None
),
Notify(
First(Errors('Demo Test')).Message,
NotificationType.Error
)
)
However, I would recommend that you utilize a SubmitForm rather than Patch the two forms together as you lose all of the error capabilities of the Form and also many of the built in form validate, error logic, and results.
I hope this is helpful for you.
Thank you. I use varStatus to dynamically change values in Combobox field. I have managed to take advantage of the SubmitForm features by adding the following formula in my other OnSelect formula
/*Save form details into a variable varFormData*/
Set(
varFormData,
If(
FormMode = FormMode.New,
Defaults('Demo Test'),
SharePointIntegration.Selected
)
);
/*Validate if all required fields are filled in*/
If(
form_MaterialRegistration.Valid,
/*set status var*/
Set(
varStatus,
"Technologists"
);
/*Save form details into a variable varFormData*/
Set(
varFormData,
If(
FormMode = FormMode.New,
Defaults('Demo Test'),
SharePointIntegration.Selected
)
);
/*Patch information that are associated to the forms' instances*/
Patch(
'Material Testing',
varFormData,
form_1.Updates,
form_2.Updates
);
If(
IsEmpty(Errors('Demo Test')),
Notify(
"Success",
NotificationType.Success
);
Navigate(screen_Confirmation),
Notify(
First(Errors('Demo Test')).Message,
NotificationType.Error
)
),
SubmitForm(form_1)
)
Ironically, if I get rid of the code and make OnSelect = submitForm(form_1), then SharePoint list item is created as expected. It gets quite puzzling..
I would go with simple! This appears quite extensive just to split a form and submit. You might want to take a look over my video on splitting forms across screen (assuming you are doing this across screens - if this is on a single screen, the solution is even much simpler).
I am not seeing any real value to Patching and submitting at the same time. You can avoid the Patch all together and get all the feature of the form back in your hands.
@RandyHayes , noted. However, in my final version, I have 8 screens that all together have around 10 forms. I considered patch would be easier to maintain.. I am not an expert though..
I would just say - consider the balance. Your Patch will require more formulas to check for conditions and errors and ultimately will become more difficult to control and maintain than to simply split the forms across the screens and submit One master form (as I highlight in the video). With that method, there are really only one or two formulas and they are pretty simple ones.
found an error in the code:(
instead of FormMode = FormMode.New it has to be to varFormMode = FormMode.New
User | Count |
---|---|
183 | |
106 | |
88 | |
44 | |
43 |
User | Count |
---|---|
226 | |
108 | |
105 | |
68 | |
68 |