Create-form Operation

The create-form operation returns a record form with all fields prepopulated. This operation enables you to see all default fields and the line IDs of default lines on a record, and you can modify these values before submitting the record.

With the create-form operation, you can emulate a NetSuite UI workflow by prepopulating fields on transaction line items with values from a related record. Your REST web services application can then modify only the values it needs to before submitting the record.

For example, in the UI, when you bill a sales order, an invoice record is loaded with fields populated with values from the sales order. When loading an invoice record in REST web services, you can reference the related sales order record to initialize fields with values from that sales order.

You can use the create-form operation by including the custom mediaType Accept: application/vnd.oracle.resource+json; type=create-form in your REST request header.

The create-form operation supports the same query parameters as a GET response:

Sublists and subrecords are not be expanded by default.

Accessing Metadata Related to the Create-form Operation

For every transformation operation in the metadata, the create-form operation is displayed. Similar metadata is displayed for every POST and PATCH request.

            "/salesOrder/{id}/!transform/itemfulfillment": {
    "post": {
        "tags": [
            "ItemFulfillment"
        ],
        "summary": "Create-form for transformation to itemFulfillment.",
        "parameters": [
            ...
        ],
        "requestBody": {
            "description": "Request body.",
            "content": {
                "application/vnd.oracle.resource+json; type=create-form": {
                    "schema": {
                        "$ref": "#/components/schemas/itemFulfillment"
                    }
                }
            },
            "required": true
        },
        "responses": {
            "200": {
                "description": "Pre-filled form for itemFulfillment.",
                "content": {
                    "application/vnd.oracle.resource+json; type=create-form": {
                        "schema": {
                            "$ref": "#/components/schemas/itemFulfillment"
                        }
                    }
                }
            }
        }
    }
}, 

          

Sample Code

The following request returns all fields set on the target record without submitting the record.

REST request

            POST ../record/v1/salesorder/1/!transform/itemfulfillment
Accept: application/vnd.oracle.resource+json; type=create-form
{} 

          

REST response

            Content-Type: application/vnd.oracle.resource+json; type=create-form
{
  "links": [
    {
      "rel": "self",
      "method": "POST",
      "mediaType": "application/vnd.oracle.resource+json; type=create-form",
      "href": "../record/v1/salesorder/1/!transform/itemfulfillment"
    },
    {
      "rel": "transform",
      "method": "POST",
      "href": "../record/v1/salesorder/1/!transform/itemfulfillment",
    }
 ],
 "... itemFulfillment fields ..."
} 

          

Creating a Record Using the Create-form Operation

You can also use the create-form operation to create a record. The following sample shows this usage.

REST request

            POST ../record/v1/salesorder
Accept: application/vnd.oracle.resource+json; type=create-form
{
  "entity": {
    "id": 107
  },
  "discountitem": {
    "id": 1
  }
} 

          

REST response

            Content-Type: application/vnd.oracle.resource+json; type=create-form
{
  "links": [
    {
      "rel": "self",
      "method": "POST", 
      "mediaType": "application/vnd.oracle.resource+json; type=create-form", 
      "href": "../record/v1/salesorder"
    },
    {
      "rel": "create",
      "method": "POST", 
      "href": "../record/v1/salesorder"
    }
  ],
  "... salesorder fields ..." 
} 

          

Updating a Record Using the Create-form Operation

For updating a record using the create-form operation, you can use the edit-form and edit links. The following sample shows this usage.

REST request

            PATCH ../record/v1/salesorder/1
Accept: application/vnd.oracle.resource+json; type=edit-form
{
  "entity": {
    "id": 107
  }
} 

          

REST response

            Content-Type: application/vnd.oracle.resource+json; type=edit-form
{
  "links": [
    {
      "rel": "self",
      "method": "PATCH", 
      "mediaType": "application/vnd.oracle.resource+json; type=edit-form", 
      "href": "../record/v1/salesorder/1"
    },
    {
      "rel": "edit",
      "method": "PATCH",
      "href": "../record/v1/salesorder/1"
    },
    {
      "rel": "create",
      "method": "POST", 
      "href": "../record/v1/salesorder"
    }, 
    {
      "rel": "create-form",
      "method": "POST", 
      "mediaType": "application/vnd.oracle.resource+json; type=create-form", 
      "href": "../record/v1/salesorder"
    }
  ],
  "... salesorder fields ..." 
} 

          

Related Topics

General Notices