I have a SharePoint list integrated with a PowerApp. In the OnSave of the SharePointIntegration I am trying to update and validate different forms based on a selected vale and a checkbox. I cannot seem to get everything right with my if statements. I have some datacards required but with the current statements, it is letting me click the save button with or without the required fields populated but it is not actually saving my item to the list. Any help is appreciated. Below is the code I currently have:
If (
Checkbox1.Value = true,
If(
BasicInfoForm.Mode = FormMode.New && BasicInfoForm.Valid,
Patch(
'Business Asset',
Defaults('Business Asset'),
BasicInfoForm.Updates,
ManualAddForm.Updates
),
Patch(
'Business Asset',
SharePointIntegration.Selected,
BasicInfoForm.Updates,
ManualAddForm.Updates
)),
ResetForm(BasicInfoForm);
RequestHide()
);
If(
DataCardValue5.Selected.Value = "Manual Add" && Checkbox1.Value = false,
If(
BasicInfoForm.Valid && ManualAddForm.Valid,
If(
BasicInfoForm.Mode = FormMode.New,
Patch(
'Business Asset',
Defaults('Business Asset'),
BasicInfoForm.Updates,
ManualAddForm.Updates
),
Patch(
'Business Asset',
SharePointIntegration.Selected,
BasicInfoForm.Updates,
ManualAddForm.Updates
)
);
Notify("Please fill the required fields")
);
ResetForm(BasicInfoForm);
ResetForm(ManualAddForm);
RequestHide();
);
If(
DataCardValue5.Selected.Value = "Cost Adjustment" && Checkbox1.Value = false,
If(
BasicInfoForm.Valid && CostAdjustmentForm.Valid,
If(
BasicInfoForm.Mode = FormMode.New,
Patch(
'Business Asset',
Defaults('Business Asset'),
BasicInfoForm.Updates,
CostAdjustmentForm.Updates
),
Patch(
'Business Asset',
SharePointIntegration.Selected,
BasicInfoForm.Updates,
CostAdjustmentForm.Updates
);
Notify("Please fill the required fields")
)
);
ResetForm(BasicInfoForm);
ResetForm(CostAdjustmentForm);
RequestHide();
);
If(
DataCardValue5.Selected.Value = "Transfer" && Checkbox1.Value = false,
If(
BasicInfoForm.Valid && TransferForm.Valid,
If(
BasicInfoForm.Mode = FormMode.New,
Patch(
'Business Asset',
Defaults('Business Asset'),
BasicInfoForm.Updates,
TransferForm.Updates
),
Patch(
'Business Asset',
SharePointIntegration.Selected,
BasicInfoForm.Updates,
TransferForm.Updates
);
Notify("Please fill the required fields")
)
);
ResetForm(BasicInfoForm);
ResetForm(TransferForm);
RequestHide();
);
If(
DataCardValue5.Selected.Value = "Disposal" && Checkbox1.Value = false,
If(
BasicInfoForm.Valid,
If(
BasicInfoForm.Mode = FormMode.New,
Patch(
'Business Asset',
Defaults('Business Asset'),
BasicInfoForm.Updates
),
Patch(
'Business Asset',
SharePointIntegration.Selected,
BasicInfoForm.Updates
);
Notify("Please fill the required fields")
)
);
ResetForm(BasicInfoForm);
RequestHide();
);
If(
DataCardValue5.Selected.Value = "Adjust Useful Life / Accelerate Depreciation" && Checkbox1.Value = false,
If(
BasicInfoForm.Valid,
If(
BasicInfoForm.Mode = FormMode.New,
Patch(
'Business Asset',
Defaults('Business Asset'),
BasicInfoForm.Updates
),
Patch(
'Business Asset',
SharePointIntegration.Selected,
BasicInfoForm.Updates
);
Notify("Please fill the required fields")
)
);
ResetForm(BasicInfoForm);
RequestHide();
)