A Place for Sharing and Inspiration

Total Pageviews

Wednesday, September 29, 2021

Tip - How to set up a Condition in Power Automate flow to check if "the field is empty"


Scenario:

sometimes, we have to check if the field contain data or is empty under the Condition action in a Power Automate flow, and we may be confused about which expression should be used to set up the condition.

image-20210929204201649

Reference material from Microsoft

If you use logical functions or conditions to compare values, null values are converted to empty string ("") values. The behavior of conditions differs when you compare with an empty string instead of a null value. For more information, see the string() function.

Refer to below link for more details from Microsoft:

https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#logical-comparison-functions

"empty" function

Check whether a collection is empty. Return true when the collection is empty, or return false when not empty.

Copy

empty('<collection>')empty([<collection>])
ParameterRequiredTypeDescription
<collection>YesString, Array, or ObjectThe collection to check
Return valueTypeDescription
true or falseBooleanReturn true when the collection is empty. Return false when not empty.

Example

These examples check whether the specified collections are empty:

Copy

empty('')empty('abc')

And returns these results:

  • First example: Passes an empty string, so the function returns true.
  • Second example: Passes the string "abc", so the function returns false.

Refer to below link for more details from Microsoft:

https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#empty

On the left side of the condition

"empty" function

empty([DynamicValue])e.g. empty(triggerOutputs()?['body/address1_city'])

but please note that the type of DynamicValue should be String, Array, or Object only (most of time, it will be a string type), otherwise, you will see an error, for instance, if we try to use a option set (choice) field in the Empty function indicated below, then we will see below error message during the run.

e.g.empty(triggerOutputs()?['body/preferredcontactmethodcode'])

image-20210929205305113

image-20210929211239611

image-20210929205614055

"length" function

length([DynamicValue])e.g.length(outputs('retrieve_option')?['body/methodToUpdate'])

but please note that the type of DynamicValue should be String, Array only. for instance, you can use it to check the length of an array in order to verify if the file or option exists. If it’s greater than 0, the array is not empty. If it’s 0, then it’s empty.

image-20210929211306283

On the right side of the condition

If you intend to check if a field is empty or not (on the right side of the condition) , and then do something. there are also couple of ways you can refer to.

null keyword

Just open the expression builder as below pic shown, and enter null, then you will see below predefined value “null” show up, after that, you can just click on Update to add it in the condition on the right side for comparison.

image-20210929212043686

empty string ("") value

if you‘re sure that the data type of the field you’re using on the left side of the condition is a string, then you can just put empty string on the right side for comparison.

image-20210929213239343

Monday, September 27, 2021

Tip - a quicker to find out the logic name of field on a form in Dynamics 365


Scenario:

Sometimes if we look for the logic name of a certain field on a form, we will have to go to advanced setting -> default solution or a certain solution that you already know -> find the entity (table) -> find the field and the corresponding logic name, which is a bit time consuming.

image-20210927131126494

Workaround:

there is actually another quicker way to find out the logic name for the field on the form using the Developer Tool from the browser (Chrome, Edge, etc.). Below is an example from the Chrome Browser.

image-20210927132222572

