cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
marsdendd
Helper II
Helper II

Problem updating SharePoint List using ForAll/Patch

Hi Community, 

I have an issue updating my SP List using ForAll and Patch. Expression below:

 

ForAll(
    colRiskRegisterAdd,
    Patch(
        RiskRegister,
        Defaults(RiskRegister),
        {
            RiskID: ThisRecord.ID,
            RiskGroup: ThisRecord.RiskGroup,
            Risk: ThisRecord.Risk,
            RiskCategory: ThisRecord.RiskCategory,
            RiskDescription: ThisRecord.RiskDescription,
            MonetaryImpact: numMonetaryImpact.Text,
            ReputationalImpact: numReputarionalImpact.Text,
            OperationalImpact: numOperationalImpact.Text,
            FinalImpactScore: numFinalImpactScore.Text,
            Likelihood: numLikelihood.Text,
            InherentRisk: numInherentRisk.Text,
            ControlEffectiveness: numControlEffectiveness.Text,
            ResidualRisk: numResidualRisk.Text 
        }
    )
);

 

The issue I face is the ForAll adds each Record as expected but adds the last entered set of numerical values to all records. What do i need to do to ensure that each record is updated with the corresponding set of numerical values.  Capture.PNG

 Thanks

 

6 REPLIES 6
notj
Post Prodigy
Post Prodigy

@marsdendd OK, so what's the issue/error?

The ForAll adds each Record as expected but adds the last entered set of numerical values. So when adding more than one record the same set of numerical values are updated to all records.

 

I understand the ForAll isnt a loop in the traditional sense but id appreciate any help on how to ensure the values are correctly written to the corresponding item.

HI @marsdendd ,

Assuming all these fields are in the Collection, this should work

ForAll(
   colRiskRegisterAdd As aRisk,
   Patch(
      RiskRegister,
      Defaults(RiskRegister),
      {
         RiskID: aRisk.ID,
         RiskGroup: aRisk.RiskGroup,
         Risk: aRisk.Risk,
         RiskCategory: aRisk.RiskCategory,
         RiskDescription: aRisk.RiskDescription,
         MonetaryImpact: aRisk.numMonetaryImpact,
         ReputationalImpact: aRisk.numReputarionalImpact,
         OperationalImpact: aRisk.numOperationalImpact,
         FinalImpactScore: aRisk.numFinalImpactScore,
         Likelihood: aRisk.numLikelihood,
         InherentRisk: aRisk.numInherentRisk,
         ControlEffectiveness: aRisk.numControlEffectiveness,
         ResidualRisk: aRisk.numResidualRisk
      }
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Hi @marsdendd 

Just checking if you got the result you were looking for on this thread. Happy to help further if not.

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Hi @WarrenBelz 

 

Thanks for coming back on this. Sorry for my late reply. I wasn't alerted until today that there had been a response. 

 

Ok so i tried the proposed solution and unfortunately it didn't have the desired outcome. 

 

The inclusion of the following in the collection returns a "The type of this argument does not match the expected type "Text" (tried changing SP list column to number and got similar error except type "Number")

 

MonetaryImpact: aRisk.numMonetaryImpact,
ReputationalImpact: aRisk.numReputarionalImpact,
OperationalImpact: aRisk.numOperationalImpact,
FinalImpactScore: aRisk.numFinalImpactScore,
Likelihood: aRisk.numLikelihood,
InherentRisk: aRisk.numInherentRisk,
ControlEffectiveness: aRisk.numControlEffectiveness,
ResidualRisk: aRisk.numResidualRisk

 

Darren

@marsdendd ,

Where are the values you have noted as Text coming from? I assumed they were fields in the collection.

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (3,782)