cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Daved1
Helper II
Helper II

trying to use If(true, then do this, else do this) does not work with Switch and Patch ?

I wanted to write the following code in the format If(true, then do this, else do this).  However this is not working (something to do with the Switch or the Patch ?).  Here is the only way i could get the code to work:

 

Switch(locbtnSubmit,
    "Submit",
          If(IsBlank(recRevDoc.SubmitComments),
               UpdateContext({locWarning:"Comments are required. Please update comments"})

           );

          If(!IsBlank(recRevDoc.SubmitComments),
          Patch(
               jctnReviewersDocRevs,
              LookUp(jctnReviewersDocRevs,new_jctnreviewersdocrevid = recRevDocRevsCurr.new_jctnreviewersdocrevid),
              {ReviewDateStart: Now()}
             )
         )
     ,

 

 

I tried the following and it works 

 

Switch(locbtnSubmit,
    "Submit",

          If(IsBlank(recRevDocRevsCurr.SubmitComments),
                 UpdateContext({locIssueDocWarning:"Comments are required. Please update comments"}),
                 UpdateContext({a:"a"})

          );

 

But for some reason this does not work as soon as I use the Patch command with the If...

 

Any idea what i am doing wrong

Regards

Dave

 

1 ACCEPTED SOLUTION

Accepted Solutions
Daved1
Helper II
Helper II

I am not sure what i did wrong, but got it to work

 

I had to write the If statement outside of the Switch, and got it to work.

 

THen I copied the code back into the Switch, and now it works.  

 

Not sure what happened. 

 

Dave

 

View solution in original post

1 REPLY 1
Daved1
Helper II
Helper II

I am not sure what i did wrong, but got it to work

 

I had to write the If statement outside of the Switch, and got it to work.

 

THen I copied the code back into the Switch, and now it works.  

 

Not sure what happened. 

 

Dave

 

View solution in original post

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (2,598)