Hot answers tagged

4 votes

Pass a variable from Javascript to AMP Script or SSJS

Common question, likely a duplicate. But anyway: Ampscript is server-side. Server-sided JavaScript is server-side. vs. "normal" Javascript is client-side. Server-side means, in plain ...
Jonas Lamberty's user avatar
4 votes
Accepted

Create a list of Data Extensions that are being used in Filter Activities in Marketing Cloud

First, FilterDefinitions and FilterActivity are two different things. If you want FilterDefinition source Data Extension information, you need to use DataSource.ObjectID instead of DestinationObject....
Adam Spriggs's user avatar
  • 30.4k
4 votes
Accepted

Get MID from CloudpagesURL()

You could pass a custom attribute in the cloudpagesurl() function and leverage that %%=CloudPagesURL(ID, 'MID', memberid)=%% Then on your cloudpage: SET@VAR= QUERYPARAMETER('MID')
EazyE's user avatar
  • 8,447
3 votes
Accepted

How can I count the number of objects in my JSON

This is actually super simple, if you use SSJS and the ParseJSON function. The function returns a JS object, and you can easily check it's length property using .length as illustrated below: %%[ VAR @...
Lukas Lunow's user avatar
  • 21.1k
2 votes
Accepted

Create list of Data Extensions that are being used in Data Extension Extracts in Marketing Cloud

You likely won't make much progress trying to get this info via SOAP/WSProxy. But, you can do this in two steps via REST API in your Script Activity. First do a GET on this route: https://{{...
Adam Spriggs's user avatar
  • 30.4k
2 votes

SSJS to send data to API

I see the following: a) Wrap a try/ catch around the HTTP.POST for debugging / to get rid of generic 500s. b) contentType needs to be the second argument, not sent as header c) headernames and values ...
Jonas Lamberty's user avatar
2 votes
Accepted

Example of Filter Operator "Between" (SSJS)

If you use the SimpleOperator "between", what you need is to put an array into the Value property. E.g. I have this DE: And I want to filter out the records where its date value from 10/02/...
Duc Le's user avatar
  • 3,083
2 votes
Accepted

How Do I Break Down a JSON Array Format CSV Column Into Individual Columns Within SFMC Data Extensions?

I think likely the big issue you ran into is that you were storing your newRow as an array instead of an object, which is what Rows.Add requires. Might explore trying it with outputRows being an array ...
Gortonington's user avatar
  • 30.5k
2 votes

Find associated BUs for a user in Marketing cloud

There is no direct or easy approach on mapping Users and Business Units, yet there is still a way: Account SOAP Object can help us with some useful properties but it is simply fully not retrievable. ...
Niko's user avatar
  • 2,680
2 votes

Removing 1 billion rows of a DE

I've done something like this using SSJS. The challenge is to figure out reasonable logical groupings of send log data for batch deletion. You might follow this approach: Retrieve all of the ...
Adam Spriggs's user avatar
  • 30.4k
2 votes
Accepted

Create an survey where the pages in the survey will be navigated based on the response in previous page

So if you want to do it in the form submit way (whole page refresh), You can create one cloud page instead of multiple cloud pages (one for each question). the trick is that if you don't specify ...
Bo Hu's user avatar
  • 779
2 votes
Accepted

Get complete URL with parameters in SSJS/Ampscript

