
This example illustrates how to start a BPM process using the BPM Process Start OData service.
In the example, a BPM process with the following start data XSD is used:
<complexType name="<Customer>"> <sequence> < element name="<firstName>" type="<string>"></element> < element name="<lastName>" type="<string>"></element> < element name="<address>" type="<tns:Address>"></element> < element name="<currency>" type="<string>" default ="<EUR>"></element> < element name="<phone-numbers>" type="<string>" maxOccurs="<unbounded>" minOccurs="<0>"></element> < element name="<vcards>" type="<tns:Vcard> "maxOccurs="<unbounded>" minOccurs="<0>"></element> </sequence> </complexType> <complexType name="<Address>"> <sequence> < element name="<street>" type="<string>"></element> < element name="<city>" type="<string>"></element> < element name="<zip>" type="<integer>"></element> < element name="<country>" type="<string>"></element> </sequence> </complexType> <complexType name="<vCard>"> <sequence> < element name="<attr1>" type="<string>"></element> < element name="<attr2>" type="<string>"></element> < element name="<attr3>" type="<string>"></element> </sequence> </complexType>
The BPM Process Start OData service provides the following metadata for the aforementioned process start data:
<EntityType Name="StartData">
<Key>
<PropertyRef Name="vendor" />
<PropertyRef Name="dcName" />
<PropertyRef Name="processTechnicalName" />
</Key>
<Property Name="vendor" Type="Edm.String" Nullable="false" />
<Property Name="dcName" Type="Edm.String" Nullable="false" />
<Property Name="processTechnicalName" Type="Edm.String" Nullable="false" />
<Property Name="processInstanceId" Type="Edm.String" Nullable="true" />
<NavigationProperty Name="ProcessStartEvent"
Relationship="BPMProcessStart.StartData_ProcessStartEvent" FromRole="StartData" ToRole="ProcessStartEvent" />
</EntityType>
<EntityType Name="ProcessStartEvent">
<Key>
<PropertyRef Name="EDM_Key" />
</Key>
<Property Name="EDM_Key" Type="Edm.String" Nullable="false" />
<NavigationPropertyName ="Customer"
Relationship="BPMProcessStart.ProcessStartEvent_Customer" FromRole="ProcessStartEvent" ToRole="Customer" />
</EntityType>
<EntityType Name="Customer">
<Key>
<PropertyRef Name="EDM_Key" />
</Key>
<Property Name="EDM_Key" Type="Edm.String" Nullable="false" />
<Property Name="firstName" Type="Edm.String" Nullable="true" />
<Property Name="lastName" Type="Edm.String" Nullable="true" />
<Property Name="currency" Type="Edm.String" Nullable="true" DefaultValue="EUR" />
<NavigationProperty Name="address" Relationship="BPMProcessStart.Customer_Address" FromRole="Customer" ToRole="Address" />
<NavigationProperty Name="phone-numbers" Relationship="BPMProcessStart.Customer_phone-numbers" FromRole="Customer" ToRole="phone-numbers" />
<NavigationProperty Name="vcards" Relationship="BPMProcessStart.Customer_Vcard" FromRole="Customer" ToRole="Vcard" />
</EntityType>
<EntityType Name="Address">
<Key>
<PropertyRef Name="EDM_Key" />
</Key>
<Property Name="EDM_Key" Type="Edm.String" Nullable="false" />
<Property Name="street" Type="Edm.String" Nullable="true" />
<Property Name="city" Type="Edm.String" Nullable="true" />
<Property Name="zip" Type="Edm.Decimal" Nullable="true" />
<Property Name="country" Type="Edm.String" Nullable="true" />
</EntityType>
<EntityType Name="phone-numbers">
<Key>
<PropertyRef Name="EDM_Key" />
</Key>
<Property Name="EDM_Key" Type="Edm.String" Nullable="false" />
<Property Name="phone-numbers" Type="Edm.String" Nullable="true" />
</EntityType>
<EntityType Name="Vcard">
<Key>
<PropertyRef Name="EDM_Key" />
</Key>
<Property Name="EDM_Key" Type="Edm.String" Nullable="false" />
<Property Name="attr1" Type="Edm.String" Nullable="true" />
<Property Name="attr2" Type="Edm.String" Nullable="true" />
<Property Name="attr3" Type="Edm.String" Nullable="true" />
</EntityType >For more information about the generation of the Entity Data Model from XSD, see From XSD to the Entity Data Model.
According to the table with the service URIs, starting a process requires a POST request to be sent to the service, with the request body containing the process start event along with the entity for the process start data.
According to the metadata, the process start data is represented as a Customer entity type, which has a number of primitive properties, a single-valued navigation property for the Address entity type, and multi-valued navigation properties for phone-numbers and Vcard entity types. Taking the structure of all the aforementioned entity types into consideration, the POST request body to start the process needs to be created in the following way:
{
"ProcessStartEvent": {
"Customer": {
"firstName": "John",
"lastName": "Doe",
"currency": "EUR",
"address": {
"street": "Mainstr.",
"city": "Walldorf",
"zip": "69190",
"country": "Germany"
},
"phone-numbers": {
"results": [
{
"phone-numbers": "111-111-111"
},
{
"phone-numbers": "222-222-222"
},
{
"phone-numbers": "333-333-333"
}
]
},
"vcards": {
"results": [
{
"attr1": "value11",
"attr2": "value12",
"attr3": "value13"
},
{
"attr1": "value21",
"attr2": "value22",
"attr3": "value23"
},
{
"attr1": "value31",
"attr2": "value32",
"attr3": "value33"
}
]
}
}
}
}The service response for such a POST request contains the provided process start data along with the identifier of the started process instance.