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
2answers
30 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="...
0
votes
2answers
77 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
1answer
66 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
37 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
38 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
47 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
35 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
68 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
29 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
40 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 ...
0
votes
0answers
14 views

Deleting UESER Roles Using SSJS in Marketing Cloud

I am trying to delete the user roles and permissions using SSJS(playload) in marketing cloud,I was able to add and update the roles,but I dont know if i can delete the roles. I was successful in ...
0
votes
1answer
95 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
36 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
62 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
34 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
47 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
57 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
40 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
39 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
147 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
39 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
42 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
42 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
56 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
66 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
41 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
81 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
138 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 ...
1
vote
1answer
53 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
71 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
104 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
68 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
79 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 ...
1
vote
1answer
33 views

Marketing cloud - SSJS - Truncate Sendable DE

I have a sendable DE which i am trying to truncate . however its erroring out. The code for ssjs is <script runat="server"> Platform.Load("core", "1.1.1"); var rows = Platform....
8
votes
1answer
107 views

Handing REST API POST Exceptions using SSJS Try-Catch on a Landing Page Form Submission with AMPSCRIPT

I have an issue with a landing page containing a webform that submits input from the user and using AMPSCRIPT I make a Rest API call using the HTTPPost2 function to utilize the validateEmail resource. ...
0
votes
1answer
87 views

SSJS Rows.Lookup with multiple criteria

I want to perform lookup search with multiple criteria applied. The below code works with one condition, but I have not found the solution to add conditions. Are there any solutions for that beyond ...
0
votes
1answer
88 views

Get and format system time with SSJS [duplicate]

How do I get current Marketing Cloud system time, usng SSJS on a cloud page. This is the format I need: 11/8/2018 14:16:54 Ideas?
1
vote
1answer
51 views

Fetching more than 2500 records returning null for everything but correct amount of records

So I am attempting to write code that returns more than 2500 records so that I can use the data for display on the page (I know this will be slow but it is business' requirement). There are currently ...
5
votes
1answer
142 views

Error adding EmailSendDefinition using SSJS

Using the documentation in the SF Help docs I am trying to create send an email to a specific person using the following code: <script type="text/javascript" runat="server"> try { ...
0
votes
2answers
33 views

Improve update query SSJS block to report errors

I've just managed to make a landing page where you can enter the target data extension, update type, and query definition of a query you want to run, press submit, and run it. It uses the following ...
1
vote
1answer
69 views

Get value of URL hash using SSJS in Marketing Cloud

Is there a way to return the full URL -- including any hash values using Server-Side JavaScript in a Landing/Cloud Page in Marketing Cloud ? If the incoming URL to my page is: https://pages.email-...
3
votes
1answer
56 views

What's the different between the core versions in SSJS?

I wrote a number of SSJS before, but a question that just can't sort it out: the core version. From the official document: it said: Given that the Core library has 1, 1.1, 1.2 and 2.0 versions, ...
2
votes
1answer
170 views

Using SSJS to send single email in Marketing Cloud

Is it possible to send a single email to a Subscriber rather than a whole List using the SSJS Send Mail function? My code is as follows, you can see we have to provide a List ID to send to. <...
1
vote
0answers
118 views

What's wrong with this “HTTP.Get” in SSJS?

In activities I am running this script: <script runat="server"> Platform.Load("Core", "1.1.1") var NewReq = HTTP.Get("http://samplesite.com/sample.html"); </script> It always throws ...
0
votes
0answers
28 views

Email Preview using REST API [duplicate]

I have written a SSJS code to preview the rendered email. <script runat="server"> Platform.Load("core", "1"); var url = 'https://auth.exacttargetapis.com/v1/requestToken'; ...
1
vote
2answers
64 views

SSJS Error - Retrieving data from two DataExtensions and want to update the initial DataExtension

Anybody an idea what is wrong with this script? It is my first SSJS script in the automation studio but I just get the error message: An error has occured. I got the functions from the documentary. ...
2
votes
0answers
84 views

Getting Error while try to trigger API event in Journey From Landing pages using ssjs?

I'm working on to trigger API event in journey/Journey builder from landing pages. For now, I can able to get accessToken using clientId & clientSecret and then I tried to pass subscriberkey & ...
0
votes
1answer
111 views

SSJS : Parsing URL from JSON

I have a CloudPage form which contains a Select Dropdown with a JSON-esque Value: <select id="Select_Specialism" name="Select_Specialism" required=""><option value="">Select Specialism<...
0
votes
1answer
34 views

Get ListID of a Subscriber's Publication List programatically?

Is it possible to get subscriber's ListID of a Publication List? A retrieve from _Unsubscribes gives me only AllSubscribers listID. I've tried every API from MC, I can't get that ListID. set @rows =...
0
votes
1answer
47 views

Best practice - Really complex email - use TreatAsContent()?

I am working on an email that is very very complex with tons of ampscript and SSJS covering for a lot of different scenarios. The amount of code is still increasing as we go and it holds calls to both ...