Help

Re: [Solved] Script Settings: CreateRecordAsync

Solved
Jump to Solution
928 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Chris_Guthrie
7 - App Architect
7 - App Architect

I’m having some trouble using a Script Setting input field when building a new record using CreateRecordAsync. Any help would be appreciated! Thanks!

I keep getting errors like this

Field ‘orderEvents’ does not exist in table ‘Inventory & Order Events’
at main on line 318

Here is my setup

const config = input.config({
title: 'Replenish Script',
description: 'This utility/script acts like a form for choose information about the coming replenishment',
items: [
    input.config.table('eventsTable', {
        label: 'Inventory & Order Events',
        description: 'Choose Inventory & Order Events Table'
    }),
    input.config.table('locationsTable', {
        label: 'Locations Table',
        description: 'Choose the Contacts and Vendors table'
    }),
    input.config.table('measurementsTable', {
        label: 'Measurments Table',
        description: 'Choose the measurements table'
    }),
    input.config.table('productsTable', {
        label: 'Products Table',
        description: 'Choose the products table'
    }),
    input.config.table('ordersTable', {
        label: 'Ordres Table',
        description: 'Choose the Table with our Order Groups'
    }),
    input.config.field('panStarInventoryField', {
        label: 'Pan Star Inventory Field',
        parentTable: 'ordersTable'
    }),
    input.config.field('rppPreppedInventoryField', {
        label: 'RPP PRepped Inventory Field',
        parentTable: 'ordersTable'
    }),
    input.config.field('regionalExpressInventoryField', {
        label: 'Regional Express Inventory Field',
        parentTable: 'ordersTable'
    }),
    input.config.field('gillInventoryField', {
        label: '616 Gill Ave Inventory Field',
        parentTable: 'ordersTable'
    }),
    input.config.field('totalInventoryField', {
        label: 'Units @ 3PL Inventory Field',
        parentTable: 'ordersTable'
    }),
    input.config.field('cartonInfo', {
        label: 'Carton Info Field',
        parentTable: 'eventsTable'
    }),
    input.config.field('locationVendor', {
        label: 'Location/Vendor Field',
        parentTable: 'eventsTable'
    }),
    input.config.field('transactionQty', {
        label: 'Transaction Qty Field',
        parentTable: 'eventsTable'
    }),
    input.config.field('orderGroupSummary', {
        label: 'Order Group Summary Field',
        parentTable: 'eventsTable'
    }),
    input.config.field('productOrderGroupSummarytable', {
        label: 'Product Field',
        parentTable: 'eventsTable'
    }),
    input.config.field('orderEvents', {
        label: 'Events Field',
        parentTable: 'eventsTable'
    }),
]

})

//set models
const cartonInfo = config.cartonInfo;
const locationVendor = config.locationVendor;
const transactionQty = config.transactionQty;
const orderGroupSummary = config.orderGroupSummary;
const productOrderGroupSummarytable = config.productOrderGroupSummarytable;
const orderEvents = config.orderEvents;

if (shouldContinue == "yes") {
let recordID = await config.eventsTable.createRecordAsync(
    {
        orderEvents : { name: destination },
        "Date": new Date(),
        productOrderGroupSummarytable: { id: product },
        orderGroupSummary: { id: selectedOrder },
        transactionQty: (parseInt(unitsToDeduct)) * -1,
        locationVendor: { id: selectedVendor },
        cartonInfo: { id: selectedCarton }
    });

}

1 Solution

Accepted Solutions
kuovonne
18 - Pluto
18 - Pluto

You need to put square brackets around the variable name when using a variable as an object key. You will need to do this for all of the object keys, not just the first one.

[orderEvents] : { name: destination },

See Solution in Thread

2 Replies 2
kuovonne
18 - Pluto
18 - Pluto

You need to put square brackets around the variable name when using a variable as an object key. You will need to do this for all of the object keys, not just the first one.

[orderEvents] : { name: destination },
Chris_Guthrie
7 - App Architect
7 - App Architect

That was it. Thanks!