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
Community Champion
Community Champion

@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
Community Champion
Community Champion

@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

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

nickellis74
Resolver I
Resolver I

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 (:

CNT
Community Champion
Community Champion

@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
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (2,063)