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
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Users online (2,441)