cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Pinguito
Helper I
Helper I

Patch Function and Business Rules

Hi guys, i have one question about business rules on entities. I need to Patch some data using canvas app OnSelect property that have some required fields, but have a scenario when the user isn't need to populate this fields.

 

In my entity table I have this fields as required, so when the canvas try to Patch will appears required error message, okay ...

 

My question is: Can I create business rules to "When a field is set with 'Yes' option, the required field of the field is removed"?

 

I tried to do some like this but nothing changes in canvas app.

 

*Im using Defaults entity to Patch the data, if helps in something ...

1 ACCEPTED SOLUTION

Accepted Solutions
CNT
Super User
Super User

@Pinguito the answer is very simple. Business Rules are not supported in Canvas Apps. Recently I had a conversation about this with someone from MS who confirmed it. 

View solution in original post

5 REPLIES 5
CNT
Super User
Super User

@Pinguito the answer is very simple. Business Rules are not supported in Canvas Apps. Recently I had a conversation about this with someone from MS who confirmed it. 

Do you know other way? I didnt want make them optional 

nickellis74
Resolver II
Resolver II

I can't see a way around making it optional in the data source, then use fx formulas to control the behaviour in the app.

 

On the screen.onVisible put

Set(_Validated,true)

 

Do something with the border formatting of the text box like

// Black if validated, red if not
If(
   _Validated,
   RGBA(0,0,0,1),
   RGBA(255,0,0,1)
   )

 

On the 'submit' button put something like 

If(
   IsBlank(TextBox.Text) && (whatever your other requirement is),
   Set(_Validated,false);
   Notify("You have not completed the text box",Warning),
   Patch(Data Source, Defaults(Data Source), {table content})
   )

 

I have to say though, if it's a Yes/No field which is set to Yes, I don't see the value in making it non-mandatory. The Yes you've entered will meet the requirement. Unless you mean "field a is required unless field b is Yes"?

 

Nick

Hi @nickellis74 , thanks for your reply.

 

In canvas app its okay, I have made all necessary validated to make sure the data. I'm not worry about this.

 

My curious was about the back-end, if was possible to do something like this.

 

Thank very much (:

@Pinguito You can use Calculated and Rollup to do some server side logic. For example, you have a Date of Birth field and an Age field, you can calculate the Age based on the Date of Birth.

CNT_0-1622129763012.png

The other way to do validations within Canvas App Forms is to use the Valid function.

Also, you can use the Match function to validate the format of certain fields. For example you can check if the user has entered a valid email address etc.,

 

Hope this helps!

Helpful resources

Announcements
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.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (1,847)