Monetize360

Create or Update Record

Add a new record to a table or update an existing record if it already exists. You can also link this record to other records in your system.

Technical Name: InsertMDataFunc

Properties

  • Execution Mode: SYNC
  • Type: NATIVE
  • Category: CRUD Operations
  • Function ID: 3f9a1ea8-5d9a-4f2b-a8f6-8f6b5d9a1ea9

Input Schema

Required Parameters

ParameterTypeDescription
dataobjectThe data to insert or update

Optional Parameters

ParameterTypeDescription
idstring (uuid)ID of the record to update (creates new if not provided)
mobjectIdstring (uuid)The Object to insert data into

[Image placeholder: InsertMData function configuration panel]

Input Example

{
  "mobjectId": "3f9a1ea8-5d9a-4f2b-a8f6-8f6b5d9a1ea9",
  "data": {
    "name": "John Doe",
    "email": "john@example.com",
    "phone": "+1234567890",
    "status": "Active"
  }
}

Output Schema

The function returns the created or updated MData record:

FieldTypeDescription
idstring (uuid)The unique identifier of the record
mobjectIdstring (uuid)The Object ID this record belongs to
dataobjectThe stored data
createdAtstring (date-time)Timestamp when the record was created
updatedAtstring (date-time)Timestamp when the record was last updated

Output Example

{
  "id": "7f8a2ea8-6d9a-5f3b-b9f7-9f7b6d9a2eb1",
  "mobjectId": "3f9a1ea8-5d9a-4f2b-a8f6-8f6b5d9a1ea9",
  "data": {
    "name": "John Doe",
    "email": "john@example.com",
    "phone": "+1234567890",
    "status": "Active"
  },
  "createdAt": "2024-01-15T10:30:00Z",
  "updatedAt": "2024-01-15T10:30:00Z"
}

[Image placeholder: InsertMData output visualization]

Use Cases

Creating New Records

Use InsertMData to create new records without providing an id:

{
  "mobjectId": "customer-mobject-id",
  "data": {
    "name": "Jane Smith",
    "email": "jane@example.com"
  }
}

Updating Existing Records

Provide an id to update an existing record:

{
  "id": "existing-record-id",
  "mobjectId": "customer-mobject-id",
  "data": {
    "status": "Inactive",
    "lastModified": "2024-01-15"
  }
}

Working with Relationships

InsertMData supports relationships through reference fields:

{
  "mobjectId": "order-mobject-id",
  "data": {
    "orderNumber": "ORD-001",
    "customerId": "customer-record-id",
    "items": [
      {"productId": "prod-1", "quantity": 2},
      {"productId": "prod-2", "quantity": 1}
    ]
  }
}

Workflow Example

A typical workflow using InsertMData:

Start → ValidateInput → InsertMData → EmailNotification → End

[Image placeholder: Workflow diagram showing InsertMData in context]

Error Handling

Common errors and how to handle them:

Validation Errors

{
  "error": "Validation failed: email field is required",
  "timestamp": "2024-01-15T10:30:00Z"
}

Permission Errors

{
  "error": "User does not have permission to insert data in this Object",
  "timestamp": "2024-01-15T10:30:00Z"
}

Best Practices

  1. Always validate input data before calling InsertMData
  2. Use bulk operations when inserting multiple records (see BulkInsertMData)
  3. Handle errors gracefully with proper error checking nodes
  4. Set appropriate field mappings for reference fields
  5. Use transactions for related inserts to maintain data integrity

External Data Source Configuration

The mobjectId parameter supports external data source configuration for dropdown selection:

{
  "externalDataSource": {
    "source": "mobject",
    "sourceField": "name"
  }
}

This allows you to select the Object by name in the workflow designer.

[Image placeholder: Object selector dropdown]