1

I’m trying a default date value of ‘use current date’ when creating a data extension via WSProxy.

I’ve tried

Now() GetDate() Current Date

Docs say Now(), another SFSE post says GetDate(); neither worked for me. The script works when I don’t set a default value for it.

1 Answer 1

5

this is curious, but it works:

"getdate()" including doubleQuotes.

    Platform.Load("Core","1");

    var prox = new Script.Util.WSProxy();
    var name = "myDE";
    var de = {
        Name: name,
        CustomerKey: name,
        Description: "",
        Fields: [
            {
                FieldType: "Text",
                Name: "Field1",
                MaxLength: 254,
                IsPrimaryKey: true,
                IsNillable: false,
                IsRequired: true
            },
            {
                FieldType: "Date",
                Name: "Field2",
                DefaultValue: "getdate()"
            }
        ]
    }

    var res = prox.createItem("DataExtension", de);
</script>
2
  • That worked! Thanks for the assist, it shows up as "getdate()" in the default column when you are looking at the DE but it works and that's all that matters. Commented Aug 11, 2020 at 12:33
  • 1
    Yep, I think that is actually the same when you add it manually. Commented Aug 11, 2020 at 13:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .