Difference between revisions of "Power Automate"

From Resco's Wiki
Jump to: navigation, search
(Resco Cloud connector)
 
(17 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Beta}}{{Integration TOC}}
+
{{Integration TOC}}
'''[https://docs.microsoft.com/en-us/power-automate/ Power Automate]''' is a Microsoft service that helps you create automated workflows between your favorite apps and services to synchronize files, get notifications, collect data, and more. Power Automate can be used to connect a [[Resco Cloud]] organization with other CRM/ERP backend systems, such as Microsoft Dynamics 365 Business Central.
+
'''[https://docs.microsoft.com/en-us/power-automate/ Power Automate]''' is a Microsoft service that helps you create automated workflows between your favorite apps and services to synchronize files, get notifications, collect data, and more. Power Automate can be used to connect a [[Resco Cloud]] organization with other CRM/ERP backend systems, such as Microsoft Dynamics 365 [[Business Central]].
 +
 
 +
== Getting started ==
 +
 
 +
{{YT|ze-ZjnFRhDM}}
  
 
== Benefits ==
 
== Benefits ==
  
 
* Connecting backends is often a complex and time-consuming endeavor. Use Microsoft-standardized integration to save time and money.
 
* Connecting backends is often a complex and time-consuming endeavor. Use Microsoft-standardized integration to save time and money.
 
 
* Automating the communication can extend Resco Cloud benefits to the users of other backends, for example, offline mobility or some field service functions.
 
* Automating the communication can extend Resco Cloud benefits to the users of other backends, for example, offline mobility or some field service functions.
  
Line 13: Line 16:
  
 
The Microsoft-certified '''Resco Cloud connector''' exposes a couple of operations that allow you to seamlessly create, read, update, and delete records.
 
The Microsoft-certified '''Resco Cloud connector''' exposes a couple of operations that allow you to seamlessly create, read, update, and delete records.
 +
 +
[[File:Resco Cloud connector.png]]
  
 
=== Prerequisites ===
 
=== Prerequisites ===
In order to use this connector, you will need the following:
+
 
 +
To use this connector, you need:
 
