1

I'm trying to add a new row to a Shared Data Extension using SSJS. When I try to run my code I got this error:

"There was an error Adding the row(s)."

In another environment of Marketing cloud, the code works and does not give errors. Why is there an error?

My code:

<script runat="server">
    Platform.Load("core", "1");

    try {
        var de = DataExtension.Init("EXTERNAL KEY");
        var data = {
            status: "status",
            errorMsg: "errorMsg"
        }
       Write(de.Rows.Add(data));
    }catch(error) {
        Write(Stringify(error));
    }
</script>
6
  • Are you running this in the parent BU? "Shared" means "parent" context, always, no matter from where it's shared. If you run this from child BU context, it might not find the DE? Commented Apr 22, 2020 at 6:49
  • Thanks, I tried to run it from a child BU...From there I got the error. Commented Apr 22, 2020 at 7:00
  • @DanielRomano Since you are running into the child BU but in Share data extensions. Did you use "ENT." as prefix? Also instead of External Name Try using Data extension name - Like this - DataExtension.Init("ENT.Data Extension Name");Let me know if this works!
    – Naveen VM
    Commented Apr 22, 2020 at 7:46
  • @razor It works thank you so much!!!!!!! Commented Apr 22, 2020 at 8:23
  • Now I tried to read the DE. I used it like this: Rows.Retrieve() and I got 0 Result Commented Apr 22, 2020 at 8:52

2 Answers 2

2

Since you are running into the child BU but in Share data extensions.

Please you use "ENT." as prefix. Also instead of External Name Try using Data external Key.

Like this - DataExtension.Init("ENT.Data External Key");

0

To expand on the WHY. Shared data extensions are owned by the enterprise regardless of what BU made them.

1

You must log in to answer this question.

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