Adding Teamwork Orders programmatically

Summary

If your needs for extending the order form exceed the capabilities provided with Teamwork, or you have a third-party system you want to feed orders through automatically, follow these instructions.

How to programmatically create a new Teamwork order

To have a new order that will be automatically processed, you will need to add two rows into the Teamwork Admin site:

  1. A new entry into 'Teamwork Orders Metadata' list, which will contain the metadata for the item
  2. A new entry into 'Teamwork orders' list, which will contain other details of the order

Teamwork Orders Metadata entry

You should create an entry into the Teamwork Orders Metadata list. Use the Content type appropriate to the template you are using (e.g. if you want to use standard Teams Metadata, use the ctId of 'Team Group Metadata').

Teamwork orders entry

You should create an entry into the Teamwork orders list. The other fields should be self-explanatory, but the 'Metadata' field needs to contain a value in the following JSON format to refer to the correct Metadata entry:

1
2
3
4
5
6
7
8
9
{
   "ctId":"0x01005AA0FAEE65DE4A1DA3519C2EE415E8D7",
   "entityType":"Group",
   "templateId":"GroupTemplate1",
   "orderMetadataReference":{
      "listUrl":"/sites/teamworkadmin/Teamwork-Orders-Metadata",
      "listItemId":4
   }
}
  • ctId: Provide the Content Type Id of the template you are using.
  • entityType: Provide either 'Group' or 'Site'.
  • templateId: Provide the id of the Template you are using
  • listUrl: Provide the URL to the Teamwork Orders Metadata list
  • listItemId: Provide the ID of the list item which contains the metadata

Approving the order

If you have approval enabled for the orders list, the order will not be processed before the item has been approved. By default, approval is turned on for the Teamwork orders list.