1

I have a script in SSJS that works fine inside a CloudPage (I use it for debug). For some unknown reason the same script doesn't work in Script Activity inside the automaton, without any error and without "failing" the Automation. Simply inside the DE there aren't ROWS (the same rows that I delete populated form the same script with Cloud Page).

The script makes an API call, gets back the response, parses it and saves the result inside a data extension with "upsertData" (I also try with upsertDE).

The question is: Can I add/update/upsert the content of a DE with SSJS using a Script Activity?

(without make a request to a Cloud Page inside the Activity)

I make a test with this simple SSJS code (but it's only to understand, my Script is an other thing), RESULT: no rows added to the DE.

Platform.Load("core","1.1.1");
var myde = new DataExtension.Init("CE235575-F895-4394-BH7A-90CAAE52592A");
myde.Rows.Add({"rows_count":"saved row: 1"});

Above, CE235575-F895-4394-BH7A-90CAAE52592A is the external key of my DE, I have also try with DE name. Also, rows_count is a Text field of the DE (maxLength: 50)

In this test I use myde.Rows.Add but I try also with the other methods (Platform.Function.): upsertDE/upsertData, updateDE/updateData, addDE/addData. But remember, the same script WORKS inside a CloudPages.

Is it a problem only on my Instance? (If it is I will open a Case but first I want to understand).

  • Your English was just fine. Made some minor tweaks but otherwise looks like a good question to me! +1 – Adrian Larson Jun 30 '18 at 16:37
  • Try removing the quotes around your field name. {rows_count:"saved row: 1"} – Gortonington Jul 1 '18 at 3:59
  • Thanks @AdrianLarson! @Gortonington i could try but in Javascript Syntax there is no difference to using them or not. – Frogmouth Jul 1 '18 at 16:42
  • 1
    Ok. SF support is useless, I try to submit a case but they told me that isn't in SF support scope. – Frogmouth Jul 2 '18 at 12:07
  • I know in normal syntax it is not needed, but SFMC has its own syntax and the sample shows it w/out the quotes. developer.salesforce.com/docs/… – Gortonington Jul 2 '18 at 18:55
2

Your script needs an opening <script runat=server> and closing </script> tag.

You would have assumed that it's implied (as you can only use SSJS scripts in Script Activities) but I recall it's required.

  • Yes. You are right! The problem is the <script> wrapping. I feel like a poor stupid idiot. I have think a lot of times: "try to wrap all with <script> tag" but I never did that, I have think also: "No man! Here you can place only SSJS is useless there is surly some other problem". You save my mind's wellness. I was convinced that the script works because the API counter (in the external control panel) log the calls, maybe without "<script/>" the script works only function that not interact with MC entities (only to call external API) I use it for that without <script> a lot of times. – Frogmouth Jul 4 '18 at 14:17

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.