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.

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. Aug 11 '20 at 12:33
  • 1
    Yep, I think that is actually the same when you add it manually. Aug 11 '20 at 13:49

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.