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 Automate / from two flows only on...
Power Automate
Suggested Answer

from two flows only one flow is executing

(2) ShareShare
ReportReport
Posted on by 26
in power apps on buttonselect, has to execute two flows, one is insert and second is update. insert flow is executing and update flow is skipping.
 
In power apps using tables from azure databricks. created flows using parse Json for insert and update.
 

Delete__DEP.Run(TextInput2_4.Text);
Refresh('TableDEP');
If(IsBlank(DatePicker4.SelectedDate) || IsBlank(TextInput15_5.Text), Notify("message ",NotificationType.Error),
If(CountRows(checkescdep) =0
,Notify("Please Select at least one Escalation Check Box",NotificationType.Warning),
With(
    {
        _sr_log_ref: TextInput2_4.Text,
        _datewithnsp: TextInput15_3.Text,
        _i
    },
    ForAll(
        checkescdep,
        Collect(
            colPayloadNSP,
            {
                so_item_impact: PartNumber,
                sales_order: OrderType,
                line_number: LineNumber,
                 sr_log_ref: _sr_log_ref,
                datewithnsp: _datewithnsp,
                
            }
        )
    )
);
Set(varNSPDEPflow,
   !IsError( ForAll(colPayloadNSP,INSERT.Run(JSON(ThisRecord,JSONFormat.IgnoreUnsupportedTypes)  ) ) ) );

Set(varNSPDEPupdate,If(varNSPDEPflow,!IsError(
Set(
    payloadupdate,
    {
            
        sr_log_ref: SelectedSR,
        detailed_comment: ip_SRDetails_Detailed_Comments.Text,
          nsp_closurecomments: TextInput9_8.Text 
    }
);
UPDATE.Run(JSON(payloadupdate, JSONFormat.IncludeBinaryData));
    ),false));
//Set(varNSPDEPupdate,If(varNSPDEPflow, !IsError(SR_UPDATE.Run(JSON(payloadupdate, JSONFormat.IgnoreUnsupportedTypes))),false));
If(varNSPDEPflow,  varNSPDEPupdate, Set(varShowPopupDEPES,true),
Notify("Flow Execution failed SR is not Escalated, Some field values are empty",NotificationType.Error)
)));
 
Clear(colpartdata);
Clear(checkescdep);

Set(varDEPSelectAll,false);

