Questions tagged [ssjs]

Server-side JavaScript (SSJS) in the Salesforce Marketing Cloud allows a developer to use JavaScript syntax and proprietary platform libraries for server-side processing.

Filter by
Sorted by
Tagged with
2 votes
1 answer
11k views

Trying to automate contact deletion with SSJS

with the GDPR laws in place, it's important to have the possibility to remove contacts from Marketing Cloud. I'm trying to automate the process with existing tools and am looking for possible ...
Rafał Wolsztyniak's user avatar
7 votes
2 answers
13k views

REST API Methods in AMPScript or SSJS

Is there any way via AMPScript or SSJS to utilize HTTP methods outside of GET and POST? I have had no problem utilizing these two via the HTTPPost() and HTTPGet() functions, but have not found any ...
Gortonington's user avatar
  • 30.3k
4 votes
3 answers
10k views

Using AMPscript with SSJS Activities

I have tried using the below AMPscript block in an SSJS Activity, however it appears that Script activities only support SSJS and AMPscript cannot be included in Script Activities — please can someone ...
Eliot Harper's user avatar
  • 16.3k
0 votes
1 answer
3k views

Parse XML in Server Side Javascript

Is there a way to parse XML in SSJS. I have an RSS Feed that comes as XML in the response, is there a way I can parse the field and store them in a Data Extension, using SSJS. I have tried standard ...
Sanchit Mittal's user avatar
5 votes
1 answer
9k views

Making a REST API call from a Script Activity in Automation Studio

We are trying to update a service cloud custom object from marketing cloud. Can we make a REST api call within a script in Automation Studio.It will be great if someone in this forum can confirm they ...
Monomit Bhowmik's user avatar
2 votes
1 answer
3k views

Making SOAP Calls via SSJS

