Transcript:
0:00 complex rules are often required to be
0:02 executed as part of a canvas power app
0:04 and North52's business rules engine for
0:06 microsoft dynamics 365 and the power
0:08 platform is a perfect partner for this
0:11 scenario
0:12 in this video we'll show you how you can
0:14 calculate a heart disease risk score as
0:16 part of a canvas power app using the
0:18 following components a canvas power amp
0:21 a power automate flow a global action
0:24 and the North52 business rules engine
0:26 although the North52 solution is
0:28 installed in microsoft database we will
0:30 not be saving any data in dataverse as
0:32 part of the calculation this shows how
0:34 North52 can be used for stateless
0:36 processing
0:37 let's first see the canvas powerapp in
0:39 action and then review the components
0:41 we select options on the app and click
0:44 the calculate risk button the North52
0:46 business rules assess the information
0:48 and return results we can see that we
0:50 have a high risk for these specific risk
0:52 areas to make this work we first need to
0:55 create a global action which has two
0:56 parameters an input defined as payload
0:59 in risk parameters json and an output
1:02 defined as payload out risk results json
1:06 we then bind this action to a North52
1:08 formula and decision logic is based on
1:10 the information passed from the canvas
1:12 app the first decision sheet determines
1:15 whether there is a smoke risk based on
1:17 any of the three criteria being met
1:19 the values for these criteria are
1:21 extracted from the json data provided
1:24 from the canvas app we do this on the
1:26 global calculation sheet where values
1:28 from the payload in risk parameters json
1:30 input parameter are mapped so they can
1:32 be easily referenced in the decision
1:34 sheets first the payload in risk
1:37 parameters json input parameter is
1:39 assigned to the north52 internal
1:41 variable called response content
1:43 then the individual values are assigned
1:45 for example current smoker is assigned
1:48 on row 4. all these values are used on
1:50 the decision sheets to determine risk
1:52 for each category we won't dwell on the
1:54 individual logic for each sheet but
1:56 instead focus on the risk scoresheet
1:58 which determines the risk and associated
2:00 messages column j is an incremental
2:02 inline calculation which is adding a
2:05 value of 1 for each risk matched and
2:07 subtracting one in the case of the hdl
2:10 mitigating factor column k is an inline
2:12 calculation that calls a parameterized
2:15 North52 global action the cell k4 shows
2:19 the build json global action with the
2:21 first parameter having the text smoke
2:23 risk and the second parameter with the
2:25 text the patient has a smoke risk on the
2:28 global action sheet we can see the build
2:30 json action defined to append each
2:32 message to an array the risk type and
2:35 message properties being set by
2:37 information passed in the parameters
2:39 replacing the 0 and 1 within the curly
2:41 brackets an example of the output would
2:44 look like this
2:48 the final sheet in the formula provides
2:50 the response to the action's payload out
2:52 risk results json output parameter
2:55 if we expand cell a4 we can see the
2:57 construction of the json including the
2:59 risk messages jason created from the
3:01 global action an example of the output
3:04 would look like this
3:08 let's take a look at the power automate
3:10 flow which calls the global action and
3:12 receives the response from the formula
3:13 calculations it is relatively simple
3:16 with just three steps the first being
3:18 the trigger from power amps the second
3:21 step is perform an unbound action this
3:23 connects to our North52 demo underscore
3:26 heart disease risk action and assigns
3:28 the output from the canvas powerapp to
3:31 the payload in risk parameters json
3:33 input parameter the third step is the
3:35 response and we set the body to the
3:38 output from the previous step which is
3:39 the payload out risk results json you
3:42 can create the response body json schema
3:45 from sample.json this can be easily
3:47 obtained by running the flow and
3:49 analyzing the results
3:51 one final point to note is that you
3:53 should not use the respond to a power
3:55 wrap or flow step as this will return
3:57 json to the canvas power as a string and
4:00 cannot be added directly to a collection
4:02 within the canvas powerapp the next part
4:05 to look at is the canvas app and how the
4:07 calculation is called and the results
4:08 displayed there are two important parts
4:11 to review the onselect property of a
4:13 button to collect the values and submit
4:15 them to the power automate flow and the
4:17 data table which shows the messages that
4:18 have been returned as part of the json
4:20 response let's look at the detail of the
4:22 onselect property the values from many
4:25 input objects are collated in a
4:26 collection called formula data this
4:28 formula data collection is passed to the
4:30 power automate flow as json the flow
4:33 returns the results and adds this to
4:36 another collection called risk score
4:38 results and finally the property risk
4:40 score is obtained from the risk score
4:43 results collection
4:44 this data table is shown using the risk
4:47 messages property of the risk score
4:48 results collection it shows the risk
4:51 type and associated message for each
4:53 risk identified
4:55 if you'd like to know more please review
4:57 the associated article in our support
4:59 portal and get in touch to see how we
5:01 can help you with your complex business
5:02 rules requirements on the dynamics
5:04 platform
5:05 also please don't forget to subscribe to
5:07 our youtube channel
