Certainly! I understand the requirement, and I'm here to help you modify the formula to achieve the desired functionality.
First, you'll need to generate a unique OfferId that can be applied to all items in the offerCol collection. One way to do this is to use the Now() function to create a timestamp, which can be used as a unique ID. You can then use ClearCollect to create a temporary collection with the same data from offerCol but with the additional OfferId column.
Here's the updated formula:
- Create the
OfferId using the current timestamp.
- Use
ClearCollect to create a temporary collection with the OfferId.
- Patch the temporary collection to the SharePoint list.
// Generate unique OfferId based on the current timestamp
Set(gloOfferId, Text(Now(), "[$-en-US]yyyymmddhhmmss"))
// Create a temporary collection with the same data from offerCol and the additional OfferId
ClearCollect(
colTemp,
AddColumns(
offerCol,
"OfferId", gloOfferId
)
)
// Go through the temporary collection and Patch it to the SharePoint list
ForAll(
colTemp,
Patch(
OfferList,
Defaults(OfferList),
{
LicenseName: LicenseName,
TermDuration: TermDuration,
BillingPlan: BillingPlan,
SkuId: SkuId,
Price: Price,
Quantity: Quantity,
LineDiscountRate: LineDiscountRate,
Total: Total,
OfferId: OfferId // Using the unique OfferId for the collection upload
}
)
)
However, I recommend Patch outside ForAll - to do so, try below:
- Generate the unique
OfferId as before.
- Use
ClearCollect to create a temporary collection (colTemp) with the OfferId.
- Create another temporary collection (
colChanges) using ForAll to go through the colTemp and prepare the records you want to patch.
- Use
Patch outside of ForAll to apply the changes to the SharePoint list.
// Generate unique OfferId based on the current timestamp
Set(gloOfferId, Text(Now(), "[$-en-US]yyyymmddhhmmss"))
// Create a temporary collection with the same data from offerCol and the additional OfferId
ClearCollect(
colTemp,
AddColumns(
offerCol,
"OfferId", gloOfferId
)
)
// Go through the temporary collection and prepare the records for patching
ClearCollect(
colChanges,
ForAll(
colTemp,
{
LicenseName: LicenseName,
TermDuration: TermDuration,
BillingPlan: BillingPlan,
SkuId: SkuId,
Price: Price,
Quantity: Quantity,
LineDiscountRate: LineDiscountRate,
Total: Total,
OfferId: OfferId // Using the unique OfferId for the collection upload
}
)
)
// Patch the prepared records to the SharePoint list
Patch(
OfferList,
Defaults(OfferList),
colChanges
)
See if it helps @Ebbe1988