once you click on to open the Developer Tool, you will see below side pane, where you can click on that same arrow (indicated in #1), after that you will be able to hover over to whatever field on the form that you’re looking for for the logic name, then the corresponding logic name will show up (indicated in #2 with the underscore).

image-20210927125811468

Thursday, September 23, 2021

Use "Wait Condition" to delay workflow


Add Execution Time field to the form for comparison

the workflow called Contact: test workflow is created as below snap shot shown

image-20210922210405437

then, click on Set Properties to assign a dynamics value {Execution Time(Process)} to the newly added field called Execution Time for testing purpose. in order to compare with the timestamp when the contact record is created, I also add Created On field on the Contact form.

image-20210922210559499

Execution Time in workflow

Step #1 Update the workflow by adding below condition to the flow:

If Contact:Created On on or after [ 5 Minutes Before Process-Execution Time], then:

​ Update the Job Title field on the contact record as Iron Man

image-20210923220008096

Once completing the set up, you can save and activate the workflow.

Step #2 create a new contact record

Go back to the unified interface and navigate to the Contact entity, and create a new contact record and save it. 1 min After the contact record is created, the workflow is triggered.

image-20210923215434817

Step #3 check the Process session history of the workflow

Below graph will give you some rough idea about how the execution time works.

image-20210923230630891

that’s the reason why the workflow is triggered and completed at the same time (sometimes, the workflow may be postponed based on the availability of the server resources).

image-20210923215548415

Timeout in workflow

Local Values: Process -> Timeout -> Equals -> {3 Minutes After Created On} -> Save and Close

You can replicate Dynamics 365 Workflow Timeout wait condition in Power Automate flow as well.

Step #1 Configure the Wait Condition step using Timeout

Updating the existing workflow by adding the Wait Condition step to this flow

image-20210922211423223

then click on (click to configure) to open a new page where we can select Local Values Process -> Timeout -> Equals -> {3 Minutes After Created On} -> Save and Close

image-20210922211249031

There are at least three ways to configure timeout:

  1. Wait for a specific amount of time

image

  1. Wait until a specific date

image

  1. Wait for a specific amount of time based on an existing date/time field

image-20210922211953428

in order to validate the wait condition configuration, one more Update Record step is also added to the flow, then assign a static value called "Super man" to Job Title field for verification.

image-20210922213346638

Step #2 Testing & Validation

Create a new contact record, as we can see below in red rectangle, there is one minute delay (or may be even longer delay based on the availability of server resources) between Created on and Execution Time, because the workflow that is used to update the Execution Time field is a background workflow rather than real-time one.

image-20210922220942102

when the contact is created, the workflow is triggered at the same time as well. then the workflow has to wait for 3min, and after 3min, the Job Title field will be updated.

image-20210922221057789

image-20210922221120136

While the ‘Wait conditions’ are useful in case of the timer related tasks which will be achieved with no coding, excessive use of wait conditions has a downside.

  • Performance:
    • Each waiting workflow instance carries performance overhead. The more waiting workflow you have, the more server resources will be consumed by the Asynchronous Processing Service.
    • If you change the logic in your workflow and republish (like update the text of the email sent to your client), it does not change waiting workflow instances. For example, if you change the renewal email frequency to 15 days rather than 30 days, any workflow instances that are waiting will not be updated.

Activity Count & Activity Count Including Process

When designing workflows, it is possible to test the number of activities (open and closed) against a record (only activities that are regarding the record directly are counted).

The count is available under the Local Value – Process.

There are two activity counts – Activity Count and Activity Count Including Process.

  • Activity Count is a count of all activities (open and closed) excluding ones created by any workflow.

  • Activity Count including Workflow is a count of all activities (open and closed) regardless of how they were created.

It seems that the values for the activity counts are evaluated when the workflow starts or is paused and resumed or at the end of a wait. So a step like this to get a workflow to do something when an activity is added to a record does not work:

Wait until Process-Activity Count > some integer (or field with an integer)

However, if there is a parallel wait such as

Timeout until 4 hours

The wait branch with the activity count is re-evaluated and if the test on activity count is true the workflow follows that path rather than the timeout path. Most frustrating.

How to customize the case resolution dialog


Customizing the case resolution dialog to suit the business needs, such as, adding fields like Resolution type, or removing fields like Remarks, if they don’t apply to your business scenarios. You can also create case resolution rules by adding custom status values. The following sections discuss the permissions you’ll need to modify the case resolution dialog and how to enable the option to customize dialogs in Customer Service Hub. You’ll also learn to customize the case resolution dialog and add custom case resolution rules using examples.

image-20210918205404889

Note

The option to customize the case resolution dialog is also available in Dynamics 365 Customer Engagement (on-premises) 9.1. More information: New features in Dynamics 365 Customer Engagement (on-premises)

Check permissions

Make sure that the CSR Manager and Customer Service Representative security roles have the following permissions set for Environment Variable Definition:

  • Customer Service Manager: Create, Read, and Write
  • Customer Service Representative: Read

image-20210918203827167

image-20210918203842936

Note

If you’ve created custom security roles, you’ll need to update the roles before you can use the modified case resolution dialog.

Customize dialogs

By default, the style of the Resolve case dialog is set to standard dialog. You can, however, change the style to Customizable dialog so that you can add custom fields and values.

To enable the Customizable dialog option

  1. In Customer Service Hub, go to Service Management.
  2. In the site map under Service Terms, select Service Configuration Settings.
  3. In the Resolve case dialog section, select Customizable dialog from the dropdown list.
  4. Select Save.

image-20210918204016941

Note: there are actually two form types available (quick create and standard dialog). please note that you must choose which dialog you’d like to use first from the dropdown list, and save it; after that, you can change it to Customizable dialog. for example, if you try to customize the standard dialog, you must choose Standard dialog and save the change first, then change it to Customizable dialog, and save it again.

Note: at this moment, case resolution dialog can only be configured under the new interface. the classic(legacy) interface doesn’t support the modification of the case resolution dialog yet.

image-20210918204242562

Add or remove fields from the case resolution dialog

You can modify the case resolution dialog and remove a field under the new unified interface rather than the classic interface, so that it no longer appears at runtime for the user.

As an example, let’s see how to remove the Remarks field from the Information form.

  1. In Power Apps under the correct environment, navigate to and open the default solution, and search for Case Resolution table, and then select Forms.
  2. Open the form you want to edit. For this example, let’s select the Information form. The form opens in the form designer.
  3. In the form designer, do the following:
    1. Select Remarks.
    2. On the command bar, click on that Delete icon.
  4. Select Save, and then select Publish.

image-20210918205735480

When the CSR manager or customer service representatives try to resolve a case, the case resolution dialog won’t display the field that you deleted. the dialog will look like below snap shot now.

image-20210918210433564

Tip-How does Case Resolution Dialog interact with the Case record and the Business Process flow


The Fact

When resolving a case record, the user will normally click on the "Resolve Case" button on the ribbon, which will trigger the Case Resolution Dialog box to open.

image-20210923162001625

image-20210923160659531

After capturing the additional details and resolving the case (by clicking on Save & Close) from the Case Resolution Dialog, the case will show up like below screen shot.

The Case record has been marked as:

  1. Status: resolved
  2. Status reason: problem solved

The Business Process flow entity called Test BPF for case has been marked as:

  1. Status: inactive
  2. Status reason: aborted

image-20210923161047436

Question

Users also try to use the workflow to move the stage of the Business Process flow back and forth automatically through the classic workflow right after clicking on that "Resolve Case" button on the ribbon. is it possible?

so just for testing purpose, a workflow called "Resolve case Auto BPF stage movement" is created as below snap shot shown for the Business Process flow entity called "Test BPF for case".

image-20210923154613657

then we need to click on that View item beside Process changes to configure the trigger. If the Status Reason under the related Case record is changed or updated, the workflow will be triggered (refer to below screen shot).

image-20210923163104390

the condition is set up as below screen shot shown.

image-20210923155402104

then, after we click on the "Resolve Case" button on the ribbon, then the case will be resolved and the Status reason of the case will be changed to Problem Solved, meanwhile, this workflow will be triggered as well. after that, we will see Message "Invalid stage transition. Stage transition is not allowed on inactive processes." , and the result should be like below screen shot shown, which means the Business Process flow record was marked as inactive at the same time, when the case record was resolved via Case Resolution Dialog. after that, when the workflow is triggered and try to update the business process flow record again, it will fail.

image-20210923165837531

Another scenario

Resolve case via 1st workflow + update the stage of BPF via 2nd workflow

If we use a workflow to resolve the case, then we will be able to use another workflow to move the stage of the BPF record back and forth, which means resolving the case through workflow is totally different from clicking on that "Resolve Case" button on the ribbon

below is an example for resolving the case through workflow.

image-20210923195139890

then, you will be able to use the existing workflow Resolve case Auto BPF stage movement to automatically update the stage of a Business Process Flow.

Saturday, September 18, 2021

How to customize the case resolution dialog


Customizing the case resolution dialog to suit the business needs, such as, adding fields like Resolution type, or removing fields like Remarks, if they don’t apply to your business scenarios. You can also create case resolution rules by adding custom status values. The following sections discuss the permissions you’ll need to modify the case resolution dialog and how to enable the option to customize dialogs in Customer Service Hub. You’ll also learn to customize the case resolution dialog and add custom case resolution rules using examples.

image-20210918205404889

Note

The option to customize the case resolution dialog is also available in Dynamics 365 Customer Engagement (on-premises) 9.1. More information: New features in Dynamics 365 Customer Engagement (on-premises)

Check permissions

Make sure that the CSR Manager and Customer Service Representative security roles have the following permissions set for Environment Variable Definition:

  • Customer Service Manager: Create, Read, and Write
  • Customer Service Representative: Read

image-20210918203827167

image-20210918203842936

Note

If you’ve created custom security roles, you’ll need to update the roles before you can use the modified case resolution dialog.

Customize dialogs

By default, the style of the Resolve case dialog is set to standard dialog. You can, however, change the style to Customizable dialog so that you can add custom fields and values.

To enable the Customizable dialog option

  1. In Customer Service Hub, go to Service Management.
  2. In the site map under Service Terms, select Service Configuration Settings.
  3. In the Resolve case dialog section, select Customizable dialog from the dropdown list.
  4. Select Save.

image-20210918204016941

Note: there are actually two form types available (quick create and standard dialog). please note that you must choose which dialog you’d like to use first from the dropdown list, and save it; after that, you can change it to Customizable dialog. for example, if you try to customize the standard dialog, you must choose Standard dialog and save the change first, then change it to Customizable dialog, and save it again.

Note: at this moment, case resolution dialog can only be configured under the new interface. the classic(legacy) interface doesn’t support the modification of the case resolution dialog yet.

image-20210918204242562

Add or remove fields from the case resolution dialog

You can modify the case resolution dialog and remove a field under the new unified interface rather than the classic interface, so that it no longer appears at runtime for the user.

As an example, let’s see how to remove the Remarks field from the Information form.

  1. In Power Apps under the correct environment, navigate to and open the default solution, and search for Case Resolution table, and then select Forms.
  2. Open the form you want to edit. For this example, let’s select the Information form. The form opens in the form designer.
  3. In the form designer, do the following:
    1. Select Remarks.
    2. On the command bar, click on that Delete icon.
  4. Select Save, and then select Publish.

image-20210918205735480

When the CSR manager or customer service representatives try to resolve a case, the case resolution dialog won’t display the field that you deleted. the dialog will look like below snap shot now.

image-20210918210433564

Tip - Business Process flow does not appear in the unified interface


Scenario:

A new Business Process flow called "Test BPF for case" is just created on Case entity, however, we cannot find it from Unified Interface. we can only find Phone to Case process BPF now.

image-20210918152848069

Solution #1:

Go to Advanced Settings -> Security -> Security Roles, then find and open the security role that was assigned to the user who should see the BPF in unified interface, for instance, Customer Service Representative role was assigned to the user, and we just find and open this role, then follow below steps,

  1. Open Customer Service Representative role, then you will see below page
  2. Go to Business Process Flows tab
  3. Find the entity that was automatically created for the BPF you’re working on, and make sure you will select and grant the appropriate privileges to the user
  4. Save and Close this page

image-20210918153038650

Solution #2:

In Power Apps, select the correct environment you’re working with, then navigate to Apps on the left hand side, and click on existing app (Where you couldn’t see BPF)

image-20210918154214729

Open in App Designer.

  1. Select Business Process Flows component from designer.
  2. Select the required BPF from list of BPF’s those displayed right side.
  3. Save and Publish

image-20210918154628871

Now, you can go back to the unified interface. After you refresh the form, the BPF should be visible now.

image-20210918155237676