Flow Help
NovacuraRoadmap
6.11
6.11
  • What is Novacura Flow?
  • ๐Ÿ““System requirements
  • ๐ŸŽ‰Release notes
  • ๐ŸŽฃGetting started
    • Quick start
    • Develop your first app
  • ๐Ÿ”จInstallation and upgrade
    • Installation
    • New installation
    • Upgrade installation
    • Apply service pack
    • Add component
    • Windows authentication
    • Event log
    • FAQ
      • Monitoring
      • Troubleshooting
      • Migration tool
      • IIS user permission
      • Moving SQLite portal database
  • ๐ŸงฑSecurity
    • Server
      • Security settings
  • ๐Ÿ’กDevelopment
    • Studio
      • Installation and log in
        • OpenID connect
      • Applications
        • Menu
          • Inbox
        • Workflow
          • Start step
          • User step
            • Header
            • Static text
            • Labeled static text
            • Link
            • External app launcher
            • Image viewer
            • Text input
            • Numeric input
            • Date input
            • Time input
            • Check box input
            • Binary option input
            • List selection input
            • List multi-selection input
            • Menu selection input
            • Image selection input
            • Data grid
            • Calendar
            • List presentation
            • Camera input
            • File gallery
            • GPS location input
            • Signature capture input
            • Item creation sub task
            • Check list sub task
            • Verb sub task
          • Machine step
          • Decision step
          • Assertion step
          • Assignment
          • Table
          • Checkpoint
          • Split
          • Join
          • Script item
          • Log point
          • Annotation
          • End step
          • Included workflow
          • Offline resource
          • Public variables
          • Swimlanes
          • Offline workflow
            • Create an offline workflow
            • Create an offline resource
            • Create an offline seed inbox
            • Create an offline transactions
        • Subscribe
        • Server content
          • Workflow scheduler
          • Generate link
        • Elements
        • Problems
        • Find
        • Metadata panel
        • Version panel
        • Navigation
        • Test bench
        • Application package
          • Get started
      • Environment
        • Users
        • Roles
        • Connectors
        • Properties
        • Languages
        • System events
        • Active directory sync
        • License
        • Devices
        • Branding
        • Reports
      • Monitoring
        • Tasks
        • Applications
        • Help requests
      • Connectors
        • Business systems
          • Database
          • IFS Applications
          • Infor M3
            • M3 Infor API
            • Infor M3 REST
          • Maximo Generic
          • SAP
            • SAP BAPI
              • Basic API
                • BAPI: ZNCFLOW_APPLICATION_COMPONENT
                • BAPI: BAPI_MONITOR_GETLIST
                • BAPI: BAPI_INTERFACE_GETDOCU
                • BAPI: RFC_GET_FUNCTION_INTERFACE
                • BAPI: ZNCFLOW_DDIF_FIELDINFO_GET
          • Oracle Primavera
          • Microsoft Dynamics AX
          • Microsoft Dynamics CRM
          • Microsoft Active Directory
          • Microsoft SharePoint 2013
            • Generic operations
              • Custom list
                • Attachments
                • Create new item
                • Create new item, with field values
                • Delete item
                • Get items by query
                • List all items
                • List fields of items
                • Update item field
              • Document library
                • Check in/out file
                • File management
                • Create sub folder
                • Upload/download
              • Tasks
                • Attachments
                • Predecessors
                • Task information
                • Update task
                • Create new subtask
                • Create new task
              • User operations
                • Group operations
                • Get user by ID
                • Get user by login name
                • List users
        • Communication
          • Email
          • Web page submit
          • FTP
            • Server Operations
            • Directory operations
            • Download Operations
            • File Operations
            • Upload operations
          • SFTP
            • Directory operations
            • Download operations
            • File operations
            • Upload operations
          • Modbus
            • Read operations
            • Write operations
          • External Oauth 2.0 provider
          • Siox
          • REST service
            • REST Project Tool
              • Global output
              • Global parameters
              • Authorization schemes
              • Model transform
              • Enumerations
              • Models
                • Custom model member
              • Operations
                • Parameters
                • Outputs
              • Getting started
          • Web service
            • Example
              • Webservice example: Connector to Microsoft Dynamics AX
        • Printing
          • BarTender 2016
            • Print
            • Manually select
            • Print from BTXML script
            • Print from BTXML script
            • List printers
          • NiceLabel
          • Html to PDF
        • Utility
          • Flow environment
          • Table Operations
          • Custom .NET
          • Google API
          • Generate Xml Data
          • Generate text
          • File System
            • Directory operations
            • File operations
            • Zip operations
      • FlowScript
        • Variables
        • Operators
        • Functions
          • Text functions
          • Number functions
          • Date functions
          • Advanced functions
        • Table
          • Table functions
        • Programs
        • Formats
        • Script examples
        • AD sync scripting
    • Portal 2
      • Getting started
      • General
        • Add pages and portlets
        • Edit pages
        • Navigation
        • Style
        • Settings
          • List of values management
          • Presentation mode
      • Portlets
        • Chart portlets
          • Column chart
          • Line chart
          • Pie chart
        • Data tree
        • Document viewer
        • Filter
        • Html table
        • KPI portlets
          • KPI card
          • Speedometer
        • Record viewer
        • Table
        • Text
        • Common configuration
    • Portal
      • Get started
      • Options
        • Settings
        • List of values management
        • Global variables management
        • Content access management
        • Translations management
        • Import/export
      • Portlets
        • Table
          • Database source
          • Workflow source
        • Record viewer
        • Process overview
        • Iframe
        • Inbox
        • News viewer
        • Document tree
        • Document list
        • Document viewer
        • Generic document viewer
        • Generic document viewer URL
        • Generic document viewer
        • Filter
        • HTML
        • Text
        • Data visualizer card
        • Data visualizer navigator
        • Visual planning
          • Gantt chart
          • Kanban
          • Resource bucket
          • Scheduler
        • Map
      • Portal Push
      • Icons
  • ๐Ÿ“ฑClients
    • Android legacy client
    • iOS client
    • Windows 10 client
    • Web client
    • Windows CE client
  • โ“FAQ
    • How do i find which version of Flow i am running?
  • ๐Ÿ“งContact
