Skip to main content
added 21 characters in body
Source Link
Lukas Lunow
  • 22.2k
  • 4
  • 27
  • 59

%%[ SET @subscriberKey = AttributeValue('ContactKey') /* IS Triggered Products Parse */ SET @triggerRecommendationJson = AttributeValue('Trigger_Catalog_Items')

]%%
<script runat="server">
Platform.Load("Core","1");

  try {
     var triggerCatalogItems = Platform.Variable.GetValue('@triggerRecommendationJson'); 
     var payloadObj = Platform.Function.ParseJSON(triggerCatalogItems);
     var numProductsTrigger = payloadObj.length;
     var subKey = Platform.Variable.GetValue('@subscriberKey'); 

     if(numProductsTrigger > 0) {

       var catalogItem = payloadObj[0]
       var productName = catalogItem.name

       Platform.Variable.SetValue('@productAvailableCount', numProductsTrigger);    
       Platform.Variable.SetValue('@productName', productName);  

       var rows = Platform.Function.UpsertData("audience for test push",["ContactKey"],[subKey],["productName"],[productName]);
     }
       Write(1);
   }
   catch(e) {
     Write(Stringify(e.message) + Stringify(e.description))
   }
</script>
   %%[
      SET @subscriberKey = AttributeValue('ContactKey')
      /* IS Triggered Products Parse */
      SET @triggerRecommendationJson = AttributeValue('Trigger_Catalog_Items')
      
    ]%%
    <script runat="server">
    Platform.Load("Core","1");
    
      try {
         var triggerCatalogItems = Platform.Variable.GetValue('@triggerRecommendationJson'); 
         var payloadObj = Platform.Function.ParseJSON(triggerCatalogItems);
         var numProductsTrigger = payloadObj.length;
         var subKey = Platform.Variable.GetValue('@subscriberKey'); 
    
         if(numProductsTrigger > 0) {
    
           var catalogItem = payloadObj[0]
           var productName = catalogItem.name
    
           Platform.Variable.SetValue('@productAvailableCount', numProductsTrigger);    
           Platform.Variable.SetValue('@productName', productName);  
    
           var rows = Platform.Function.UpsertData("audience for test push",["ContactKey"],[subKey],["productName"],[productName]);
         }
           Write(1);
       }
       catch(e) {
         Write(Stringify(e.message) + Stringify(e.description))
       }
    </script>

%%[ SET @subscriberKey = AttributeValue('ContactKey') /* IS Triggered Products Parse */ SET @triggerRecommendationJson = AttributeValue('Trigger_Catalog_Items')

]%%
<script runat="server">
Platform.Load("Core","1");

  try {
     var triggerCatalogItems = Platform.Variable.GetValue('@triggerRecommendationJson'); 
     var payloadObj = Platform.Function.ParseJSON(triggerCatalogItems);
     var numProductsTrigger = payloadObj.length;
     var subKey = Platform.Variable.GetValue('@subscriberKey'); 

     if(numProductsTrigger > 0) {

       var catalogItem = payloadObj[0]
       var productName = catalogItem.name

       Platform.Variable.SetValue('@productAvailableCount', numProductsTrigger);    
       Platform.Variable.SetValue('@productName', productName);  

       var rows = Platform.Function.UpsertData("audience for test push",["ContactKey"],[subKey],["productName"],[productName]);
     }
       Write(1);
   }
   catch(e) {
     Write(Stringify(e.message) + Stringify(e.description))
   }
</script>
   %%[
      SET @subscriberKey = AttributeValue('ContactKey')
      /* IS Triggered Products Parse */
      SET @triggerRecommendationJson = AttributeValue('Trigger_Catalog_Items')
      
    ]%%
    <script runat="server">
    Platform.Load("Core","1");
    
      try {
         var triggerCatalogItems = Platform.Variable.GetValue('@triggerRecommendationJson'); 
         var payloadObj = Platform.Function.ParseJSON(triggerCatalogItems);
         var numProductsTrigger = payloadObj.length;
         var subKey = Platform.Variable.GetValue('@subscriberKey'); 
    
         if(numProductsTrigger > 0) {
    
           var catalogItem = payloadObj[0]
           var productName = catalogItem.name
    
           Platform.Variable.SetValue('@productAvailableCount', numProductsTrigger);    
           Platform.Variable.SetValue('@productName', productName);  
    
           var rows = Platform.Function.UpsertData("audience for test push",["ContactKey"],[subKey],["productName"],[productName]);
         }
           Write(1);
       }
       catch(e) {
         Write(Stringify(e.message) + Stringify(e.description))
       }
    </script>
deleted 738 characters in body
Source Link

I must upsert data into a data extension with SSJS and AMPscript before sending a push notification in a JB. The best approach would be to create a custom activity but it will have to be for the future.

I'm wondering if is possible to create an email to upsert that data extension without it being sent?

ContactKey and Trigger_Catalog_Items are fields in 'audience for test push', the same I want to make the Upsert.

I've tried that approach from here with no success, sadly.

This is my script:

%%[ SET @subscriberKey = AttributeValue('ContactKey') /* IS Triggered Products Parse */ SET @triggerRecommendationJson = AttributeValue('Trigger_Catalog_Items')

]%%
<script runat="server">
Platform.Load("Core","1");

  try {
     var triggerCatalogItems = Platform.Variable.GetValue('@triggerRecommendationJson'); 
     var payloadObj = Platform.Function.ParseJSON(triggerCatalogItems);
     var numProductsTrigger = payloadObj.length;
     var subKey = Platform.Variable.GetValue('@subscriberKey'); 

     if(numProductsTrigger > 0) {

       var catalogItem = payloadObj[0]
       var productName = catalogItem.name

       Platform.Variable.SetValue('@productAvailableCount', numProductsTrigger);    
       Platform.Variable.SetValue('@productName', productName);  

       var rows = Platform.Function.UpsertData("audience for test push",["ContactKey"],[subKey],["productName"],[productName]);
     }
       Write(1);
   }
   catch(e) {
     Write(Stringify(e.message) + Stringify(e.description))
   }
</script>

Inner Exception when sending the email

"An error occurred when attempting to execute an UpsertData function call. See inner exception for details.""ExactTarget.OMM.FunctionExecutionException: An error occurred when attempting to execute an UpsertData function call. See inner exception for details.\r\n Error Code: OMM_FUNC_EXEC_ERROR\r\n - from Jint --> \r\n\r\n --- inner exception 1---\r\n\r\nExactTarget.OMM.FunctionExecutionException: UpsertData Function is not valid in content. This function is only allowed in a non batch context.\r\n Function: UpsertData(\"audience for test push\",1,\"ContactKey\",\"test-user\",\"productName\",\"product name\")\r\n Error Code: OMM_FUNC_CONTEXT_ERR\r\n - from OMMCommon\r\n\r\n\r\n\r\n"

Payload:

[
    {
        "price":79,
        "imageUrl":"image url",
        "name":"product name",
        "url":"url"
    }
]

enter image description here

Thanks

I must upsert data into a data extension with SSJS and AMPscript before sending a push notification in a JB. The best approach would be to create a custom activity but it will have to be for the future.

I'm wondering if is possible to create an email to upsert that data extension without it being sent?

ContactKey and Trigger_Catalog_Items are fields in 'audience for test push', the same I want to make the Upsert.

I've tried that approach from here with no success, sadly.

This is my script:

%%[ SET @subscriberKey = AttributeValue('ContactKey') /* IS Triggered Products Parse */ SET @triggerRecommendationJson = AttributeValue('Trigger_Catalog_Items')

]%%
<script runat="server">
Platform.Load("Core","1");

  try {
     var triggerCatalogItems = Platform.Variable.GetValue('@triggerRecommendationJson'); 
     var payloadObj = Platform.Function.ParseJSON(triggerCatalogItems);
     var numProductsTrigger = payloadObj.length;
     var subKey = Platform.Variable.GetValue('@subscriberKey'); 

     if(numProductsTrigger > 0) {

       var catalogItem = payloadObj[0]
       var productName = catalogItem.name

       Platform.Variable.SetValue('@productAvailableCount', numProductsTrigger);    
       Platform.Variable.SetValue('@productName', productName);  

       var rows = Platform.Function.UpsertData("audience for test push",["ContactKey"],[subKey],["productName"],[productName]);
     }
       Write(1);
   }
   catch(e) {
     Write(Stringify(e.message) + Stringify(e.description))
   }
</script>

Inner Exception when sending the email

"An error occurred when attempting to execute an UpsertData function call. See inner exception for details.""ExactTarget.OMM.FunctionExecutionException: An error occurred when attempting to execute an UpsertData function call. See inner exception for details.\r\n Error Code: OMM_FUNC_EXEC_ERROR\r\n - from Jint --> \r\n\r\n --- inner exception 1---\r\n\r\nExactTarget.OMM.FunctionExecutionException: UpsertData Function is not valid in content. This function is only allowed in a non batch context.\r\n Function: UpsertData(\"audience for test push\",1,\"ContactKey\",\"test-user\",\"productName\",\"product name\")\r\n Error Code: OMM_FUNC_CONTEXT_ERR\r\n - from OMMCommon\r\n\r\n\r\n\r\n"

Payload:

[
    {
        "price":79,
        "imageUrl":"image url",
        "name":"product name",
        "url":"url"
    }
]

enter image description here

Thanks

I must upsert data into a data extension with SSJS and AMPscript before sending a push notification in a JB. The best approach would be to create a custom activity but it will have to be for the future.

I'm wondering if is possible to create an email to upsert that data extension without it being sent?

ContactKey and Trigger_Catalog_Items are fields in 'audience for test push', the same I want to make the Upsert.

I've tried that approach from here with no success, sadly.

This is my script:

%%[ SET @subscriberKey = AttributeValue('ContactKey') /* IS Triggered Products Parse */ SET @triggerRecommendationJson = AttributeValue('Trigger_Catalog_Items')

]%%
<script runat="server">
Platform.Load("Core","1");

  try {
     var triggerCatalogItems = Platform.Variable.GetValue('@triggerRecommendationJson'); 
     var payloadObj = Platform.Function.ParseJSON(triggerCatalogItems);
     var numProductsTrigger = payloadObj.length;
     var subKey = Platform.Variable.GetValue('@subscriberKey'); 

     if(numProductsTrigger > 0) {

       var catalogItem = payloadObj[0]
       var productName = catalogItem.name

       Platform.Variable.SetValue('@productAvailableCount', numProductsTrigger);    
       Platform.Variable.SetValue('@productName', productName);  

       var rows = Platform.Function.UpsertData("audience for test push",["ContactKey"],[subKey],["productName"],[productName]);
     }
       Write(1);
   }
   catch(e) {
     Write(Stringify(e.message) + Stringify(e.description))
   }
</script>

Payload:

[
    {
        "price":79,
        "imageUrl":"image url",
        "name":"product name",
        "url":"url"
    }
]

enter image description here

Thanks

deleted 28 characters in body
Source Link

I must upsert data into a data extension with SSJS and AMPscript before sending a push notification in a JB. The best approach would be to create a custom activity but it will have to be for the future.

I'm wondering if is possible to create an email to upsert that data extension without it being sent?

ContactKey and Trigger_Catalog_Items are fields in 'audience for test push', the same I want to make the Upsert.

I've tried that approach from here with no success, sadly.

This is my script:

%%[ SET @subscriberKey = AttributeValue('ContactKey') /* IS Triggered Products Parse */ SET @triggerRecommendationJson = AttributeValue('Trigger_Catalog_Items')

]%%
<script runat="server">
Platform.Load("Core","1");

  try {
     var triggerCatalogItems = Platform.Variable.GetValue('@triggerRecommendationJson'); 
     var payloadObj = Platform.Function.ParseJSON(triggerCatalogItems);
     var numProductsTrigger = payloadObj.length;
     var subKey = Platform.Variable.GetValue('@subscriberKey'); 

     if(numProductsTrigger > 0) {

       var catalogItem = payloadObj[0]
       var productName = catalogItem.name

       Platform.Variable.SetValue('@productAvailableCount', numProductsTrigger);    
       Platform.Variable.SetValue('@productName', productName);  

       var rows = Platform.Function.UpsertData("audience for test push",["ContactKey"],[subKey],["productName"],[productName]);
     }
       Write(1);
   }
   catch(e) {
     Write(Stringify(e.message) + Stringify(e.description))
   }
</script>

Inner Exception when sending the email

"An error occurred when attempting to execute an UpsertData function call. See inner exception for details.""ExactTarget.OMM.FunctionExecutionException: An error occurred when attempting to execute an UpsertData function call. See inner exception for details.\r\n Error Code: OMM_FUNC_EXEC_ERROR\r\n - from Jint --> \r\n\r\n --- inner exception 1---\r\n\r\nExactTarget.OMM.FunctionExecutionException: UpsertData Function is not valid in content. This function is only allowed in a non batch context.\r\n Function: UpsertData(\"audience for test push\",1,\"ContactKey\",\"0033g00001TEWtRAAX\"\"test-user\",\"productName\",\"UO Mallory Cowl Neck Slip\"product Dress\"name\")\r\n Error Code: OMM_FUNC_CONTEXT_ERR\r\n - from OMMCommon\r\n\r\n\r\n\r\n"

Payload:

[
    {
        "price":79,
        "imageUrl":"image url",
        "name":"product name",
        "url":"url"
    }
]

enter image description here

Thanks

I must upsert data into a data extension with SSJS and AMPscript before sending a push notification in a JB. The best approach would be to create a custom activity but it will have to be for the future.

I'm wondering if is possible to create an email to upsert that data extension without it being sent?

ContactKey and Trigger_Catalog_Items are fields in 'audience for test push', the same I want to make the Upsert.

I've tried that approach from here with no success, sadly.

This is my script:

%%[ SET @subscriberKey = AttributeValue('ContactKey') /* IS Triggered Products Parse */ SET @triggerRecommendationJson = AttributeValue('Trigger_Catalog_Items')

]%%
<script runat="server">
Platform.Load("Core","1");

  try {
     var triggerCatalogItems = Platform.Variable.GetValue('@triggerRecommendationJson'); 
     var payloadObj = Platform.Function.ParseJSON(triggerCatalogItems);
     var numProductsTrigger = payloadObj.length;
     var subKey = Platform.Variable.GetValue('@subscriberKey'); 

     if(numProductsTrigger > 0) {

       var catalogItem = payloadObj[0]
       var productName = catalogItem.name

       Platform.Variable.SetValue('@productAvailableCount', numProductsTrigger);    
       Platform.Variable.SetValue('@productName', productName);  

       var rows = Platform.Function.UpsertData("audience for test push",["ContactKey"],[subKey],["productName"],[productName]);
     }
       Write(1);
   }
   catch(e) {
     Write(Stringify(e.message) + Stringify(e.description))
   }
</script>

Inner Exception when sending the email

"An error occurred when attempting to execute an UpsertData function call. See inner exception for details.""ExactTarget.OMM.FunctionExecutionException: An error occurred when attempting to execute an UpsertData function call. See inner exception for details.\r\n Error Code: OMM_FUNC_EXEC_ERROR\r\n - from Jint --> \r\n\r\n --- inner exception 1---\r\n\r\nExactTarget.OMM.FunctionExecutionException: UpsertData Function is not valid in content. This function is only allowed in a non batch context.\r\n Function: UpsertData(\"audience for test push\",1,\"ContactKey\",\"0033g00001TEWtRAAX\",\"productName\",\"UO Mallory Cowl Neck Slip Dress\")\r\n Error Code: OMM_FUNC_CONTEXT_ERR\r\n - from OMMCommon\r\n\r\n\r\n\r\n"

Payload:

[
    {
        "price":79,
        "imageUrl":"image url",
        "name":"product name",
        "url":"url"
    }
]

enter image description here

Thanks

I must upsert data into a data extension with SSJS and AMPscript before sending a push notification in a JB. The best approach would be to create a custom activity but it will have to be for the future.

I'm wondering if is possible to create an email to upsert that data extension without it being sent?

ContactKey and Trigger_Catalog_Items are fields in 'audience for test push', the same I want to make the Upsert.

I've tried that approach from here with no success, sadly.

This is my script:

%%[ SET @subscriberKey = AttributeValue('ContactKey') /* IS Triggered Products Parse */ SET @triggerRecommendationJson = AttributeValue('Trigger_Catalog_Items')

]%%
<script runat="server">
Platform.Load("Core","1");

  try {
     var triggerCatalogItems = Platform.Variable.GetValue('@triggerRecommendationJson'); 
     var payloadObj = Platform.Function.ParseJSON(triggerCatalogItems);
     var numProductsTrigger = payloadObj.length;
     var subKey = Platform.Variable.GetValue('@subscriberKey'); 

     if(numProductsTrigger > 0) {

       var catalogItem = payloadObj[0]
       var productName = catalogItem.name

       Platform.Variable.SetValue('@productAvailableCount', numProductsTrigger);    
       Platform.Variable.SetValue('@productName', productName);  

       var rows = Platform.Function.UpsertData("audience for test push",["ContactKey"],[subKey],["productName"],[productName]);
     }
       Write(1);
   }
   catch(e) {
     Write(Stringify(e.message) + Stringify(e.description))
   }
</script>

Inner Exception when sending the email

"An error occurred when attempting to execute an UpsertData function call. See inner exception for details.""ExactTarget.OMM.FunctionExecutionException: An error occurred when attempting to execute an UpsertData function call. See inner exception for details.\r\n Error Code: OMM_FUNC_EXEC_ERROR\r\n - from Jint --> \r\n\r\n --- inner exception 1---\r\n\r\nExactTarget.OMM.FunctionExecutionException: UpsertData Function is not valid in content. This function is only allowed in a non batch context.\r\n Function: UpsertData(\"audience for test push\",1,\"ContactKey\",\"test-user\",\"productName\",\"product name\")\r\n Error Code: OMM_FUNC_CONTEXT_ERR\r\n - from OMMCommon\r\n\r\n\r\n\r\n"

Payload:

[
    {
        "price":79,
        "imageUrl":"image url",
        "name":"product name",
        "url":"url"
    }
]

enter image description here

Thanks

added 768 characters in body
Source Link
Loading
added 142 characters in body
Source Link
Loading
added 116 characters in body
Source Link
Loading
edited body
Source Link
Loading
added 83 characters in body
Source Link
Loading
added 2 characters in body
Source Link
Loading
added 171 characters in body
Source Link
Loading
added 1092 characters in body
Source Link
Loading
Source Link
Loading