web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Add Delay to Formula o...
Power Apps
Answered

Add Delay to Formula or Update Gallery Before Running a Flow

(1) ShareShare
ReportReport
Posted on by 46

Hi

 

I have an app where users submit information and the app creates a PDF for the last record with that information. 

 

This is the code for the button that runs the mentioned above:

 

SubmitForm(Form1);

PenInput.Run( "Here I have HTML code to concatenate text with gally items", i.e:: &Concat(Gallery2.AllItems, ID) 
"and I have a PenInput to get a digital signature <img width='120px' src=" &JSON(PenInput1.Image, JSONFormat.IgnoreBinaryData) & ">
, "Ded"&Last(BD).Modified);
Reset(PenInput1);
NewForm(Form1)

 

The PenInput.Run is a flow that uses HTML and concatenate information from a Gallery to generate the PDF but I'm having issues with the pdf generated because is not using the information from the last record because the flow runs before the gallery updates, so the PDF is being generated with the information from the previous record submitted. 

 

I want to have all in the same button if it's possible. Is there a way to add a delay to the code between the SubmitForm and the flow that creates the PDF to give time to the gallery to update with the last record information? Or update the gallery immediately before running the flow to create the pdf?

 

Right now the only solution that worked in all the testing I've made is to have two buttons and run the submit separately from the flow but it's not he solution that I need.

 

Any idea is welcome.Thanks for your help.

Categories:
I have the same question (0)
  • iAm_ManCat Profile Picture
    18,228 Most Valuable Professional on at

    Hi,

     

    You should run the other parts of the code in the OnSuccess of the form - not only for the delay, but lets say someone manages to click submit when an item is not complete - in your case the rest of the code will run as its not dependant on whether or not the form succeeds, however putting it on the OnSuccess means it will only run if the form has completed submitting.

     

    So on the OnSuccess of your form, have the rest of your code:

     

    PenInput.Run( "Here I have HTML code to concatenate text with gally items", i.e:: &Concat(Gallery2.AllItems, ID) 
    "and I have a PenInput to get a digital signature <img width='120px' src=" &JSON(PenInput1.Image, JSONFormat.IgnoreBinaryData) & ">
    , "Ded"&Last(BD).Modified);
    Reset(PenInput1);
    NewForm(Form1)

     

     

  • sebastiandcarri Profile Picture
    46 on at

    Hi 

     

    Thanks for your reply. I tried to run it in OnTheSuccess but didn't work, I guess it doesn't give enough time to the gallery to update and take the information from the last record submitted. 

     

    I've been thinking maybe if it's possible to add some lines between SubmitForm and the flow to give time to the gallery to update, purpose for the lines is just stall the code to give time to the gallery to update and then run the flow, not sure if it's gonna work or what lines I can use to achieve it.

     

     

  • sebastiandcarri Profile Picture
    46 on at

    I tried to add delay to the code by using additional lines, I added 100 lines of Refresh to the button between the SubmiForm and the flow but didn't work, tried too adding the lines in OnTheSuccess event but didn't work.

  • Verified answer
    iAm_ManCat Profile Picture
    18,228 Most Valuable Professional on at

    You can reference the submitted item by using FormName.LastSubmit if you want to pass those details into the Flow instead of using the Gallery details, that way it doesn't have to wait for the gallery to update

  • sebastiandcarri Profile Picture
    46 on at

    Hi. Thanks, It worked, I just had to reference the fields in the HTML with LastSubmit solving the issue with the galley. Is there a way to give format to that LastSubmit field? For example I'm referencing a data field using FormName.LastSubmit.Modified but this field is in LongDateTime ( April 30 2021 4:00:00 PM) I want to change it just to April 30, but when I'm using Form1.LastSubmit(Modified,DateTimeFormat.LongDate) doesn't work.

  • sebastiandcarri Profile Picture
    46 on at

    I figure it out using Text with the LastSubmit to format it.

     

    Thanks again for your help @iAm_ManCat

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard