Set(
serializedQuoteData,
JSON(
ForAll(
QuoteDataCollection,
{
'Participant Name': 'Participant Name',
'NDIS Number': 'NDIS Number',
Day: Day,
Occurrence: {Value: Occurrence.DisplayTitle},
Year: Year,
Frequency: {Value: Frequency.Value},
'Custom Frequency': 'Custom Frequency',
'Service Start Date': DateValue('Service Start'),
'Service End Date': DateValue('Service End'),
Weeks: Value(Weeks),
'Start Time': 'Start Time',
'Finish Time': 'Finish Time',
Hours: Value(Hours),
Kilometers: Kms,
'Support Item': 'Support Item',
Ratio: {Value: Ratio},
Rate: Rate,
'Custom Rate': Value('Custom Rate'),
'Number Of Staff': Value('Num Staff'),
'Description Of Service': Desc,
'Assigned Staff Member': Assigned,
'Total Cost': Value(Total)
}
),
JSONFormat.Compact// Compact JSON format
)
);
// Step 3: Patch to SharePoint, including dynamic assignment of Status, Quote Type, and ID
Patch(
'NDIS Quote Tool Quote Data',// SharePoint list name
Defaults('NDIS Quote Tool Quote Data'),// Create new record
{
'Participant Name': ParticipantName.Value,
'NDIS Number': NDISNumber.Value,
'Selected Service': SelectedService.Value,
Day: ForAll(
FormattedDaysTable,
{Value: Value}
),
Occurrence: {Value: Occurrence.Selected.DisplayTitle},
Year: QuoteYear.Selected,
Frequency: QuoteFrequency.Selected,
'Custom Frequency': CustomFrequency.Value,
'Service Start Date': DateValue(ServiceStart.SelectedDate),
'Service End Date': DateValue(ServiceEnd.SelectedDate),
Weeks: QuoteWeeks.Value,
'Start Time': Text(
StartTime.Value,
"HH:mm"
),
'Finish Time': Text(
FinishTime.Value,
"HH:mm"
),
Hours: Value(QuoteHours.Value),
Kilometers: Kms.Value,
'Support Item': NDISSupportItem.Selected.'Support Item',
Ratio: {Value: RatioSelector.Selected.Value},
Rate: Value(SupportRate.Value),
'Custom Rate': Value(CustomRate.Value),
'Number Of Staff': Value(NumOfStaff.Value),
'Description of Service': QuoteDesc.Value,
'Assigned Staff Member': AssignedStaff.Value,
'Total Cost': Value(QuoteTotal.Value),
'Item Id': uniqueDraftID,
// Unique identifier for the draft
FormData: serializedQuoteData,
// Save entire collection as JSON
// Fields for status and draft type:
Status: {Value: "Pending"},
// Draft status is Pending
'Quote Type': {Value: "Draft"},
// Quote type is set to Draft
'User Email': UserMail.Value,
'Users With Access': Concat(
ComboboxCanvas2.SelectedItems,
Mail,
" ; "
)
}
);
I am having trouble retrieving this data to populate the galleries when the user selects a draft, template or completed quote.
I set up a flow to retrieve the data - The flow is as follows:
Trigger: When Power Apps calls a flow - Input is ItemId (This is the id of the item in the list that is being selected - Set(ItemId, SelectedItem.'Item Id')
Apply to each: Inside this loop i have:
Compose: From the FormData column of the Get Items output (Where the JSON is stored)
Select: Here i map out the exact fields i want to retrieve
MyResponse,
ParsedJSON.Run(ItemId)
);