admin管理员组

文章数量:1406949

I have one form in my canvas app which has fome feilds and a attachment. On submit button I have this code

If(Connection.Connected, 
//Online Mode: Save to SharePoint
SubmitForm(EditForm1)
,
//Offline Mode: Store data locally
Collect(colOfflineRecords, {
    RecordID: If(EditForm1.Mode = FormMode.New, Text(GUID()), EditForm1.LastSubmit.ID),
    IsNew: If(EditForm1.Mode = FormMode.New, true, false),
    Date: DataCardValue10.SelectedDate,
    'Building Name': DataCardValue11.Selected,
    'Building Number': DataCardValue12.Text,
    'AC Unit Number': DataCardValue13.Text,
    'Unit Model Number': DataCardValue14.Text,
    'Unit Serial Number': DataCardValue15.Text,
    'Maintenance Time (minutes)': DataCardValue16,
    'Maintenance Completed': DataCardValue17.Value,
    Notes: DataCardValue18.Text,
    Attachments: ForAll(
    DataCardValue9.Attachments, 
        {
            DisplayName: Name,
            FileContent: JSON(Value, JSONFormat.IncludeBinaryData)
        }
    )
});

SaveData(colOfflineRecords, "OfflineData");
Notify("Data saved offline!", NotificationType.Success);
Back()
);

While app comes to online I have this code

If(Connection.Connected And CountRows(colOfflineRecords) > 0, 
Notify("Started Offline data sync!", NotificationType.Success);
// Transform colOfflineRecords to a JSON-friendly structure
Set(varJsonRecords,
    JSON(
        ForAll(
            colOfflineRecords,
            {
                RecordID: RecordID,  
                IsNew: IsNew,  
                Date: Date,
                'Building Name': 'Building Name',
                'Building Number': 'Building Number',
                'AC Unit Number': 'AC Unit Number',
                'Unit Model Number': 'Unit Model Number',
                'Unit Serial Number': 'Unit Serial Number',
                'Maintenance Time (minutes)': Value('Maintenance Time (minutes)'.Text),
                'Maintenance Completed': 'Maintenance Completed',
                Notes: Notes,

                //Convert Attachments into a serializable format
                Attachments: ForAll(
                    Attachments,
                    {
                        DisplayName: DisplayName,
                        FileContent: JSON(FileContent, JSONFormat.IncludeBinaryData)
                    }
                )
            }
        ),
        JSONFormat.IncludeBinaryData // Keep binary data for Power Automate
    )
);

//Call Power Automate with cleaned JSON data
'UploadRecordsAndAttachments'.Run(varJsonRecords);

//Clear offline records after sync
Clear(colOfflineRecords);
SaveData(colOfflineRecords, "OfflineData");
Notify("Offline data synced successfully!", NotificationType.Success);
);

I have tried many things for FileContent: JSON(FileContent, JSONFormat.IncludeBinaryData) this line but everytime it gives me

"Attachments": [
  {
    "DisplayName": "0ff4c8a5-676c-4500-8e37-72d90a634a4e.jpg",
    "FileContent": "\"/SessionStorage/40d6af4dda7039b5fe973857b02c9541fe22f1035f1135a0a8fcbc6c467a8b46.jpg\""
  }
],

SessionStorage path instead of FileContent.

I have tried

FileContent: JSON(Last(FirstN(Split(Value, ";base64,"), 2)).Value, JSONFormat.IncludeBinaryData)

and

FileContent: Text(Value, JSONFormat.IncludeBinaryData)

but not any succsess.

本文标签: Not getting FileContent of Attachments in canvas app collectionStack Overflow