0

I need to create a data extension using javascript that includes DECIMAL fields.

Here's my code that wasn't working.

var deObj = {
        "CustomerKey" : "Genesis_DE",
        "Name" : "Genesis_DE",
        "Fields" : [
          { "Name" : "OppID", "FieldType" : "Number", "IsPrimaryKey" : true, "IsRequired" : true },
          { "Name" : "MemSvngs", "FieldType" : "Decimal", "MaxLength" : 15.2 },
        ]
    };

var myDE = DataExtension.Add(deObj);

I was pretty sure the issue was with the DECIMAL field. Specifically, I didn’t think the syntax for the MaxLength parameter was correct. But, I couldn’t find documentation on what the right format is.

What's the correct syntax for defining a decimal field in Marketing Cloud using SSJS DataExtension.Add method? The documentation from SF doesn't offer any help here and I'm a SSJS beginner.

1

Turns out the right parameter to use in the JSON is "Scale". So the code that ended working is...

var deObj = {
        "CustomerKey" : "Genesis_DE",
        "Name" : "Genesis_DE",
        "Fields" : [
          { "Name" : "OppID", "FieldType" : "Number", "IsPrimaryKey" : true, "IsRequired" : true },
          { "Name" : "MemSvngs", "FieldType" : "Decimal", "MaxLength" : 15, "Scale" : 2 },
        ]
    };

var myDE = DataExtension.Add(deObj);
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.