* An organization at [[Resco Cloud]] or any affiliate product from [https://www.resco.net/ Resco website].
 
* An organization at [[Resco Cloud]] or any affiliate product from [https://www.resco.net/ Resco website].
* You can sign up for a [https://www.resco.net/request-a-trial/ free trial].
+
** You can sign up for a [https://www.resco.net/request-a-trial/ free trial].
 
* An user account with schema access privilege or system administrator privilege.
 
* An user account with schema access privilege or system administrator privilege.
  
Line 24: Line 30:
 
This connector uses Basic authentication. When creating a new connector (in Power Apps/Logic Apps), you must provide login credentials. You must also select a server to use with this connector and the organization name you specified during sign-up.
 
This connector uses Basic authentication. When creating a new connector (in Power Apps/Logic Apps), you must provide login credentials. You must also select a server to use with this connector and the organization name you specified during sign-up.
  
=== Supported operations ===
+
=== Getting started ===
This connector supports the following operations:
+
 
 +
Simply add any Resco Cloud connector step to your flow and start accessing/changing data in your Resco Cloud organization. This connector allows you to perform basic data operations:
 
* List records: Get a list of records.
 
* List records: Get a list of records.
 
* Get record: Get record with a specific ID.
 
* Get record: Get record with a specific ID.
Line 33: Line 40:
 
* Get current user: Get the current user record associated with login credentials.
 
* Get current user: Get the current user record associated with login credentials.
  
== Creating a sample flow using the connector ==  
+
=== Known issues ===
 +
 
 +
==== Paging ====
 +
 
 +
The ''List records'' action returns a maximum of 1000 records. If you would like to get more records, you have to use the ''Skip token'' input parameter. The ''Skip token'' is not returned directly, but instead ''Next Link'' is returned which contains ''Skip token'' also.
 +
 
 +
To resolve ''Skip token'' for the next ''List records'' action call, you can use the expression in the ''Set variable'' step like:
 +
 
 +
<syntaxhighlight lang="json">
 +
{
 +
    "inputs": {
 +
        "name": "skipToken",
 +
        "value": "@{if(empty(outputs('List_records')?['body/@odata.nextLink']),null,decodeUriComponent(substring(outputs('List_records')?['body/@odata.nextLink'],add(indexOf(outputs('List_records')?['body/@odata.nextLink'], '$skipToken='),11))))}"
 +
    }
 +
}
 +
</syntaxhighlight>
 +
 
 +
==== Triggers ====
 +
 
 +
For now, the connector does not support triggers. However, there is a workaround available using the server process event and invoking an HTTP request provided by "When an HTTP request is received". Simply create a new automated cloud flow, name it, and click skip to create an empty flow. Search for "Request" connector and add the "When an HTTP request is received" trigger. Set "Request Body JSON Schema" to accept the ''id'' parameter:
 +
 
 +
<syntaxhighlight lang="json">
 +
{
 +
    "type": "object",
 +
    "properties": {
 +
        "id": {
 +
            "type": "string"
 +
        }
 +
    }
 +
}
 +
</syntaxhighlight>
 +
 
 +
Under '''Show Advanced Options''' set method to '''POST'''. Save the flow to generate "HTTP POST URL".
 +
 
 +
[[File:Pa-flow.png|600px]]
 +
 
 +
Now you have to create a process to invoke trigger in your flow.
 +
# Log into your [[Resco Cloud]] server, start the [[Admin Console]], and select '''Processes''' from the menu.
 +
# Click '''New''', enter a name for the new process, select the desired entity (e.g., Account), and the desired event (e.g., Record is created).
 +
# Add StringList variable '''headers''' and add item <code>Content-Type: application/json;charset=utf-8</code> to it.
 +
# Add string variable '''body''' as "Format Text" with: <code>\{ "id": "{Entity.id}" \}</code>.
 +
# Then, add the function step `Server.InvokeWebRequest` with `POST` method. URL copied from "When an HTTP request is received" trigger and body variable.
 +
 
 +
[[File:Resco-process.png|600px]]
 +
 
 +
Now, when you create a record of the specified entity type, the trigger activates.
 +
 
 +
=== Common errors and remedies ===
 +
 
 +
* For cloud servers, make sure that you have specified the proper server under the Connection dialog. If not, you may get an Unauthorized error.
 +
* For custom or on-premise servers, enter the URL including protocol and port (if applicable), e.g., <code><nowiki>https://mycompany.com[:8080]</nowiki></code>.
 +
 
 +
=== FAQ ===
 +
 
 +
; How to use ''List records'' input parameters?
 +
: These are standard OData query parameters. The syntax for each input parameter is defined by OData specification.  The only thing to think of is using logical names instead of display names. (e.g. Account -> account, Name -> name, etc.). Logical names can be found under Entities in the Admin Console.
  
TBD
+
; How do I get a picklist label?
 +
: Each picklist field returns 2 values:
 +
:* '''Field''' - This is the picklist value
 +
:* '''Field (Label)''' - This is the label for the picklist value.
  
== Building custom connectors ==
+
; How do I get a lookup label?
 +
: Each lookup field returns 3 values:
 +
:* '''Field''' - This is the ID (GUID) of the reference
 +
:* '''Field (Label)''' - This is the label (primary name) of the reference.
 +
:* '''Field (Type)''' - This is the target entity of the reference.
 +
 
 +
; How do I set a lookup field?
 +
: When setting lookup fields, you have to construct a reference consisting of record type and record id.
 +
:* From existing record in your flow, you can use '''OData Id'''
 +
:* By creating '''logicalName:id''' expression
 +
:* By creating '''logicalName('id')''' expression
 +
 
 +
<!-- == Creating a sample flow using the connector ==
 +
 
 +
In the following example, we are creating an instant flow that retrieves some records from Resco Cloud and saves them to Common Data Service.
 +
 
 +
# Select '''Create''' from the menu, then select '''Instant cloud flow'''.
 +
# Enter a flow name and choose how the flow should be triggered.<br>[[File:Create sample flow.png|600px]]
 +
# Click '''New step'''.<br>[[File:Manually trigger a flow.png|600px]]
 +
# Search for 'resco' and select '''Resco Cloud''' connector.<br>[[File:Select resco cloud connector.png]]
 +
# Select an action for the connector, for example, '''Get record'''.
 +
# Connect to your Resco Cloud, Resco Inspections, or Resco Routes organization.<br>[[File:Connect to resco cloud.png]]
 +
# TBD.
 +
-->
 +
 
 +
<!-- == Building custom connectors ==
  
 
Resco has prepared OpenAPI definition files that can be used by Power Automate to create a custom connector for interfacing with Resco Cloud. Both YAML and JSON formats are available. When using an OpenAPI definition to describe a custom connector in Power Automate, [https://docs.microsoft.com/en-us/connectors/custom-connectors/faq#limits the file must be less than 1 MB]. Therefore, the API definition only includes selected entities by default. Contact [https://www.resco.net/contact-support/ Resco support] for more information.
 
Resco has prepared OpenAPI definition files that can be used by Power Automate to create a custom connector for interfacing with Resco Cloud. Both YAML and JSON formats are available. When using an OpenAPI definition to describe a custom connector in Power Automate, [https://docs.microsoft.com/en-us/connectors/custom-connectors/faq#limits the file must be less than 1 MB]. Therefore, the API definition only includes selected entities by default. Contact [https://www.resco.net/contact-support/ Resco support] for more information.
Line 43: Line 133:
 
{{Note|The API definition files can be also utilized by other tools and services compatible with the OpenAPI standard, not only Power Automate.|Tip}}
 
{{Note|The API definition files can be also utilized by other tools and services compatible with the OpenAPI standard, not only Power Automate.|Tip}}
  
'''(Coming soon)''': You can also generate your own OpenAPI file with entities necessary for your particular use case. In the [[Admin Console]], select TBD from the menu; then select the entities (fields?) that you need.
+
'''(Coming soon)''': You can also generate your own OpenAPI file with entities necessary for your particular use case. In the [[Admin Console]], select TBD from the menu; then select the entities (fields?) that you need.
 +
 
 +
-->
 +
 
 +
== See also ==
 +
 
 +
* [https://www.resco.net/news/resco-launches-integration-with-microsoft-dynamics-365-business-central/ Resco launches integration with Microsoft Dynamics 365 Business Central]
 +
* [https://www.resco.net/blog/faq-integrating-resco-with-dynamics-business-central-power-automate/ FAQ: Integrating Resco with Dynamics 365 Business Central via Power Automate] {{Badge|Blog}}
 +
* [https://docs.microsoft.com/en-us/connectors/rescocloud/ Resco Cloud connector documentation at docs.microsoft.com]
  
 
[[Category:Resco Cloud]]
 
[[Category:Resco Cloud]]

Latest revision as of 10:17, 2 June 2021

Integration with third-party systems

Resco CRM Connector (web APIs):




Power Automate is a Microsoft service that helps you create automated workflows between your favorite apps and services to synchronize files, get notifications, collect data, and more. Power Automate can be used to connect a Resco Cloud organization with other CRM/ERP backend systems, such as Microsoft Dynamics 365 Business Central.

Getting started

Benefits

  • Connecting backends is often a complex and time-consuming endeavor. Use Microsoft-standardized integration to save time and money.
  • Automating the communication can extend Resco Cloud benefits to the users of other backends, for example, offline mobility or some field service functions.
One of the possible usage scenarios


Resco Cloud connector

The Microsoft-certified Resco Cloud connector exposes a couple of operations that allow you to seamlessly create, read, update, and delete records.

Resco Cloud connector.png

Prerequisites

To use this connector, you need:

  • An organization at Resco Cloud or any affiliate product from Resco website.
  • An user account with schema access privilege or system administrator privilege.

Authentication

This connector uses Basic authentication. When creating a new connector (in Power Apps/Logic Apps), you must provide login credentials. You must also select a server to use with this connector and the organization name you specified during sign-up.

Getting started

Simply add any Resco Cloud connector step to your flow and start accessing/changing data in your Resco Cloud organization. This connector allows you to perform basic data operations:

  • List records: Get a list of records.
  • Get record: Get record with a specific ID.
  • Create a new record: Create a new record.
  • Delete record: Delete record with a specific ID.
  • Update record: Update record with a specific ID.
  • Get current user: Get the current user record associated with login credentials.

Known issues

Paging

The List records action returns a maximum of 1000 records. If you would like to get more records, you have to use the Skip token input parameter. The Skip token is not returned directly, but instead Next Link is returned which contains Skip token also.

To resolve Skip token for the next List records action call, you can use the expression in the Set variable step like:

{
    "inputs": {
        "name": "skipToken",
        "value": "@{if(empty(outputs('List_records')?['body/@odata.nextLink']),null,decodeUriComponent(substring(outputs('List_records')?['body/@odata.nextLink'],add(indexOf(outputs('List_records')?['body/@odata.nextLink'], '$skipToken='),11))))}"
    }
}

Triggers

For now, the connector does not support triggers. However, there is a workaround available using the server process event and invoking an HTTP request provided by "When an HTTP request is received". Simply create a new automated cloud flow, name it, and click skip to create an empty flow. Search for "Request" connector and add the "When an HTTP request is received" trigger. Set "Request Body JSON Schema" to accept the id parameter:

{
    "type": "object",
    "properties": {
        "id": {
            "type": "string"
        }
    }
}

Under Show Advanced Options set method to POST. Save the flow to generate "HTTP POST URL".

Pa-flow.png

Now you have to create a process to invoke trigger in your flow.

  1. Log into your Resco Cloud server, start the Admin Console, and select Processes from the menu.
  2. Click New, enter a name for the new process, select the desired entity (e.g., Account), and the desired event (e.g., Record is created).
  3. Add StringList variable headers and add item Content-Type: application/json;charset=utf-8 to it.
  4. Add string variable body as "Format Text" with: \{ "id": "{Entity.id}" \}.
  5. Then, add the function step `Server.InvokeWebRequest` with `POST` method. URL copied from "When an HTTP request is received" trigger and body variable.

Resco-process.png

Now, when you create a record of the specified entity type, the trigger activates.

Common errors and remedies

  • For cloud servers, make sure that you have specified the proper server under the Connection dialog. If not, you may get an Unauthorized error.
  • For custom or on-premise servers, enter the URL including protocol and port (if applicable), e.g., https://mycompany.com[:8080].

FAQ

How to use List records input parameters?
These are standard OData query parameters. The syntax for each input parameter is defined by OData specification. The only thing to think of is using logical names instead of display names. (e.g. Account -> account, Name -> name, etc.). Logical names can be found under Entities in the Admin Console.
How do I get a picklist label?
Each picklist field returns 2 values:
  • Field - This is the picklist value
  • Field (Label) - This is the label for the picklist value.
How do I get a lookup label?
Each lookup field returns 3 values:
  • Field - This is the ID (GUID) of the reference
  • Field (Label) - This is the label (primary name) of the reference.
  • Field (Type) - This is the target entity of the reference.
How do I set a lookup field?
When setting lookup fields, you have to construct a reference consisting of record type and record id.
  • From existing record in your flow, you can use OData Id
  • By creating logicalName:id expression
  • By creating logicalName('id') expression


See also