I have a form with Submit button using a patch so I can create new records based on how many agencies are selected. The form has an attachment field from the SharePoint list. I need what attachment(s) to be added to every row that creates a new record. I have the right records being created so I just need to get the attachment(s) on every record. I have tried multiple different ways and nothing I am doing is working. I have great luck in the forum so I figured I would try again.
// 1. Collect records and safely handle Blank Agencies
ClearCollect(
colIRRecords,
ForAll(
If(
IsBlank(valAgencies.SelectedItems),
[ { Value: Blank() } ], // Fallback if multi-select is empty
valAgencies.SelectedItems
) As SelectedAgency,
{
Title: Coalesce(SelectedAgency.Value, "NoAgency") & " " &
Substitute(
Substitute(
Substitute(
Substitute(
Substitute(
Substitute(
Substitute(
Substitute(
Substitute(
Substitute(
Substitute(
Substitute(
Substitute(
Substitute(valShortDesc.Text, " ", ""),
" ", ""
),
"@", ""
),
"#", ""
),
"$", ""
),
"|", ""
),
":", ""
),
"\\", "" /* Corrected backslash escape */
),
"/", ""
),
"[", ""
),
"]", ""
),
",", ""
),
"'", ""
),
Char(34), "" /* For double quotes (") */
),
DtOfInc: Today(),
DateDetected: valDtDetected.SelectedDate,
CaseNum: valCaseNum.Text,
Status: If(!IsBlank(valStatus.Selected), {Value: valStatus.Selected.Value}, Blank())
// I have more fields but removed them for this forum
}
)
);
// 2. Patch Collection to Data Source, safely handling blank attachments
ForAll(
colIRRecords As NewRec,
Patch(
MyList,
Defaults(MyList),
NewRec
)
);
// 3. Success Notification
Notify("Incident submitted successfully!", NotificationType.Success, 3000);
// 4. Clear the form data and revert to default values
ResetForm(frmNYSOCIntake);
// 5. Optional: Set the form back into "New" mode if creating subsequent entries
NewForm(frmMyForm);