I am trying to make a SOAP call following from the answer here : Server-Side Javascript calling SOAP API I am running this on a cloud page. When I publish it, it doesnt render (harbinger or bad ...
0xsegfault's user avatar
  • 6,553
1 vote
1 answer
10k views

Date manipulation Function SSJS

I want to delete the records from Data Extension based on Date Field in my DE i.e. I want to delete record which were created date before 30 days.But I didn't find date manipulation function in SSJS ...
Prateek Nara's user avatar
1 vote
2 answers
3k views

Get current location with AMPscript or SSJS

I have functionality on a cloud page that depends on the CloudPage URL. I know how to Requestparameter(), but how do I get the entire URL using AMPscript or SSJS?
Tove's user avatar
  • 123
0 votes
2 answers
2k views

Getting Error while try to get Salesforce OAuth access token from SFMC cloudpages ssjs httppost?

Actually I try to get access token of salesforce DC from salesforce MC by SSJS Httppost I need to create a record in salesforce object From Salesforce marketing cloud pages <!doctype html> &...
Karuppasamy's user avatar
10 votes
1 answer
2k views

Using AMPscript/SSJS how do you unsubscribe a subscriber from a child business unit?

My goal is to create a page that passes a business unit id and a subscriber key. The page sits on the parent/enterprise business unit, it will receive business unit ids from a child business unit. ...
Rick Locke's user avatar
2 votes
3 answers
2k views

How can I obtain the status of an automation in a Business Unit using AMPscript?

I am attempting to retrieve the status of an automation in a Business Unit with the following AMPscript, but I haven't been successful yet. Could someone please assist? %%[ SET @key = "###" SET @...
Christopher Carswell's user avatar
1 vote
1 answer
3k views

Server-Side Javascript calling SOAP API

Does anyone see why this SOAP Request would return a 500 Internal Server Error? If I just pull out the payload test and run it in SOAP UI I get a correct response? <script language="javascript" ...
victorcorey's user avatar
  • 1,808
1 vote
1 answer
6k views

Using AMPscript in a Script Activity

We need to update a record in Salesforce using a Script Activity within an Automation. Ideally, I would like to use the AMPscript UpdateSingleSalesforceObject() function to achieve this as there is no ...
Eliot Harper's user avatar
  • 16.3k
1 vote
1 answer
6k views

SSJS Retrieve DataExtension Rows by RetrieveRequest

Is it possible to retrieve all rows for a DataExtension with a RetrieveRequest? I'm blocking by 2500 max-retrieve function restriction. My cloudpage blocked, when I repeat two or three times this ...
MrViSiOn's user avatar
  • 171
1 vote
1 answer
1k views

Always 2500 rows found in the filter

I am using the following script (in Automation Studio as a Script Activity) to remove all the rows of the last 30 days from a DE. The automation is run daily. I log errors and messages in a DE called ...
Disasterkid's user avatar
1 vote
1 answer
4k views

SSJS to save data into a data extension

I am really new to SSJS but what I am trying to achieve is to pass some parameters in the URL from an email and capture them in the cloud page and then save that data into a DE using SSJS. At the ...
Wallace's user avatar
  • 341
0 votes
1 answer
7k views

SSJS HTTP.Post throws error instead of returning status code

I am banging my head against the HTTP.Post function. The documentation says: Performs an HTTP POST using the provided information against the passed URL. The function returns a JSON object ...
shd.lux's user avatar
  • 466
0 votes
1 answer
5k views

Error Handing in Ampscript

I have used Server side javascript with a mix of ampscript to handle the error but the issue is even for the correct syntax the page is being redirected to error. When i remove the SSJS exception ...
Abhishek's user avatar
  • 726
0 votes
1 answer
480 views

How to refer Javascript cloud page in my email in content builder?

I have a Javascript file written and saved in Cloud Page. Now,I want to refer this Javascript file from Cloud page inside my email in Content Builder. The reason why I am following this approach is ...
Sourab Mund's user avatar
0 votes
3 answers
2k views

Clearing a Data Extension using SSJS with SOAP

I am using the below SSJS to clear out a data extension. It works well in the Parent BU but when I run it in a Child Business Unit it fails <script language="javascript" runat="server"> ...
Maneesh's user avatar
  • 2,164
6 votes
2 answers
2k views

Are there any external call out limits in Marketing Cloud?

I would like to run an SSJS script which makes callouts to a third party system (which sends WhatsApp messages). As this action will happen frequently I would like to know if there are any limits I ...
Deployment Failure's user avatar
5 votes
1 answer
2k views

Identify the Type of an Automation Activity using SSJS WSProxy

I'm trying to create an API call that will return the SQL Code from all Query Activities within an given Automation. Using the information provided in this question Retrieve multiple tasks in an ...
Cameron Robert's user avatar
4 votes
2 answers
2k views

Accessing SSJS variables and functions from a Content Block

I'm trying to figure out a way to inject SSJS code in a CloudPage instead of having to copy and paste each time. That is, I have a library of functions that I want to manage centrally and include in ...
Eliot Harper's user avatar
  • 16.3k
3 votes
1 answer
1k views

Connect SMFC to Github

Has anyone had any success connecting things like content builder or cloud pages to GitHub? I have been searching far and wide and have come across this amazing repository that almost does what I need ...
Nate Harris's user avatar
3 votes
1 answer
1k views

Update Data Extension Field to NULL using WSProxy

I'm trying out the new WSProxy API for server-side javascript. I haven't been able to update a Data Extension field to NULL when it already contains a value. Let's say "Student" is a nullable field. ...
Billk's user avatar
  • 31
3 votes
1 answer
2k views

How to set a cookie using SSJS?

This question relates to: Is it possible to add http headers. for example set-cookie, via ampscript or ssjs in ExactTarget? The answer on that question does not specifically call out how to set a ...
Daniel's user avatar
  • 1,257
2 votes
1 answer
3k views

Landing Page post to itself and run SSJS

i found a great blog post by Adam Spriggs https://sprignaturemoves.com/prune-rows-data-extension-ssjs/ He mentioned to execute this function be built a landing page that posts to itself and calls ...
AndrewC's user avatar
  • 301
2 votes
2 answers
941 views

SSJS OAuth 2 Support?

I'm trying to obtain an OAuth 2 token through SSJS and getting a 400 error. Here's the code I'm using: <script type="javascript" runat="server"> Platform.Load("Core", "1.1.5"); var ...
Mark P's user avatar
  • 430
2 votes
2 answers
1k views

SSJS Activities : Move Data Extentions in a Folder

I'm investigating the SSJS activities. I'm not a JavaScript programmer but I'm trying to learn. Now I have managed to create Date Extension, a Create a folder path. Now I would like to be able to ...
R.Pruner's user avatar
2 votes
1 answer
4k views

SSJS to call Content Block with AMPscript

Use case: Through automation studio, a script activity is use to call and reference a content area through the "ContentAreaByName" function. That content area contains AMPscript that performs specific ...
AnonWonderer's user avatar
  • 2,113
2 votes
1 answer
1k views

POSTing multipart/form-data payloads with SSJS

I'm trying to use an SSJS script activity to upload a CSV file. Specifically, I'm using the Pardot Import API to create new Prospects. I'm stuck on the add batch part. This requires the Content-Type ...
Eliot Harper's user avatar
  • 16.3k
1 vote
1 answer
2k views

Retrieve more than 2500 records from a DE using SSJS

Trying to retrieve more than 2500 records from a DE. My thought is to have a for loop (to process the recordset) within a while loop (to retrieve records). var data; var recordCount = 0; do { ...
victorcorey's user avatar
  • 1,808
1 vote
2 answers
5k views

SSJS Landing Page access POST JSON Request payload

I would like to POST to an SFMC SSJS Landing page using AJAX. Is there any way to access the POST JSON Request Payload using SSJS in the Landing page?
MIL's user avatar
  • 128
1 vote
1 answer
887 views

SSJS RegExp.exec() works different - why?

Once again, I try to understand why SSJS in SFMC is acting differently compared to JS. Based on the following sample: RegExp.prototype.exec() SSJS Example: <script runat=server> var str = '...
shd.lux's user avatar
  • 466
1 vote
3 answers
816 views

Changing Unsubscribe reason through SSJS

I noticed that you can unsubscribe a user through SSJS, is it possible to use SSJS to change the unsubscribe reason? I notice that doing it through the API seems to be popular? why is that? Thanks
mercifulhop's user avatar
0 votes
1 answer
2k views

Creating Query Definition with SSJS

I am trying to create Query Definition using SSJS but its not working for me. my code as follows: <script runat="server"> Platform.Load("Core","1.1"); var queryDef = { Name : "Example ...
Referee_Mark's user avatar
0 votes
2 answers
4k views

how to update status active or Unsubcribed of subscriber in _ListSubscribers

I'm trying to do it this way, but I'm getting 500 error %%[ var @SubscriberKey, @ListID, @ListType set @SubscriberKey = "example" set @ListID= 123 SET @ListType= "Publication List&...
Jefersson Gomez's user avatar
0 votes
1 answer
771 views

can we generate hmac in SSJS Marketing cloud

I am trying to find SSJS function in marketing cloud. is there any way to generate hmac sha256 in server side javascript in marketing cloud ? does SSJS has any equivalent to CryptoJS.HmacSHA256(, ) ? ...
hemant's user avatar
  • 11
0 votes
2 answers
2k views

AMPScript for loop and SSJS

As the subject says, I would like to use two line of SSJS code in a for loop like in the example: VAR @listAddress, @nameChosen, @Counter, @i, @AddressRow, SET @listAddress = ...
Federico Amici's user avatar
0 votes
1 answer
1k views

How to increase Pagesize of REST API call response using SSJS in Cloudpage

I am using REST API call to get history data. For this I am writing SSJS in Cloud page and am trying to store the data in a data extension. The result of REST API call is more than 100 records. But by ...
Harry's user avatar
  • 1
14 votes
0 answers
1k views

WSProxy setClientId in Child BU does not allow execute at Parent BU

In SF Marketing Cloud, I'm trying to update a subscriber at the Parent BU Level from my SSJS in the Child BU. I created a Cloud Page at the Child BU to run the following code in order to debug faster....
Bechir's user avatar
  • 516
5 votes
1 answer
2k views

Failure to retrieve list subscriber attributes in a landing page using AMPScript and SSJS

ExactTarget is core edition. There are no Data Extensions, so we use Lists. Am using landing page and trying to retrieve all the subscribers attributes of the List from SSJS and AMPScript but failed ...
Jack85's user avatar
  • 489
4 votes
2 answers
11k views

Retrieving and Displaying the records from a data Extension using SSJS or WSProxy

I am new to SSJS/WSProxy. Any idea, how you can see the retrieved records from data Extension and put them in an Array. Question 1: Also What are the different methods to see the results in SSJS or ...
tanvi's user avatar
  • 51
4 votes
1 answer
4k views

Can you retrieve more than 2500 records with SSJS?

I am trying to use a script activity to update a data extension with the statuses of subscriber records. I have managed to get the code working but it will only add 2500 records. I have been reading ...
wimpywombat's user avatar
3 votes
2 answers
3k views

How to resubscribe a user in Marketing cloud using SSJS?

I have unsubscribed users using logunusbevent call in a custom unsubscribe landing pages. However, I couldn't resubscribe them again if they check the resubscribe checkbox, below are the codes that I ...
Manoj Chandran's user avatar
3 votes
2 answers
1k views

Setting a function to run at set intervals in a Landing Page in SSJS

I would like to run the following HTTP.GET function at a set interval (every 1 minute) until 10 minutes have passed or it has succeeded in retrieving the content. var contentRetriever = function(){ ...
Christopher Carswell's user avatar
3 votes
1 answer
3k views

Is it possible to call external SOAP/REST API in ExactTarget?

Is it possible to call external SOAP/REST API in ExactTarget? I want to call external SOAP/REST API in landing page and need to use SSJS. I tried to search in ExactTarget wiki but didn't get any ...
Palash Rai's user avatar
  • 1,824
3 votes
1 answer
4k views

ParseJSON using SSJS

I am unable to extract msg from the JSON response. @returnCode works fine and I am passing it to SSJS, but then I cannot get the msg value. <script runat="server" language="javascript"> ...
zuzannamj's user avatar
  • 14.3k
3 votes
1 answer
3k views

Can we generate PDF in ExactTarget?

I want to generate PDF document on the basis of data available in my customer DataExtension and print it in proper format so that it can be sent to customer by a email. is there any AmpScript, SSJS, ...
Palash Rai's user avatar
  • 1,824
3 votes
1 answer
1k views

Is it possible to perform HMAC SHA1 encoding with Ampscript?

Is it possible to do this with Ampscript? Is it possible to achieve this with SSJS? I understand there is an apex function that can do this, but I am not sure it is possible to use apex with ...
legoMyEgo's user avatar
  • 203