Power Automate: Difference between revisions

Jump to navigation Jump to search
Line 15: Line 15:


=== 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 25:
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 32: Line 34:
* Update record: Update 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.
* 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:
<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., 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 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


== Creating a sample flow using the connector ==  
== Creating a sample flow using the connector ==  

Navigation menu