cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AkshayManke
Continued Contributor
Continued Contributor

Perform Multiple Actions Based on If Condition

Hi,

 

I am trying to build an app where i have added Approve button in the form screen. I have used patch function to update the field values as below. What is the condition is: If the Item is 'Complex' then do 1,2,3 actions else do 4,5,6. 

 

Set(
    VarIntake,
    If(
        DataCardValue73.Selected.Value = "Complex",
        Patch(
            'List Name',
            VarIntake,
            {
                Status: {Value: "Next Review"},
                IntakeReviewComment: intComments.Text
            }
        ),
        Patch(
            'List Name',
            VarIntake,
            {
                Status: {Value: "Approved"},
                IntakeReviewComment: intComments.Text
            }
        )
    )
)

 

I am able to perform the single action if a specific condition is true, however I want more 2 actions in each condition as below.

 

If( Type = "Complex",
           1. Patch {Staus: ABC},
           2. Send Email to Person A
           3. Send Email to Person B,
     Else,
           4. Patch {Status: EFG}
           5. Send Email to Person C
           6. Send Email to Person D
  ) 

I tried segregating the 1, 2, 3 using &&, ||, ;;, ;, but somehow getting error. Can anyone please help how to combine multiple actions in true and false conditions?

 

Thanks,

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Pstork1
Dual Super User
Dual Super User

I don't believe there is any way to embed multiple statements inside an If() statement.  The only way to do what you are asking is to have a set of If() statements with one for each set of actions.

If( Type = "Complex",
           1. Patch {Staus: ABC},
     Else,
           4. Patch {Status: EFG}
  ) ;
If( Type = "Complex",
           2. Send Email to Person A
     Else,
           5. Send Email to Person C
  ) ;
If( Type = "Complex",
            3. Send Email to Person B,
     Else,
            6. Send Email to Person D
  ) 
 
 


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Join me at 365EduCon in Chicago on Sept. 26-30 where I'll be presenting on the Power Platform!

View solution in original post

Hi @AkshayManke ,

below the Code For your requirement.

If(ThisItem.Complexity.Value="Simple",Patch( 
    TestAkshay,{
        ID:ThisItem.ID,
        Status:{
            Value:"Approved",
            '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"
        }
    }
);Office365Outlook.SendEmailV2(ThisItem.'Created By'.Email,"Your Request is Apptoved","Hi your request is approved",{Importance:"High"}),Patch( 
    TestAkshay,{
        ID:ThisItem.ID,
        Status:{
            Value:"Under Review",
            '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"
        }
    }
);Office365Outlook.SendEmailV2(ThisItem.'Created By'.Email,"Your Request is Under Review","Hi your request is approved",{Importance:"High"}))

 Thanks,
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

16 REPLIES 16
Pstork1
Dual Super User
Dual Super User

I don't believe there is any way to embed multiple statements inside an If() statement.  The only way to do what you are asking is to have a set of If() statements with one for each set of actions.

If( Type = "Complex",
           1. Patch {Staus: ABC},
     Else,
           4. Patch {Status: EFG}
  ) ;
If( Type = "Complex",
           2. Send Email to Person A
     Else,
           5. Send Email to Person C
  ) ;
If( Type = "Complex",
            3. Send Email to Person B,
     Else,
            6. Send Email to Person D
  ) 
 
 


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Join me at 365EduCon in Chicago on Sept. 26-30 where I'll be presenting on the Power Platform!
VijayTailor
Resident Rockstar
Resident Rockstar

Hi @AkshayManke ,

You can perform multiple actions

If(ThisItem.ID=1,UpdateContext({ValueNew:!ValueNew});Notify("Value is "&ValueNew,NotificationType.Success),Notify("Some Error",NotificationType.Error))

like below using if condition.

just Use ";" for Actions.

Thanks
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

AkshayManke
Continued Contributor
Continued Contributor

Hi Vijay, @VijayTailor,

 

I tried using the below but the formula is giving error. Can you please let me know where i am wrong?

IfMultiple.JPG

 

 

 

 

Regards,

Akshay

Please Remove "Big": and "Small":

your code work once you removed that
AkshayManke
Continued Contributor
Continued Contributor

But i need both the actions based on the condition. Fore clarity i have added the blow snap. In the input text field i need Big/Small to be written and also i need the notification in the screen, hence as suggested by you i have added a semicolon ";" after each action in true and false. Is this correct?

 

IfMultiple1.JPG

Hi @AkshayManke 

please have a look into the below URL, Hope that is fit for your requirement and resolve your issue
https://drive.google.com/file/d/1Oi9hnXS7h4Y2EVQZxuuyPiqlosyWV9-m/view

For reference also attached the App.
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

AkshayManke
Continued Contributor
Continued Contributor

Hi Vijay, @VijayTailor 

This is exactly what i want. But could you please share the code as well so that i can refer it?

Regards,

Already attached the Full App that I implemented for testing.

See the yellow highlighted.

VijayTailor_0-1601229180560.png

Thanks

AkshayManke
Continued Contributor
Continued Contributor

Sorry missed it. I downloaded the app and tried the formula it is working in your application however it is not working in my env. Don't know why. I tried with various combinations. Trying it again and will get back to you with the result shortly.

 

Thanks and Regards,

Akshay

 

 

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (3,096)