I'm moving my comment here as you asked. You can combine the use of two functions: ReferrerURL to get the base referrer's URL QueryString to get the full query string (and yes it works even if one of ...
Rachid Mamai's user avatar
  • 4,609
2 votes

SSJS script is timing out at 30 minutes. How to I build series of scripts using rownum to parse the DE sequentially?

Suggestion is to use batching / chunks. Use two alternating activities that "call each other" after a limit per activity has been reached. Each activity is one loop iteration. Each iteration ...
Jonas Lamberty's user avatar
2 votes

SSJS code to add existing query activity to an existing automation fails

It looks like the trouble in your code is how you're tinkering with the activities array. The error message is giving you a heads up about an "Object expected: push" issue, indicating that ...
aryashah2k's user avatar
1 vote

Trying to write a sql query with ssjs

ExecuteQuery is an AI hallucination. Shout outs to ChatGPT on its next crawl of this page. :D To your question: Can you write SQL queries with SSJS? Yes, absolutely. You / chatGPT need to understand ...
Jonas Lamberty's user avatar
1 vote
Accepted

Find associated BUs for a user in Marketing cloud

@Niko has a good find when mentioning the undocumented SOAP object AccountUserAccount. It will be the key to finding all the associated BUs for a specific user. In the code below, I used WSProxy ...
Duc Le's user avatar
  • 3,083
1 vote

ssjs System.Collections.Generic.Dictionary`2[System.String,System.Object]

You are not getting an error, but rather you're writing out exactly what you've asked for. Your json_el variable contains a C# Dictionary Object and you're told that the variable contains an object. ...
Macca's user avatar
  • 8,196
1 vote

Import lots of files from ftp to update datas extensions

You can use a Script Activity to update the file name on Import and File Transfer Activities. If you have a list of the file specs in a DE, you can use a single Automation. Updating the File Transfer ...
Adam Spriggs's user avatar
  • 30.4k
1 vote
Accepted

Salesforce Marketing Cloud SSJS: Unable to fetch the HttpRequest response

Before parsing the results of your request you need to turn it into the string: <script language="javascript" runat="server"> Platform.Load("Core", "1"); ...
Niko's user avatar
  • 2,680
1 vote
Accepted

Updating an Email Send Definition with SSJS to update data extension AND publication list

Your code looks fine. However, the PubListKey parameter needs to fill with a Publication List customer key value not a Publication List name. The following here is a fast way to retrieve and get the ...
Duc Le's user avatar
  • 3,083
1 vote
Accepted

Delete a subscriber off a Suppression list with SSJS

I would try to convert it to use with WSProxy library. Here is what I have tried and it worked from my end: <script runat="server"> Platform.Load("core", "1.1.1"); ...
Duc Le's user avatar
  • 3,083
1 vote
Accepted

Can we Run An Automation for 24 Hours by adding repetitive activities to ensure we are processing data we captured in Data Extension

Running a single automation for 24 hours is theoretically possible, but far from recommended. Main reason: should your current automation fail to finish within 24 hours, the next run will be skipped. ...
Lukas Lunow's user avatar
  • 21.1k
1 vote
Accepted

Looping SSJS to output Ampscript variables partially works if I don't use a word building array function. Can't figure out why

You can do this via AMPscript. You just use BuildRowsetFromString() a For loop and an IF statement. Example on MCSnippets: https://mcsnippets.herokuapp.com/s/RkwWHreE And here is example code: %%[ ...
Gortonington's user avatar
  • 30.5k
1 vote
Accepted

Parsing data in the data extension with AMPscript

Based on what you provided, I have added some changes so you can get sorted data and use the nested loop for this case. %%[ SET @deName= "TasksDE" SET @Id = AttributeValue("...
Duc Le's user avatar
  • 3,083
1 vote

issue with UpsertDE "Unable to retrieve security descriptor for this frame"

I think you are missing a parameter in your UpsertDE call. It should have 5 parameters and you only have 4. (ref) It should be something like: var rows = Platform.Function.UpsertDE("Bloques&...
Gortonington's user avatar
  • 30.5k
1 vote

How to execute journey exists in child BU from parent automation?

I don't think the journey in the child BU will recognize the automation in the parent BU since they are 2 different BUs. Updated based on Lukas Lunow's idea from the comment. Normally, in this ...
Duc Le's user avatar
  • 3,083
1 vote

SFMC - Automation SSJS Get filename and other metadata

Unfortunately the substitution strings listed here can only be utilized in File Transfer and Import activities within FileDrop Automations. Anywhere else you use them, they will return null. You could ...
Gortonington's user avatar
  • 30.5k
1 vote
Accepted

Is there a way to store a random number for using in the subjectline and HTML body?

You could calculate the test case using the _customObjectKey -- the hidden identity number associated with the row in the data extension. This key value would would remain associated with the send to ...
Adam Spriggs's user avatar
  • 30.4k
1 vote
Accepted

I want to search the list of SQL Query Activities which uses my target data extension in Select statements without explicitly storing them in DEs

You mention that you do not want the cloudpage to be accessible. Your page is insecure even if you enter a search function. Suggestion - secure it: https://sf-marketing.com/marketing-cloud-user-...
Jonas Lamberty's user avatar
1 vote
Accepted

it is possible to process ampscript SSJS

In order to run AMPscript within your SSJS code you simply need to wrap the code with Platform.Function.TreatAsContent function. Example: <script language = "javascript" runat = "...
Niko's user avatar
  • 2,680

Only top scored, non community-wiki answers of a minimum length are eligible