zuora to eloqua | zuora account blueprints | test eloqua import create template | Search

This code provides reusable templates for interacting with a data system, enabling bulk data imports, record creation, and potentially temporary imports. The templates use placeholders to dynamically reference fields and data sources.

Run example

npm run import -- "eloqua import create template"

eloqua import create template


module.exports = {
    bulkImportTemplate,
    contentCreateTemplate,
    temporaryImportTemplate
}

function bulkImportTemplate(templateId) {
    // replace ID for CDO
    return {
        "name": "Renewals Micro-service - Bulk Import",
        "mapDataCards": "true",
        "mapDataCardsEntityField": "{{Contact.Field(C_EmailAddress)}}",
        "mapDataCardsSourceField": "EmailAddress",
        "mapDataCardsEntityType": "Contact",
        "mapDataCardsCaseSensitiveMatch": "false",
        "updateRule": "always",
        "fields": {
            "AccountId": `{{CustomObject[${templateId}].Field(Account_ID1)}}`,
            "ActProduct": `{{CustomObject[${templateId}].Field(Act_Product1)}}`,
            "EmailAddress": `{{CustomObject[${templateId}].Field(Email_Address1)}}`,
            "Quantity": `{{CustomObject[${templateId}].Field(Quantity1)}}`,
            "Support": `{{CustomObject[${templateId}].Field(Support1)}}`,
            "SupportQuantity": `{{CustomObject[${templateId}].Field(Support_Quantity1)}}`,
            "RenewalDate": `{{CustomObject[${templateId}].Field(Renewal_Date1)}}`,
            "RenewalsStatus": `{{CustomObject[${templateId}].Field(Renewal_Status1)}}`,
            "RepName": `{{CustomObject[${templateId}].Field(Rep_Name1)}}`,
            "RORName": `{{CustomObject[${templateId}].Field(ROR_Name1)}}`,
            "RORNumber": `{{CustomObject[${templateId}].Field(ROR_Number1)}}`,
            "CardExpiration": `{{CustomObject[${templateId}].Field(Card_Expiration1)}}`,
            "State": `{{CustomObject[${templateId}].Field(State1)}}`,
            "Discount": `{{CustomObject[${templateId}].Field(Discount1)}}`,
            "Country": `{{CustomObject[${templateId}].Field(Country1)}}`,
            "Currency": `{{CustomObject[${templateId}].Field(Currency1)}}`
        },
        "identifierFieldName": "EmailAddress"
    }
}

function contentCreateTemplate() {
    return {
        "recordDefinition": {
            "ContactID": "{{Contact.Id}}",
            "EmailAddress": "{{Contact.Field(C_EmailAddress)}}"
        },
        "height": 256,
        "width": 256,
        "editorImageUrl": "https://purchasesprint.actops.com/assets/act-logo-circle.png",
        "requiresConfiguration": false,
    }
}

function temporaryImportTemplate(instance, execution) {
    return {
        "name": "Renewals Micro-service - Bulk Import",
        "mapDataCards": "true",
        "mapDataCardsEntityField": "{{Contact.Field(C_EmailAddress)}}",
        "mapDataCardsSourceField": "EmailAddress",
        "mapDataCardsEntityType": "Contact",
        "mapDataCardsCaseSensitiveMatch": "false",
        "updateRule": "always",
        "fields": {
            "EmailAddress": "{{Contact.Field(C_EmailAddress)}}",
            "Last4DigitsOfCard": "{{Contact.Field(Last_4_Digits_of_Card1)}}",
            "Content": `{{ContentInstance(${instance}).Execution[${execution}]}}`
        },
        "identifierFieldName": "EmailAddress"
    }
}

What the code could have been:

module.exports = {
  bulkImportTemplate,
  contentCreateTemplate,
  temporaryImportTemplate
};

/**
 * Creates a bulk import template with the given template ID.
 * 
 * @param {string} templateId The ID of the template.
 * @returns {object} The bulk import template.
 */
function bulkImportTemplate(templateId) {
  const fields = {
    "AccountId": getField(templateId, "Account_ID1"),
    "ActProduct": getField(templateId, "Act_Product1"),
    "EmailAddress": getField(templateId, "Email_Address1"),
    "Quantity": getField(templateId, "Quantity1"),
    "Support": getField(templateId, "Support1"),
    "SupportQuantity": getField(templateId, "Support_Quantity1"),
    "RenewalDate": getField(templateId, "Renewal_Date1"),
    "RenewalsStatus": getField(templateId, "Renewal_Status1"),
    "RepName": getField(templateId, "Rep_Name1"),
    "RORName": getField(templateId, "ROR_Name1"),
    "RORNumber": getField(templateId, "ROR_Number1"),
    "CardExpiration": getField(templateId, "Card_Expiration1"),
    "State": getField(templateId, "State1"),
    "Discount": getField(templateId, "Discount1"),
    "Country": getField(templateId, "Country1"),
    "Currency": getField(templateId, "Currency1")
  };

  return {
    "name": "Renewals Micro-service - Bulk Import",
    "mapDataCards": "true",
    "mapDataCardsEntityField": "{{Contact.Field(C_EmailAddress)}}",
    "mapDataCardsSourceField": "EmailAddress",
    "mapDataCardsEntityType": "Contact",
    "mapDataCardsCaseSensitiveMatch": "false",
    "updateRule": "always",
    "fields": fields,
    "identifierFieldName": "EmailAddress"
  };
}

/**
 * Creates a content create template.
 * 
 * @returns {object} The content create template.
 */
function contentCreateTemplate() {
  return {
    "recordDefinition": {
      "ContactID": "{{Contact.Id}}",
      "EmailAddress": "{{Contact.Field(C_EmailAddress)}}"
    },
    "height": 256,
    "width": 256,
    "editorImageUrl": "https://purchasesprint.actops.com/assets/act-logo-circle.png",
    "requiresConfiguration": false,
  };
}

/**
 * Creates a temporary import template with the given instance and execution.
 * 
 * @param {string} instance The instance.
 * @param {string} execution The execution.
 * @returns {object} The temporary import template.
 */
function temporaryImportTemplate(instance, execution) {
  return {
    "name": "Renewals Micro-service - Bulk Import",
    "mapDataCards": "true",
    "mapDataCardsEntityField": "{{Contact.Field(C_EmailAddress)}}",
    "mapDataCardsSourceField": "EmailAddress",
    "mapDataCardsEntityType": "Contact",
    "mapDataCardsCaseSensitiveMatch": "false",
    "updateRule": "always",
    "fields": {
      "EmailAddress": "{{Contact.Field(C_EmailAddress)}}",
      "Last4DigitsOfCard": "{{Contact.Field(Last_4_Digits_of_Card1)}}",
      "Content": `${getContentInstance(instance).Execution[execution]}`
    },
    "identifierFieldName": "EmailAddress"
  };
}

/**
 * Helper function to get a field from a custom object.
 * 
 * @param {string} templateId The ID of the template.
 * @param {string} fieldName The name of the field.
 * @returns {string} The field value.
 */
function getField(templateId, fieldName) {
  return `{{CustomObject[${templateId}].Field(${fieldName})}}`;
}

/**
 * Helper function to get the content instance.
 * 
 * @param {string} instance The instance.
 * @returns {object} The content instance.
 */
function getContentInstance(instance) {
  // TO DO: implement content instance logic
  return {
    Execution: []
  };
}

This code defines three template functions for interacting with a system, likely a CRM or similar platform.

Here's a breakdown:

  1. Exports:

  2. bulkImportTemplate Function:

  3. contentCreateTemplate Function:

  4. temporaryImportTemplate Function: