Attach Files From the Forma Files Tool to Submittals
This tutorial demonstrates how to attach files from the Forma Files tool to a submittal item.
The steps include verifying the user permissions and gathering required fields for attaching the file, finding the folder containing the file in Forma Files, finding the version ID of the file you want to attach, and attaching the file to a submittal item. For information about uploading files to the Forma Files tool, see the Upload Files to the Forma Files Tool tutorial.
Forma files are stored in the Data Management service. To access the files, you need to provision access to the Data Management API.
For information about attaching local files to submittals, see the Attach Local Files to a Submittal Item tutorial.
For more information about working with submittals, see the Help documentation.
Before You Begin
-
Acquire a 3-legged OAuth token with
data:readdata:writescopes. -
This tutorial assumes an item was created in Submit state
sbc-1by a user with manager permissions. For more information on creating a submittal item, see the Create a Submittal Item tutorial. In this example, assume the submittal item ID is463c0b75-7c85-43ce-aa9f-74781aa29070. -
Verify that you have access to the relevant hub and Forma project.
-
Find the relevant hub ID and project ID for the hub and project that contains the file you want to attach to a submittal item. See the Retrieve a Hub ID and Project ID tutorial for more details. In this example, assume the hub ID is
b.43939999-0bf2-490d-8e4a-c1cb1097125c, and project ID isb.55451d9a-b6a5-429d-8bc3-6074765c52e0. -
Ensure you have assigned manager-level permissions to at least one user for the project via the UI. To assign a manager to a submittal item, you need to ensure the user has the necessary permissions and roles set within the project. For instructions on setting up roles and permissions see the Help documentation.
-
The Submittal Item workflow progresses through several sequential states. Below are the states in the UI and their equivalent API names:
Step 1: Verify Permissions and Fields
You should first verify that the user has permissions to add an attachment to a submittal item and gather the mandatory and optional fields required when calling the add attachment endpoint (POST attachment) in step 6.
Call GET item using the project ID (55451d9a-b6a5-429d-8bc3-6074765c52e0) and the submittal item ID (463c0b75-7c85-43ce-aa9f-74781aa29070). Check the permittedActions object for Attachment::create. If this action is listed, the user has permission to create an attachment.
The permittedActions object also provides the mandatoryFields and fields arrays, which specify the required and optional parameters for the POST attachments request. Calling GET item at any stage in the workflow will return the permitted actions for the user at that point for the submittal item.
Request
Response
Note the following fields that are relevant for calling POST attachments in step 5:
-
Mandatory Fields:
> - Locate the
permittedActionsobject with"id": "Attachment::create". ThemandatoryFieldsarray specifies the required fields for creating an attachment: >
> -name: The name of the attachment. > -urnTypeId: The type of object being referenced. This field must always be included, and its value should always be2. -
Optional Fields:
> - Under the same
"id": "Attachment::create"entry, thefieldsarray lists optional parameters: >
> -categoryId: Links the attachment to a specific workflow state. > -urn: The version ID of the file being attached. > -isFileUploaded: Set totrueif the file has already been uploaded in the Forma Files tool.
Step 2: Find the Folder ID
When we attach the file to a submittal item we will need to provide the version ID of the file that was uploaded to the Forma Files tool. To find the version ID we need to use several Data Management API.
Note that the Forma hub ID corresponds to a Data Management hub ID. To convert an account ID into a hub ID you need to add a b. prefix. For example, an account ID of c8b0c73d-3ae9 translates to a hub ID of b.c8b0c73d-3ae9.
Note that an account in Data Management is called a hub.
Use the account ID (hub ID) (b.43939999-0bf2-490d-8e4a-c1cb1097125c) and the project ID (b.55451d9a-b6a5-429d-8bc3-6074765c52e0) to call GET topFolders to get the top-level folders for the project. For details about retrieving hub and project IDs, see the Retrieve a Hub ID and Project ID tutorial.
Request
Response
Assume that the file is in the Project Files folder (data.attributes.name), and note the folder ID (data.id) - urn:adsk.wipprod:fs.folder:co.-jRpdNhnTAGQPdWTHOqE4w
If you want to attach a file from a folder nested under the Project Files folder, you need to call GET projects/:project_id/folders/:folder_id/contents repeatedly through the hierarchy of folders until you find the Folder ID of the folder you want to attach to the submittal item. For the first iteration, use the Project Files ID (urn:adsk.wipprod:fs.folder:co.-jRpdNhnTAGQPdWTHOqE4w).
Step 3: Find the Version ID for the File
Use the project ID (b.55451d9a-b6a5-429d-8bc3-6074765c52e0) and the Project Files folder ID (urn:adsk.wipprod:fs.folder:co.-jRpdNhnTAGQPdWTHOqE4w) to call GET contents to get the version ID for the file.
Request
Response
In this example, assume that ElectricalPlan_S456_Rev02.pdf is the file that you want to attach.
Find the file (included.attributes.name), and note the version ID urn:adsk.wipprod:fs.file:vf.g2vEflLTS86eDc1Jx2GJJg?version=1.
Step 4: Attach the File to the Submittal Item
Call POST attachment to attach the file identified in the previous steps to the specified submittal item. This registers the file within the submittal workflow..
The request must include the following fields:
name: The name of the file attachment.urn: The version ID of the file (urn:adsk.wipprod:fs.file:vf.g2vEflLTS86eDc1Jx2GJJg?version=1) obtained in Step 3.urnTypeId: This must always have the value2.isFileUploaded: Set totrue.
The following fields are optional:
-
The
categoryIdis typically assigned automatically based on the submittal item’s current state. In most cases, you do not need to includecategoryIdin your request. However, for specific exceptions, you must provide it explicitly:> - Prepare for Review (
mgr-1): By default, when the submittal item is in the Prepare for Review state, thecategoryIdis assigned automatically as2(for-review). If you want the attachment to be tagged as a Submit state attachment instead, you must explicitly setcategoryIdto1in the request. > - Final Response Attachments: If you are closing a submittal item from a state other than Close and Distribute (mgr-2), and you want the attachment to be marked as a final response, explicitly setcategoryIdto4. -
For items in the Review (
rev) state, include thetaskIdfield to associate the attachment with a specific task. This ensures the attachment is linked to the relevant task in the review process.
You can retrieve the full list of available categoryId values and their corresponding meanings by calling GET metadata, and reviewing the attachmentCategories list in the response.
Request
Response
Once the request is completed successfully, the response will include the attachment ID, name, and other metadata, confirming that the file has been linked to the submittal item.
Congratulations, You have added an attachment to a submittal item from the Forma Files tool.
Imported from the Autodesk Platform Services documentation: https://aps.autodesk.com/en/docs/acc/v1/tutorials/submittals/attach-files-tool.