Reset(DatePicker4);
Reset(TextInput15_5);
 
 
given some field values only. insert part executing, update skipping.
I have the same question (0)
  • Suggested answer
    VASANTH KUMAR BALMADI Profile Picture
    322 on at

    Instead of chaining everything into one condition, separate the insert and update clearly.

    Run insert → then run update independently:

    ForAll(
        colPayloadNSP,
        INSERT.Run(JSON(ThisRecord, JSONFormat.IgnoreUnsupportedTypes))
    );
    Set(
        payloadupdate,
        {
            sr_log_ref: SelectedSR,
            detailed_comment: ip_SRDetails_Detailed_Comments.Text,
            nsp_closurecomments: TextInput9_8.Text 
        }
    );
    UPDATE.Run(JSON(payloadupdate, JSONFormat.IncludeBinaryData));
     
    This way you’re not depending on varNSPDEPflow to allow the update.
  • Suggested answer
    Valantis Profile Picture
    6,735 on at
     
    The problem is in how you are building the update payload inside !IsError(). You have Set(payloadupdate, {...}); UPDATE.Run(...) chained with a semicolon inside a single !IsError() call. Power Apps does not execute multiple statements inside a function argument like that reliably.
     
    Fix:
     
    move the Set(payloadupdate) out as a separate statement before the varNSPDEPupdate Set, like this:
    Set(varNSPDEPflow, !IsError(ForAll(colPayloadNSP, INSERT.Run(JSON(ThisRecord, JSONFormat.IgnoreUnsupportedTypes)))));
    Set(payloadupdate, {
        sr_log_ref: SelectedSR,
        detailed_comment: ip_SRDetails_Detailed_Comments.Text,
        nsp_closurecomments: TextInput9_8.Text
    });
    Set(varNSPDEPupdate,
        If(varNSPDEPflow,
            !IsError(UPDATE.Run(JSON(payloadupdate, JSONFormat.IncludeBinaryData))),
            false
        )
    );
    By separating Set(payloadupdate) into its own statement first, the variable is guaranteed to be populated before UPDATE.Run() is called.
     

     

    Best regards,

    Valantis

     

    ✅ If this helped solve your issue, please Accept as Solution so others can find it quickly.

    ❤️ If it didn’t fully solve it but was still useful, please click “Yes” on “Was this reply helpful?” or leave a Like :).

    🏷️ For follow-ups  @Valantis.

    📝 https://valantisond365.com/

    💼 LinkedIn

    ▶️ YouTube

  • Suggested answer
    Haque Profile Picture
    3,653 on at
     

    We can have a bit cleaner approach to address your code. The main part is separation of concern. Here are some tips you can follow:

    • Let's Analyse Compact code in ForAll: By using ForAll in a compact way, we have invited a possible failure - as we  have set varNSPDEPflow inside a ForAll, there is a hich chance if any insert fails, varNSPDEPflow becomes false, and the update flow is skipped. Let's make sure varNSPDEPflow correctly reflects the success of all insert calls.

    • Isolated call for Insert and Update: Separated the insert and update flow calls clearly with explicit success/failure checks.

    • Where simplicity is possible: Instead of nesting multiple Set inside the If condition for the update flow, separate the variable assignment and the flow call for clarity.

    • Handy debugging: Just for debugging purpose add Notify() calls after each flow call to confirm execution and success/failure. Once tested, you can remove Notify(). 

    Here is the cleaner approach, please make sure your  code resembles, this is just for smaple, don't copy paste, just justfiy and modify your code accordingly.

    // Delete existing data and refresh table
    Delete__DEP.Run(TextInput2_4.Text);
    Refresh('TableDEP');
    
    //--Validate required inputs
    If(
        IsBlank(DatePicker4.SelectedDate) || IsBlank(TextInput15_5.Text),
        Notify("Please fill in all required fields.", NotificationType.Error),
        
        If(
            CountRows(checkescdep) = 0,
            Notify("Please select at least one Escalation Check Box.", NotificationType.Warning),
            
            //--Prepare payload collection for insert
            With(
                {
                    _sr_log_ref: TextInput2_4.Text,
                    _datewithnsp: TextInput15_3.Text
                },
                Clear(colPayloadNSP);
                ForAll(
                    checkescdep,
                    Collect(
                        colPayloadNSP,
                        {
                            so_item_impact: PartNumber,
                            sales_order: OrderType,
                            line_number: LineNumber,
                            sr_log_ref: _sr_log_ref,
                            datewithnsp: _datewithnsp
                        }
                    )
                )
            );
            
            //--Run Insert flow for each payload item and check for errors
            Set(
                varNSPDEPflow,
                !IsError(
                    ForAll(
                        colPayloadNSP,
                        INSERT.Run(JSON(ThisRecord, JSONFormat.IgnoreUnsupportedTypes))
                    )
                )
            );
            
            Notify(
                If(varNSPDEPflow, "Insert flow executed successfully.", "Insert flow failed."),
                If(varNSPDEPflow, NotificationType.Success, NotificationType.Error)
            );
            
            //--If insert succeeded, prepare and run update flow
            If(
                varNSPDEPflow,
                Set(
                    payloadupdate,
                    {
                        sr_log_ref: SelectedSR,
                        detailed_comment: ip_SRDetails_Detailed_Comments.Text,
                        nsp_closurecomments: TextInput9_8.Text
                    }
                );
                
                Set(
                    varNSPDEPupdate,
                    !IsError(
                        UPDATE.Run(JSON(payloadupdate, JSONFormat.IncludeBinaryData))
                    )
                );
                
                Notify(
                    If(varNSPDEPupdate, "Update flow executed successfully.", "Update flow failed."),
                    If(varNSPDEPupdate, NotificationType.Success, NotificationType.Error)
                );
            );
            
            //---Show popup or error notification if insert or update failed
            If(
                !varNSPDEPflow || !varNSPDEPupdate,
                Set(varShowPopupDEPES, true);
                Notify("Flow execution failed. Some field values may be empty or incorrect.", NotificationType.Error)
            );
            
            //--Clear collections and reset controls
            Clear(colpartdata);
            Clear(checkescdep);
            Set(varDEPSelectAll, false);
            Reset(DatePicker4);
            Reset(TextInput15_5);
        )
    );
    
     

    I am sure some clues I tried to give. If these clues help to resolve the issue brought you by here, please don't forget to check the box Does this answer your question? At the same time, I am pretty sure you have liked the response!
  • Valantis Profile Picture
    6,735 on at

    Hi @sridharbabuk,

    Just wanted to check in and see if everything is working now. If you still need any help, feel free to let me know.

    Also, if the issue is resolved, it would be great if you could mark the answer as solved so others with the same question can find it easily.

     

    Thanks and have a great day!

     

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 377

#2
11manish Profile Picture

11manish 279

#3
David_MA Profile Picture

David_MA 234 Super User 2026 Season 1

Last 30 days Overall leaderboard