Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
0answers
9 views

Unable to Create Folder under Shared Data Extension from Parent BU through SSJS Script

I am trying to create a folder dynamically under "Shared Data Extensions" in Parent Business Unit using SSJS script. But it is throwing "Error adding folder." . Do we need to enable any special ...
4
votes
1answer
47 views

Using AMPscript/SSJS to unsubscribe from a parent business unit on a CloudPage from a child business unit?

If you click 'Unsubscribe from All' on the Subscriber in the Subscriber Properties modal in the parent business unit's context or when you perform an SSJS subscriber.Unsubscribe(); on a CloudPage on ...
0
votes
2answers
51 views

Help With Access Token for Server-to-Server Integrations Using SSJS

I am using the script below <script runat="server"> Platform.Load("core","1.1.1"); var client_id = Variable.GetValue("@ci"); var client_secret = Variable.GetValue("@...
2
votes
1answer
37 views

SSJS Error retrieving the automation activities of an automation

I'm trying to use SSJS to retrieve the automation activities of an automation, using this code: var api = new Script.Util.WSProxy(); var cols = ['Name', 'CustomerKey', 'AutomationTasks']; var ...
0
votes
1answer
37 views

SSJS Post request error

I'm trying to delete contacts based on DE. So far I'm testing the code on cloud page but eventually, it will be used as part of automation. I'm successfully retrieving a token but struggle to execute ...
7
votes
1answer
76 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. ...
1
vote
0answers
61 views

SSJS - Read a Data Extension after an Rows.Update

i'm now in my firsts baby steps in JavaScript on Salesforce Marketing Cloud. In my script i read one Data Extension with an DataExtension.Init("DE") and a DE.Rows.Retrieve(filter). After this, some ...
0
votes
2answers
44 views

Removing specific records from DE using SSJS script

I have a data extension that holds customer vouchers. I have different types of vouchers in that DE: WEL (welcome), BDY (Birthday) Because Birthday is a reoccurring event, i reissue Birthday ...
1
vote
1answer
45 views

How can I read a cookie via SSJS?

Is there a way to read cookie values via SSJS? setting works via Platform.Response.SetCookie(...);
1
vote
1answer
52 views

Create Filter Definition via WSProxy

I have hit a bit of a wall in this. I can create Filter Definitions via the SSJS function and via SSJS and AMPscript and SOAP API calls, but every time I try to create via WSProxy, I get the same ...
1
vote
1answer
41 views

Unable to retrieve email with WS Proxy and Email Retrieve Request

I am facing something that I can't understand. I try to retrieve all existing emails by using the WS Proxy utils but I always have an empty response. {"Status":"OK","RequestID":"cc1da13a-cee1-4aa6-...
1
vote
1answer
41 views

Marketing Cloud - Just trying to get record count of a Data Extension in SSJS

I followed part of the solution posted by @Gortonington here: How to improve this SSJS, but the following code does not reach the end of the DataExtension and unless I break, moreData always reads ...
1
vote
1answer
43 views

Getting an array column through WSProxy.retrieve

I'm using WSProxy to retrieve information about an Automation. This works fine, until I want to retrieve a column that is an array. To be exact, I would like to get the AutomationTasks for a certain ...
1
vote
0answers
33 views

Accessing contents of a file while trying to read uploaded file

I am trying to load and read a CSV file, but I want to iterate through the lines of a file in APEX rather that JS. The reason is that we expect the CSV files to be large and want to handle that job on ...
3
votes
2answers
81 views

Is there a way to identify all the places a Content Block is used?

I'm trying to identify all the places a Content Block is used. The goal is to be able to reference what will be affected if a Content Block is modified. I've looked a the Asset in the REST API, but I ...
3
votes
1answer
71 views

How to reference client-side input from a cloud page in SSJS

I have two microsite cloud pages: (1) to ask a user for the information, and (2) one that takes the information and uses it in a SSJS WSProxy call The first page captures information like: <form ...
2
votes
1answer
67 views

SSJS Create Data Extension with Retention

I'm using following SSJS script to create a Data Extension and set the retention of 7 days at row level: Platform.Load("core", "1.1"); var deObj = { "CustomerKey": "my_DE", "Name": "my DE", ...
0
votes
2answers
61 views

How to display Date (Format 'DD/MM/YYYY') in a single input type textbox in cloudpage

I'm trying to display a Date in a single input type textbox in Cloudpage, the data will be coming from Data Extension. I tried changing the type to date : <input type="date" name="...
1
vote
2answers
114 views

JSON call using SSJS to populate a dropdown list in HTML and pass it through using AMP

I have a JSON object full of County names and I want to call it using SSJS then populate a dropdown list in HTML using the Data from the JSON. JSON looks like this [ "AZ - Maricopa", "AZ - ...
2
votes
2answers
126 views

SSJS Rows.Update function not working with variable in FOR loop

I am trying to loop through all rows of a data extension and update the name of each record. I created an SSJS script activity to run the below code and it is not erroring out, but it is not updating ...
2
votes
1answer
53 views

Saving Server Side JavaScript Functions

Is it possible to create SSJS functions as code resources in Web Studio and then use those functions in other CloudPages or Script Activities? For example, if I created a function that generates an ...
1
vote
0answers
66 views

Insert a delay of a few seconds in SSJS script after a function call

Use case: Send emails based on personlization data of a few records using SSJS script. I have an email that will pull personlization data of off a non sendable Data Extension. The email will pull the ...
1
vote
3answers
73 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
0
votes
1answer
87 views

SystemDateToLocalDate inside SQL Automation

I know the function SystemDateToLocalDate is not available inside SQL but i would like exactly that feature inside an SQL query to convert the Date records of data_views (which are CST Central ...
0
votes
2answers
158 views

To Invoke Automation from SSJS

Is it possible to invoke automation from SSJS? We want to create Script Activity and based on some conditions wants to execute different automation? Can we do invoke automation using Script Activity?
0
votes
1answer
37 views

Running SFMC SSJS locally, not through SFMC

I'm developing SSJS scripts, I'm debugging connectivity issues between SFMC and 3rd party remote service. I can connect to it from my computer locally, but SFMC is having difficulties connecting. I ...
4
votes
1answer
53 views

SFMC Query 3rd party API through SSJS not on port 80 or 443

Trying to query a 3rd party API through a post request from a SSJS script. However, I get the following error: System.Net.Sockets.SocketException: A connection attempt failed because the connected ...
1
vote
0answers
27 views

Deleting User Roles Using SSJS in Marketing Cloud

I am trying to delete the user roles and permissions using SSJS (payload) in Marketing Cloud. I was able to add and update the roles, but I don't know if i can delete the roles. I was successful in ...
0
votes
1answer
226 views

SFMC - SSJS Bulk update to All Subscribers list

I would like to automate the process of updating statuses, emails and from names in All Subscribers list, but I would like to avoid using export/import or any AMPscript sitting outside of the ...
1
vote
1answer
55 views

Making soap api call from ssjs to create salesforce account record

I am trying to make a SOAP call to create new accounts and update campaign members in our sandbox salesforce crm from Marketing cloud landing page under webstudio When I publish it, I am getting ...
0
votes
1answer
135 views

Update Salesforce object with a Script Activity

I would like to create a script activity in an automation to update a Salesforce Object. Here is my example script. How can i update I get it accepted as A SSJS script in the Script Activity? %%[ ...
0
votes
1answer
57 views

How to add field to a DE using SSJS in SFMC

I have a DE called "My Demo DE" and the customer key for it is "demoDE". Now i want to add a new field to this existing DE.It my SSJS code is not adding the Field to the DE. <script runat="server"...
0
votes
0answers
100 views

Extracting the send context Data Extension fields using SSJS

I am trying to extract the send context Data Extension from an email thats being sent by placing the following code in the email itself: <script runat="server"> Platform.Load("Core", "1.1.1"); ...
2
votes
1answer
105 views

Using GTL to Display Data from Nested JSON Arrays

I am building an email using data passed through JSON. Here is an example of the JSON file: { "order": { "items": [ { *Other Data*, "tracking": [ { **"...
0
votes
1answer
75 views

Return all SSJS property value pairs for object?

I'm looking for one of two things. A complete reference guide for all SFMC SSJS objects, or A way to return all contents of an object so I can see what I need to use. For an example, I've been ...
-1
votes
1answer
59 views

Set User and Attributes - Marketing Cloud

I have implemented the following base collect code: <script type="text/javascript" src="//MID.collect.igodigital.com/collect.js"></script> <script> _etmc.push(["setOrgId", "MID"])...
0
votes
1answer
249 views

Marketing Cloud SSJS: trying to automate contact deletion

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 ...
0
votes
1answer
45 views

How to give status of triggered send back as reply on api call to landing page?

I have a cloud page that a customer accesses via an api call (do not know what kind). The call holds an email address at a time. The landing page picks up the email address, does some other stuff and ...
0
votes
1answer
51 views

Fields.Retrieve() doesn't display anything

I would like to retrieve the header of a data extension using SSJS within my Landing Page. Below is my code : <script language="javascript" runat="server"> Platform.Load("Core", "1"); ...
1
vote
1answer
75 views

Get current location with ampscript or ssjs

I have functionality on a cloud page that depends on the cloud page url. I know how to Requestparameter(), but how do I get the entire url using ampscript or SSJS?
0
votes
1answer
85 views

How to use a SFMC SJS Script Activity to pull data with httpget and then store it in a Data Extension?

I have figured out how to use HttpGet to display JSON directly in an email body, but instead I want to store this JSON data from an external URL in a data extension, and then use AMPscript lookups to ...
0
votes
3answers
99 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"> ...
0
votes
2answers
49 views

Retrieve Email's Text Version or Body Content

Does anyone know if there is a way to retrieve email body content without HTML tags? Or text version (plain text) of the email? The case is we need to log it in Data Extension created to track Email ...
2
votes
1answer
131 views

Can I use AmpScript to set Subscriber Status in Marketing Cloud?

A prior developer built our microsite preference center using ampscript to grab user info from SalesForce and update the Contact/Lead info depending on the user's answers. In the case where a User ...
0
votes
1answer
234 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 ...
2
votes
1answer
96 views

Update Data Extension via WSProxy

I've built a CloudPage which runs SQL queries quickly without having to use automation studio. The SSJS that runs the query works perfectly, but I'm also trying to use this function to also update a ...
0
votes
0answers
102 views

SSJS Data extension creation error

I was trying to create a data extension based on the value that i get from the sync de. Could anyone tel me what exactly the issue is, in my code. When i try to run this in the automation studio ...
0
votes
1answer
198 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 = ...
3
votes
1answer
96 views

How to translate the cloud pages based on the browser language in salesforce marketing cloud

I have been working in custom preference centre and one of the requirement is to translate the page based on the browser language. The difficulty here is detecting the browser language "Navigator....
0
votes
1answer
108 views

Storing JSON reply payload object in Data Extension

I'm successfully getting a result from an HTTP.Post call. My reply comes in a form of a JSON and looks something like this: { "Result": { "Message": "", "MessageDetails": "", "Status": 1 ...