0

I've just started to get my head round SSJS and tried this simple script from a tutorial as the script I wrote (same logic) was erroring in the same way.

I am looking to upsert data into a DE from a JSON file but keep getting this error:

Error Message: "Unable to retrieve security descriptor for this frame." Description: "System.InvalidOperationException: Unable to retrieve security descriptor for this frame. - from mscorlib "

is this due to permissions, the source of the data or do I need to include some sort of authentication token when trying to enter data into the DE? any help would be greatly appreciated.

Code:

    <script language="javascript" runat="server">
  Platform.Load("Core","1");
  var response = HTTP.Get("https://reg.bom.gov.au/fwo/IDQ60901/IDQ60901.94576.json");
  var object = Platform.Function.ParseJSON(response.Content);
  
  for (i = 0; i < object.observations.data.length; i++) {
    var row = Platform.Function.UpsertDE("TEST_DE", ["local_date_time_full", "history_product"], [object.observations.data[i].local_date_time_full, object.observations.data[i].history_product], ["name", "air_temp", "rel_hum"], [object.observations.data[i].name], [object.observations.data[i].air_temp], [object.observations.data[i].rel_hum]);   
  };
</script>

DE: non sendable, all fields match what's in the script including the primary keys, rest of fields are nullable.

1 Answer 1

0

It took me some time to figure it out, but I think I've found the problem in your code.

The problem is in this line:

var row = Platform.Function.UpsertDE("TEST_DE", ["local_date_time_full", "history_product"], [object.observations.data[i].local_date_time_full, object.observations.data[i].history_product], ["name", "air_temp", "rel_hum"], [object.observations.data[i].name], [object.observations.data[i].air_temp], [object.observations.data[i].rel_hum]); 

You are putting each parameter of the 3 last ones into an array. But it you check the doc, you should put all parameters not used for filtering inside one array. Your code should look like this:

var row = Platform.Function.UpsertData("test_de_script", ["local_date_time_full", "history_product"], [object.observations.data[i].local_date_time_full, object.observations.data[i].history_product], ["name", "air_temp", "rel_hum"], [object.observations.data[i].name, object.observations.data[i].air_temp, object.observations.data[i].rel_hum]);  

For more readability, you should replace this:

[object.observations.data[i].name], [object.observations.data[i].air_temp], [object.observations.data[i].rel_hum]

by this:

[object.observations.data[i].name, object.observations.data[i].air_temp, object.observations.data[i].rel_hum]

Also, I assume you are using this code inside a landing page, so I've replaced UpsertDE by UpsertData because this is the method to use in non-sendable contexts. UpsertDE is more for sendable contexts, such as email messages

4
  • Thank you for taking the time to look through this!! I have tried using UpsertData and added the last 3 parameters into 1 array (the first array is supposed to be 'primary keys' but it's now throwing a different error. I am testing the script in CloudPages to see if it will populate then i plan to use the script in an automation so it automatically refreshes. Jun 2 at 14:23
  • Description: "ExactTarget.OMM.FunctionExecutionException: An error occurred when attempting to execute an UpsertData function call. Error Code: OMM_FUNC_EXEC_ERROR - from OMMCommon --> --- inner exception 1--- ExactTarget.OMM.FunctionExecutionException: UpsertData Function is not valid in content. This function is only allowed in a non batch context. Function: UpsertData(\"EB_TEST_P\",2,\"local_date_time_full\",\"20230603000000\",\"history_product\",\"IDQ60901\",\"name\",\"Brisbane\",\"air_temp\",15.9,\"rel_hum\",91) Error Code: OMM_FUNC_CONTEXT_ERR - from OMMCommon " Jun 2 at 14:24
  • No worries. As explained in my answer, you need to use either UpsertDE or UpsertData depending on the execution context. I've already tested the code in a cloudpage and it's inserting records into the DE without any problem. Jun 2 at 14:58
  • Thank you again, I tried it again with the parameters in 1 array and using UpsertDE and it worked!! (I wasn't publishing the cloud page thinking it would still run in just the preview) :) Jun 2 at 15:37

You must log in to answer this question.

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