Powered by GitBook
On this page

Was this helpful?

  1. Development
  2. Studio
  3. Connectors
  4. Communication
  5. REST service
  6. REST Project Tool

Model transform

PreviousAuthorization schemesNextEnumerations

Last updated 4 years ago

Was this helpful?

Model transform is a feature where you as REST connector developer can manipulate the response from a REST API before returning it to the workflow. You can also use it to manipulate an outgoing object (body parameter).

Transforming incoming models

Typical use case is when an API returns data like this:

{
    properties : [
        {
            property: "Property1",
            value : "Value1"
        },
        {
            property: "Property2",
            value : "Value2"
        },
        {
            property: "Property3",
            value : "Value3"
        },
    ]
}

When used as an output model in REST connector you would end up with an output looking like this in Flow:

This can be managed with Flow Script, but it can be more convenient and efficient to do the transformation inside the connector. Especially if the connector is used in multiple workflows.

The output of the remote operation is of course still the data above, so we have to define a model to represent that data:

But we can also define the model that we want to expose to the workflow. Something like this:

Let's add the transformation.

Select "Model transformations" in connector tree and press the "NEW" button

Give the transformation a descriptive name and select source model and target model

Double click on the newly created transformation in the list, or select it from the connector tree. Something like this should be loaded:

So the actual transformation is done with c# code that you provide. Do not enter any code above //Transformation code start or below //Transformation code end

This is a very powerful feature. You are, however, limited to provide code that is compliant with c# 5.0. You are also limited to only use types from the following assemblies:

System
System.ComponentModel
System.ComponentModel.DataAnnotations
System.Core
System.Data
System.Drawing
System.Net.Http
System.Runtime
System.Runtime.Serialization
System.ServiceModel
System.ServiceModel.Web
System.Web
System.Xml

Note that not all of these assemblies are available by default. The "usings" that all transformation code uses can be changed here:

An example of transformation code for this situation could be:

public static Model_transformedOutput Operation_output_To_Transformed_output(Model_operationOutput input)
{
    var output = new Model_transformedOutput();
    //Transformation code start

    output.Property1 = input.properties.First(p => p.property == "Property1").value;
    output.Property2 = input.properties.First(p => p.property == "Property2").value;
    output.Property3 = input.properties.First(p => p.property == "Property3").value;    

    //Transformation code end
    return output;
}      

Note that models are called 'Model_' followed by the name of the model.

All that is left to do now is to apply the transformation to the operation of interest:

Which is easier to work with as a workflow designer.

There are a lot more scenarios that this feature enables. You could for instance add new output members (composed of values from other members for instance) or hide members that are not of interest to the workflow designer.

The code will run with limited permissions. It is for instance not allowed to access the file system, so code such as

System.IO.File.AppendAllText(@"C:\logs\values.txt", input.Property1);

will not work and you will get an error in runtime.

Transforming outgoing models

Like incoming models there are scenarios where it makes sense to transform the outgoing models before it is sent to remote API. Let's assume the same data structures as above are in action here as well. The transformation now needs to be from the model 'transformedOutput' to model 'operationOutput'. Names now becomes a bit off, since we are not dealing with output, but I'm sure you get the picture.

Then the transformation code could look something like this:

public static Model_operationOutput Transformed_to_real_output(Model_transformedOutput input)
{
    var output = new Model_operationOutput();
    //Transformation code start
    output.properties = new System.Collections.Generic.List<Model_properties>();
    
    output.properties.Add(new Model_properties() { property = "Property1", value = input.Property1});
    output.properties.Add(new Model_properties() { property = "Property2", value = input.Property2});
    output.properties.Add(new Model_properties() { property = "Property3", value = input.Property3});
    //Transformation code end
    return output;
}

Apply the transform.

In the machine step the operation input would then look like this:

Without the transformation the machine step would look like this:

There certainly are situations where the later is preferred, maybe there is already a table with property+values available and so forth. With the transformation feature you can control what best suites your scenario.

Now when the connector is used in a workflow the output from the operation will look like this:

๐Ÿ’ก
modeltransform9
modeltransform1