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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Trigger a flow after s...
Power Apps
Unanswered

Trigger a flow after submitting a form only when Form Mode = New

(0) ShareShare
ReportReport
Posted on by 1,599 Super User 2024 Season 1

Hello,

 

I have a save button that is used for when the Form Mode is both in New or Edit.

sudosaurus_0-1717065226579.png

I have code set on this to run a workflow after the item is saved to SharePoint. However I only need the workflow to run if the Form Mode is 'New' and not if Form Mode is 'Edit'.

I have tried using the below code to get this working however I am seeing an error in the app:

sudosaurus_1-1717065369303.png

I can see that another parentheses is required but not sure where to put it - I'm not even sure if I've got the below right?

 

Would appreciate some help with this one.

SubmitForm(BuildingForm);

If(
 IsEmpty(Errors(DocData)),
 // ON SUCCESS
 Notify(
 "Success: Building item Saved/Updated",
 NotificationType.Success
 )
);

Set(varBuildingName, BuildingDD.Selected.Value);

UpdateContext({varCreateTopSubtop: true});

If(BuildingForm.Mode = FormMode.New; 'BSC-PowerApps-AutoCreateTopicsSubtopics'.Run(varBuildingName;)

 

Categories:
I have the same question (0)
  • anandm08 Profile Picture
    1,936 Super User 2024 Season 2 on at
    If(BuildingForm.Mode = FormMode.New; 'BSC-PowerApps-AutoCreateTopicsSubtopics'.Run(varBuildingName)

    try this

  • sudosaurus Profile Picture
    1,599 Super User 2024 Season 1 on at

    @anandm08 

    Tried this but seeing the below - we're still missing a closing parentheses from after the If.

    sudosaurus_0-1717066082400.png

     

  • anandm08 Profile Picture
    1,936 Super User 2024 Season 2 on at

    hi @sudosaurus ,

     

    If(BuildingForm.Mode = FormMode.New, 'BSC-PowerApps-AutoCreateTopicsSubtopics'.Run(varBuildingName))

     

    try this now

  • anandm08 Profile Picture
    1,936 Super User 2024 Season 2 on at

    sorry my bad 

    If(BuildingForm.Mode = FormMode.New, 'BSC-PowerApps-AutoCreateTopicsSubtopics'.Run(varBuildingName))

    try this code

  • sudosaurus Profile Picture
    1,599 Super User 2024 Season 1 on at

    @anandm08 I've kind of got it working to the extent that there are no longer any validation errors in the code.

     

    I have to make sure that when I save the form that the Form Mode is equal to New.

     

    On my "New" button I have used the following code:

    ResetForm(BuildingForm);NewForm(BuildingForm);Set(varGalDefault,Blank()); Set(varGalDefault,{});
    
    // Set the display mode of the form to new
    BuildingForm.Mode = FormMode.New;

    and then on the Save button I have used this:

    SubmitForm(BuildingForm);
    
    If(
     IsEmpty(Errors(DocData)),
     // ON SUCCESS
     Notify(
     "Success: Building item Saved/Updated",
     NotificationType.Success
     )
    );
    
    Set(varBuildingName, BuildingDD.Selected.Value);
    Set(varFlowComplete, topSubTopCompletion.Text);
    
    If(BuildingForm.Mode = FormMode.New, UpdateContext({varCreateTopSubtop: true}));
    
    If(
     BuildingForm.Mode = FormMode.New,
     Set(flowResponse, 'BSC-PowerApps-AutoCreateTopicsSubtopics'.Run(varBuildingName));
     topSubTopCompletion.Text = varFlowComplete;
     Refresh(TopicsClaims);
     Refresh(SubtopicArgEvi_1)
    )

    The problem is that when I hit Save, the form is saved to the SharePoint list however, the modal dialog I have which tells the user that Topics and Subtopics are being created is not displayed - so my theory is that the Form Mode isn't being set to 'New' when I initially open the form on pressing the New button.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 846

#2
Valantis Profile Picture

Valantis 532

#3
Haque Profile Picture

Haque 410

Last 30 days Overall leaderboard