i'm making a powerapps and i have gallery in my page will patch its data in share point list .
my problem with the gallery :
in the gallery i have same text fields , one of them is attachment to add picture , also have buttons like add button , edit and delete .
add button to add the record to the collection and open another record to fill it .
now in the gallery the attached picture when i fill the record each record will have its own picture but after i finished all filling of the page and submit the form and patch the gallery data , the attachments of the records have the same first picture or attachment of the same record .
so i put this code in the add button of the gallery :
If(
!IsBlank(VisitorName_Textbox_1.Text) &&
!IsBlank(Nationality_Textbox_1.Text) &&
!IsBlank(DocumentType_Textbox_1.Text) &&
!IsBlank(QidPassportNumber_Textbox_1.Text),
// Calculate the total days for the visitor in the same month and year
If(
Sum(
ClearCollect(
colVisitorsFoCalculation,
ShowColumns(
Filter(
Visitors,
EmpEmail = DataCardValue12.Text &&
VisitorName = VisitorName_Textbox_1.Text &&
FromDate >= Date(Year(DataCardValue18.SelectedDate), Month(DataCardValue18.SelectedDate), 1) &&
FromDate < Date(Year(DataCardValue18.SelectedDate), Month(DataCardValue18.SelectedDate) + 1, 1)
),
TotalDays
)
),
TotalDays
) + Value(DataCardValue21.Text)<= 6, // Check if total days are less than or equal to 6
// Patch data if the visitor has not exceeded the limit
Patch(
colVisitors,
ThisItem, // Reference the current item in the collection
{
RequestID: RequestIDVar,
VisitorName: VisitorName_Textbox_1.Text,
Nationality: Nationality_Textbox_1.Text,
DocumentType: DocumentType_Textbox_1.Text,
QidPassportNumber: QidPassportNumber_Textbox_1.Text,
Attachment: AddMediaButton1_1.Media,
AttachmentName: AddMediaButton1_1.FileName,
ViewMode: true // Switch to view mode after adding
}
);
// Add a new empty row to the collection for a new entry
Collect(
colVisitors,
{
VisitorName: "", // Empty VisitorName
Nationality: "", // Empty Nationality
DocumentType: "", // Empty DocumentType
QidPassportNumber: "", // Empty QidPassportNumber
Attachment: "", // Empty Attachment
AttachmentName:"", // Empty AttachmentFileName
ViewMode: false, // Allow editing for the new row
EditMode: false // Disable editing for new entry
}
),
// If the condition is not met, show an error notification
Set(varTotalDaysPopup, true)
),
// If required fields are blank, show a notification
Notify("Please fill all the required fields before submitting.", NotificationType.Error)
);
and put this code in the final submit button to add all of my data to the sharepoint :
i think we have to do a flow to put the image in the sharepoint list and passing the attachment,attachmentfilename as an input , and call the flow in the submit button code