cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ananda
Resolver I
Resolver I

Set or update context inside ForAll function of PowerApps

 
I've a requirement, where I need to use updatecontext inside a ForAll function, I understand it's not supported.
Do you have any alternatives/ suggestion on this use case.
Please find the code below, any suggestion is really appreciated.
 
// I'm adding data into SharePoint List from a collection
ForAll (JobSheeWCollection,
Patch ('Job Sheet', Defaults('Job Sheet'),{
Title: Customer,
Mobile: Mobile,
Email: Email,
Address: Address,
MachineModel: Model,
JobType: InsType,
CustomerRemark: CustRemark,
EngRemark: EngRemark,
SLNo: SLNo,
TempID: ID,
JobID: "JOB No : 0" & Last('Job Sheet').ID + 1 } );
 
//Can't assign any variable here, from another collection
//UpdateContext( { sFileContent: Filter(SignatureList,FileContent in ID).FileContent } 😞 Not supported
Filter(SignatureList,FileContent in ID).FileContent; //Executes with no error
//Run a flow which accept 2 parameters (file name, file content), to upload file into sharepoint folder, and
//getting error in below line.
CreateSignature.Run( "JoobID:"& Last('Job Sheet').ID & ".png", JSON(Filter(SignatureList,FileContent in ID).FileContent)));
//Error
 
);
Thank you for your support. 
 
Thank You
Ananda
 
 
 
 
 
ReplyForward
 
 
 
 
 
 
 
 
 
3 REPLIES 3
v-siky-msft
Community Support
Community Support

Hi @ananda ,

 

Although it is not supported to define a variable in ForAll loop, you can collect data to collection, so use Collection to store and reference data. 

 

However, what is the error in your case? I have some confusion with your code:

1. What does the Filter code mean? What is SignatureList? Why does this mean that 'FileContent in ID'?

2. You miss the JSONFormat in JSON function, it should be: JSON("Your Data",JSONFormat.IncludeBinaryData)

 

Please share more information.

Sik

Managed to execute the code without error, data saved, but images are not visible. now it's formatting issue.

 

ForAll (JobSheeWCollection,
Patch ('Job Sheet', Defaults('Job Sheet'),{
Title: Customer,
Mobile: Mobile,
Email: Email,
Address: Address,
MachineModel: Model,
JobType: InsType,
CustomerRemark: CustRemark,
EngRemark: EngRemark,
SLNo: SLNo,
TempID: ID,
JobID: "JOB No : 0" & Last('Job Sheet').ID + 1 } );
CreateSignature.Run("JOB No : 0"&Last('Job Sheet').ID &".png", "JOB No : 0"& Last('Job Sheet').ID &".png",
Mid(JSON(Filter(SignatureList,JobId in ID).FileContent,JSONFormat.IncludeBinaryData),Find(",",JSON(Filter (SignatureList,JobId in ID).FileContent,JSONFormat.IncludeBinaryData))+1, Len(JSON(Filter(SignatureList,JobId in ID).FileContent,JSONFormat.IncludeBinaryData)) - Find(",",JSON(Filter(SignatureList,JobId in ID).FileContent,JSONFormat.IncludeBinaryData))-3) ));

Hi @ananda,

Please share the flow steps, and why you need to define the JSON like that?

Sik

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,235)