cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
quirkybird
Regular Visitor

Evaluate business rules via API (eg. for PCF controls)

Suggestion is to be able to retrieve & evaluate business rules for an entity (eg. via WebAPI) so the outcomes can be handled in a variety of contexts.

 

What prompted the thought is when developing a very complex PCF control for our specific use case, I found I had to replicate the logic which would show/hide/lock etc. fields. Instead it would be awesome to retrieve any (entity-scoped?) business rules for an entity through an API call, then for each one execute another API call which would evaluate the rule and return a list of outcomes (eg. [ { column: "pub_myattributename", action: "hide" }, { column: "pub_myotherattribute", action: "setValueToColumn", columnWithValue: "pub_someotherattribute" } ].

 

The PCF control could then handle these actions as desired, but it would be a simple matter to handle show/hide actions etc. This could probably be combined with PCF parameters to make some generic components which honoured business rules.

 

This evaluation of the rules would ideally be just an evaluation (eg. if a business rule would clear the value of a field, calling the API to evaluate the rule wouldn't clear the field again, but would report back to the user what action would be taken given the current record state/data.). Optionally the evaluation call might require the caller to provide an "event" eg. specify a field which has "changed". Optionally, the API call may in fact allow the rule to be executed and not just evaluated.

 

If it were implemented as an API, it would be extremely flexible and have many more applications - such as being able to call & respond to the rules via client Javascript, PowerFX, Plugins & Custom Workflow Activities, Canvas Apps, Power Automate etc. Consider that Actions, Power Automate flows and other components can be invoked in a similar way eg. by posting messages using the SDK or calling http endpoints.

 

This way, we would not only open many more exciting functional possibilities, but would also significantly reduce maintenance and bugs by centrally locating a lot of business logic.

2 REPLIES 2
cchannon
Super User
Super User

That seems pretty elaborate. Why not just have business rules that fire on change of the bound attribute for your PCF?

That would be a nice option as well.


Two reasons I took it further: 

 

1. If the PCF uses attributes that aren’t bound (eg. If the PCF attaches to a dataset but also pulls in & displays fields from related records to provide a better user experience).

 

2. The idea described above goes well beyond PCF controls… eg. Use the same principles and APIs on canvas apps, Powerapps Portals page forms and so on.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (2,422)