Workflow REST API: Item References

You can use JSON, XML or a combination to post Item Reference data to a Workflow Instance or Tasks.

You can also use tools to create a class definition for JSON objects. One of the easiest approaches is to use Visual Studio Web Extensions' Paste JSON as Classes approach to copy a string of JSON representing the Item Reference and auto-generate a C# class for the item reference. See this StackOverflow topic for more information.

Posting data to Item References using XML

Note the escape character \ for each quotation mark in the "xmlContent" section.

Copy

Post using XML

{
  "itemReferences": {
    "xmlContent": "<itemReferences>
        <itemReference name=\"Leave_Request_SmartObject\" displayName=\"Leave Request SmartObject\" type=\"SmartObjectItem\" primary=\"true\" startMode=\"smartForms\">
            <settings>
                <method>
                    <objectName>Leave_Request_SmartObject</objectName>
                    <methodName>Load</methodName> 
                    <methodType>Read</methodType>
                    <objectTypes>
                        <type>Default</type>
                    </objectTypes> 
                </method>
            </settings>
            <definition />
            <items lastId=\"1\">
                <item id=\"1\"> 
                    <properties>
                        <property name=\"ID\">1</property>
                    </properties>
                    <parameters />
                </item>
            </items>
        </itemReference>
    </itemReferences>"
  }
}

Posting data to Item References using JSON notation

If you need to pass in or read item references in JSON format, this sample illustrates the expected format. For example, a SmartObject with a System Name of foo, record ID 1, with a field named bar that accepted string values:

Copy

Post using JSON notation

"itemReferences": {
    "foo": {
        "1": {
            "bar": "bar's value."
        }
    }
}

Here is another example, showing a hypothetical SmartObject named Customer with a record ID of 1, and two properties: CustomerCode with value "AZ200" and Region with value 12.

Copy

Post using JSON notation

"itemReferences": {                  //itemReferences is the name of the JSON element
    "Customer": {                  //"Customer" is the system name/identifier of the SmartObject definition
        "1": {                      //"1" is the record ID of the specific record to edit
            "CustomerCode": "AZ200",//"CustomerCode is one of the SmartObject fields, "AZ200" is the value
            "Region": 12,          //"Region" is another SmartObject field, 12 is the value
        }
    }
}