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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (59,297)