ssjs-data 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -2
- package/src/index.js +166 -7
package/package.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ssjs-data",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Canonical SSJS (Server-Side JavaScript) function catalog, Core library objects, Platform methods, and globals for SFMC tooling",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./src/index.js"
|
|
9
9
|
},
|
|
10
|
-
"files": [
|
|
10
|
+
"files": [
|
|
11
|
+
"src"
|
|
12
|
+
],
|
|
11
13
|
"repository": {
|
|
12
14
|
"type": "git",
|
|
13
15
|
"url": "git+https://github.com/JoernBerkefeld/ssjs-data.git"
|
|
@@ -27,6 +29,9 @@
|
|
|
27
29
|
"platform-functions"
|
|
28
30
|
],
|
|
29
31
|
"license": "MIT",
|
|
32
|
+
"scripts": {
|
|
33
|
+
"test": "echo No tests defined"
|
|
34
|
+
},
|
|
30
35
|
"engines": {
|
|
31
36
|
"node": ">=18.0.0"
|
|
32
37
|
}
|
package/src/index.js
CHANGED
|
@@ -60,6 +60,7 @@ export const SSJS_GLOBALS = [
|
|
|
60
60
|
params: [{ name: 'customerKey', description: 'Customer key of the Content Builder asset', type: 'string' }],
|
|
61
61
|
returnType: 'string',
|
|
62
62
|
syntax: 'ContentBlockByKey(customerKey)',
|
|
63
|
+
example: 'var html = ContentBlockByKey("my-header-block");\nWrite(html);',
|
|
63
64
|
},
|
|
64
65
|
{
|
|
65
66
|
name: 'ContentBlockByName',
|
|
@@ -70,6 +71,7 @@ export const SSJS_GLOBALS = [
|
|
|
70
71
|
params: [{ name: 'name', description: 'Folder path and name of the Content Builder asset', type: 'string' }],
|
|
71
72
|
returnType: 'string',
|
|
72
73
|
syntax: 'ContentBlockByName(name)',
|
|
74
|
+
example: 'var html = ContentBlockByName("Shared Content/Footer");\nWrite(html);',
|
|
73
75
|
},
|
|
74
76
|
{
|
|
75
77
|
name: 'ContentBlockByID',
|
|
@@ -80,6 +82,7 @@ export const SSJS_GLOBALS = [
|
|
|
80
82
|
params: [{ name: 'id', description: 'Numeric ID of the Content Builder asset', type: 'number' }],
|
|
81
83
|
returnType: 'string',
|
|
82
84
|
syntax: 'ContentBlockByID(id)',
|
|
85
|
+
example: 'var html = ContentBlockByID(12345);\nWrite(html);',
|
|
83
86
|
},
|
|
84
87
|
{
|
|
85
88
|
name: 'ContentAreaByKey',
|
|
@@ -90,6 +93,7 @@ export const SSJS_GLOBALS = [
|
|
|
90
93
|
params: [{ name: 'key', description: 'External key of the classic content area', type: 'string' }],
|
|
91
94
|
returnType: 'string',
|
|
92
95
|
syntax: 'ContentAreaByKey(key)',
|
|
96
|
+
example: 'var html = ContentAreaByKey("my-content-area-key");\nWrite(html);',
|
|
93
97
|
},
|
|
94
98
|
{
|
|
95
99
|
name: 'TreatAsContent',
|
|
@@ -101,6 +105,7 @@ export const SSJS_GLOBALS = [
|
|
|
101
105
|
params: [{ name: 'content', description: 'String containing AMPscript or HTML to evaluate', type: 'string' }],
|
|
102
106
|
returnType: 'string',
|
|
103
107
|
syntax: 'TreatAsContent(content)',
|
|
108
|
+
example: 'var ampBlock = "%%[Set @msg = \'Dynamic content\']%% %%=v(@msg)=%%";\nWrite(TreatAsContent(ampBlock));',
|
|
104
109
|
},
|
|
105
110
|
{
|
|
106
111
|
name: 'TreatAsContentArea',
|
|
@@ -111,6 +116,7 @@ export const SSJS_GLOBALS = [
|
|
|
111
116
|
params: [{ name: 'content', description: 'Classic content area markup to render', type: 'string' }],
|
|
112
117
|
returnType: 'string',
|
|
113
118
|
syntax: 'TreatAsContentArea(content)',
|
|
119
|
+
example: 'var rendered = TreatAsContentArea("%%[ContentAreaByKey(\'my-key\')]%%");\nWrite(rendered);',
|
|
114
120
|
},
|
|
115
121
|
{
|
|
116
122
|
name: 'String',
|
|
@@ -216,6 +222,7 @@ export const PLATFORM_METHODS = [
|
|
|
216
222
|
],
|
|
217
223
|
returnType: 'void',
|
|
218
224
|
syntax: 'Platform.Load(libraryName, version)',
|
|
225
|
+
example: 'Platform.Load("core", "1.1.5");\nvar de = DataExtension.Init("MyDE");\nvar rows = de.Rows.Retrieve();',
|
|
219
226
|
},
|
|
220
227
|
];
|
|
221
228
|
|
|
@@ -270,6 +277,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
270
277
|
],
|
|
271
278
|
returnType: 'object',
|
|
272
279
|
syntax: 'LookupOrderedRows(deName, sortCount, sortField, sortOrder, fieldName, fieldValue[, fieldName2, fieldValue2, ...])',
|
|
280
|
+
example: 'var rows = Platform.Function.LookupOrderedRows("MyDE", 10, "CreatedDate", "DESC", "Status", "active");\nfor (var i = 0; i < rows.length; i++) {\n Write(rows[i]["Email"] + "<br>");\n}',
|
|
273
281
|
},
|
|
274
282
|
{
|
|
275
283
|
name: 'InsertData',
|
|
@@ -297,6 +305,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
297
305
|
],
|
|
298
306
|
returnType: 'number',
|
|
299
307
|
syntax: 'InsertDE(deName, fieldName1, value1[, fieldName2, value2, ...])',
|
|
308
|
+
example: 'var count = Platform.Function.InsertDE("MyDE", "Email", "jane@example.com", "Name", "Jane");',
|
|
300
309
|
},
|
|
301
310
|
{
|
|
302
311
|
name: 'UpdateData',
|
|
@@ -312,6 +321,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
312
321
|
],
|
|
313
322
|
returnType: 'number',
|
|
314
323
|
syntax: 'UpdateData(deName, fieldName1, value1, filterField, filterValue[, fieldName2, value2, ...])',
|
|
324
|
+
example: 'var count = Platform.Function.UpdateData("MyDE", "Status", "inactive", "Email", "jane@example.com");',
|
|
315
325
|
},
|
|
316
326
|
{
|
|
317
327
|
name: 'UpdateDE',
|
|
@@ -327,6 +337,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
327
337
|
],
|
|
328
338
|
returnType: 'number',
|
|
329
339
|
syntax: 'UpdateDE(deName, fieldName1, value1, filterField, filterValue[, fieldName2, value2, ...])',
|
|
340
|
+
example: 'var count = Platform.Function.UpdateDE("MyDE", "Status", "inactive", "Email", "jane@example.com");',
|
|
330
341
|
},
|
|
331
342
|
{
|
|
332
343
|
name: 'UpsertData',
|
|
@@ -358,6 +369,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
358
369
|
],
|
|
359
370
|
returnType: 'number',
|
|
360
371
|
syntax: 'UpsertDE(deName, fieldName1, value1, filterField, filterValue[, fieldName2, value2, ...])',
|
|
372
|
+
example: 'Platform.Function.UpsertDE("MyDE", 1, "Status", "active", "Email", "jane@example.com");',
|
|
361
373
|
},
|
|
362
374
|
{
|
|
363
375
|
name: 'DeleteData',
|
|
@@ -371,6 +383,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
371
383
|
],
|
|
372
384
|
returnType: 'number',
|
|
373
385
|
syntax: 'DeleteData(deName, filterField, filterValue[, filterField2, filterValue2, ...])',
|
|
386
|
+
example: 'var count = Platform.Function.DeleteData("MyDE", "Email", "jane@example.com");',
|
|
374
387
|
},
|
|
375
388
|
{
|
|
376
389
|
name: 'DeleteDE',
|
|
@@ -384,6 +397,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
384
397
|
],
|
|
385
398
|
returnType: 'number',
|
|
386
399
|
syntax: 'DeleteDE(deName, filterField, filterValue[, filterField2, filterValue2, ...])',
|
|
400
|
+
example: 'var count = Platform.Function.DeleteDE("MyDE", "Email", "jane@example.com");',
|
|
387
401
|
},
|
|
388
402
|
{
|
|
389
403
|
name: 'ContentBlockByKey',
|
|
@@ -395,6 +409,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
395
409
|
],
|
|
396
410
|
returnType: 'string',
|
|
397
411
|
syntax: 'ContentBlockByKey(customerKey)',
|
|
412
|
+
example: 'var html = Platform.Function.ContentBlockByKey("my-header-block");\nWrite(html);',
|
|
398
413
|
},
|
|
399
414
|
{
|
|
400
415
|
name: 'ContentBlockByName',
|
|
@@ -406,6 +421,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
406
421
|
],
|
|
407
422
|
returnType: 'string',
|
|
408
423
|
syntax: 'ContentBlockByName(name)',
|
|
424
|
+
example: 'var html = Platform.Function.ContentBlockByName("Shared Content/Footer");\nWrite(html);',
|
|
409
425
|
},
|
|
410
426
|
{
|
|
411
427
|
name: 'ContentBlockByID',
|
|
@@ -417,6 +433,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
417
433
|
],
|
|
418
434
|
returnType: 'string',
|
|
419
435
|
syntax: 'ContentBlockByID(id)',
|
|
436
|
+
example: 'var html = Platform.Function.ContentBlockByID(12345);\nWrite(html);',
|
|
420
437
|
},
|
|
421
438
|
{
|
|
422
439
|
name: 'TreatAsContent',
|
|
@@ -428,6 +445,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
428
445
|
],
|
|
429
446
|
returnType: 'string',
|
|
430
447
|
syntax: 'TreatAsContent(content)',
|
|
448
|
+
example: 'var result = Platform.Function.TreatAsContent("%%[Set @x = 1]%%%%=v(@x)=%%");\nWrite(result); // "1"',
|
|
431
449
|
},
|
|
432
450
|
{
|
|
433
451
|
name: 'Substring',
|
|
@@ -441,6 +459,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
441
459
|
],
|
|
442
460
|
returnType: 'string',
|
|
443
461
|
syntax: 'Substring(value, start[, length])',
|
|
462
|
+
example: 'var str = "Hello, World!";\nvar sub = Platform.Function.Substring(str, 1, 5);\nWrite(sub); // "Hello"',
|
|
444
463
|
},
|
|
445
464
|
{
|
|
446
465
|
name: 'Trim',
|
|
@@ -452,6 +471,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
452
471
|
],
|
|
453
472
|
returnType: 'string',
|
|
454
473
|
syntax: 'Trim(value)',
|
|
474
|
+
example: 'var clean = Platform.Function.Trim(" hello ");\nWrite(clean); // "hello"',
|
|
455
475
|
},
|
|
456
476
|
{
|
|
457
477
|
name: 'Replace',
|
|
@@ -465,6 +485,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
465
485
|
],
|
|
466
486
|
returnType: 'string',
|
|
467
487
|
syntax: 'Replace(value, search, replacement)',
|
|
488
|
+
example: 'var result = Platform.Function.Replace("Hello, World!", "World", "SFMC");\nWrite(result); // "Hello, SFMC!"',
|
|
468
489
|
},
|
|
469
490
|
{
|
|
470
491
|
name: 'IndexOf',
|
|
@@ -477,6 +498,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
477
498
|
],
|
|
478
499
|
returnType: 'number',
|
|
479
500
|
syntax: 'IndexOf(value, search)',
|
|
501
|
+
example: 'var pos = Platform.Function.IndexOf("Hello, World!", "World");\nWrite(pos); // 7',
|
|
480
502
|
},
|
|
481
503
|
{
|
|
482
504
|
name: 'Length',
|
|
@@ -488,6 +510,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
488
510
|
],
|
|
489
511
|
returnType: 'number',
|
|
490
512
|
syntax: 'Length(value)',
|
|
513
|
+
example: 'var len = Platform.Function.Length("Hello");\nWrite(len); // 5',
|
|
491
514
|
},
|
|
492
515
|
{
|
|
493
516
|
name: 'Uppercase',
|
|
@@ -499,6 +522,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
499
522
|
],
|
|
500
523
|
returnType: 'string',
|
|
501
524
|
syntax: 'Uppercase(value)',
|
|
525
|
+
example: 'var upper = Platform.Function.Uppercase("hello");\nWrite(upper); // "HELLO"',
|
|
502
526
|
},
|
|
503
527
|
{
|
|
504
528
|
name: 'Lowercase',
|
|
@@ -510,6 +534,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
510
534
|
],
|
|
511
535
|
returnType: 'string',
|
|
512
536
|
syntax: 'Lowercase(value)',
|
|
537
|
+
example: 'var lower = Platform.Function.Lowercase("HELLO");\nWrite(lower); // "hello"',
|
|
513
538
|
},
|
|
514
539
|
{
|
|
515
540
|
name: 'ProperCase',
|
|
@@ -521,6 +546,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
521
546
|
],
|
|
522
547
|
returnType: 'string',
|
|
523
548
|
syntax: 'ProperCase(value)',
|
|
549
|
+
example: 'var title = Platform.Function.ProperCase("hello world");\nWrite(title); // "Hello World"',
|
|
524
550
|
},
|
|
525
551
|
{
|
|
526
552
|
name: 'Char',
|
|
@@ -532,6 +558,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
532
558
|
],
|
|
533
559
|
returnType: 'string',
|
|
534
560
|
syntax: 'Char(asciiCode)',
|
|
561
|
+
example: 'var tab = Platform.Function.Char(9); // tab character\nWrite("Col1" + tab + "Col2");',
|
|
535
562
|
},
|
|
536
563
|
{
|
|
537
564
|
name: 'Concat',
|
|
@@ -544,6 +571,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
544
571
|
],
|
|
545
572
|
returnType: 'string',
|
|
546
573
|
syntax: 'Concat(value1, value2[, ...])',
|
|
574
|
+
example: 'var full = Platform.Function.Concat("Hello", ", ", "World!");\nWrite(full); // "Hello, World!"',
|
|
547
575
|
},
|
|
548
576
|
{
|
|
549
577
|
name: 'Format',
|
|
@@ -556,6 +584,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
556
584
|
],
|
|
557
585
|
returnType: 'string',
|
|
558
586
|
syntax: 'Format(value, format[, ...])',
|
|
587
|
+
example: 'var price = Platform.Function.Format(1234.5, "C2");\nWrite(price); // "$1,234.50"',
|
|
559
588
|
},
|
|
560
589
|
{
|
|
561
590
|
name: 'DateAdd',
|
|
@@ -569,6 +598,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
569
598
|
],
|
|
570
599
|
returnType: 'string',
|
|
571
600
|
syntax: 'DateAdd(date, interval, datePart)',
|
|
601
|
+
example: 'var future = Platform.Function.DateAdd(Platform.Function.Now(), 7, "D");\nWrite(future); // date 7 days from now',
|
|
572
602
|
},
|
|
573
603
|
{
|
|
574
604
|
name: 'DateDiff',
|
|
@@ -582,6 +612,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
582
612
|
],
|
|
583
613
|
returnType: 'number',
|
|
584
614
|
syntax: 'DateDiff(date1, date2, datePart)',
|
|
615
|
+
example: 'var days = Platform.Function.DateDiff("2025-01-01", Platform.Function.Now(), "D");\nWrite(days); // days elapsed since Jan 1 2025',
|
|
585
616
|
},
|
|
586
617
|
{
|
|
587
618
|
name: 'DateParse',
|
|
@@ -594,15 +625,26 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
594
625
|
],
|
|
595
626
|
returnType: 'object',
|
|
596
627
|
syntax: 'DateParse(dateString[, format])',
|
|
628
|
+
example: 'var d = Platform.Function.DateParse("2025-08-05T12:00:00Z");\nWrite(Platform.Function.FormatDate(d, "MM/dd/yyyy")); // "08/05/2025"',
|
|
597
629
|
},
|
|
598
630
|
{
|
|
599
631
|
name: 'Now',
|
|
600
632
|
minArgs: 0,
|
|
601
|
-
maxArgs:
|
|
602
|
-
description:
|
|
603
|
-
|
|
633
|
+
maxArgs: 1,
|
|
634
|
+
description:
|
|
635
|
+
'Returns the current system timestamp, or the timestamp of the triggering send when called with true.',
|
|
636
|
+
params: [
|
|
637
|
+
{
|
|
638
|
+
name: 'useContextTime',
|
|
639
|
+
description:
|
|
640
|
+
'When true, returns the time the triggering send or activity was initiated. When false or omitted, returns the current system clock time.',
|
|
641
|
+
type: 'boolean',
|
|
642
|
+
optional: true,
|
|
643
|
+
},
|
|
644
|
+
],
|
|
604
645
|
returnType: 'string',
|
|
605
|
-
syntax: 'Now()',
|
|
646
|
+
syntax: 'Now([useContextTime])',
|
|
647
|
+
example: 'var current = Platform.Function.Now();\nWrite(current); // e.g. "8/5/2025 12:00:00 PM"\n\n// Use context time during triggered sends:\nvar sendTime = Platform.Function.Now(true);',
|
|
606
648
|
},
|
|
607
649
|
{
|
|
608
650
|
name: 'FormatDate',
|
|
@@ -616,17 +658,33 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
616
658
|
],
|
|
617
659
|
returnType: 'string',
|
|
618
660
|
syntax: 'FormatDate(date, format[, locale])',
|
|
661
|
+
example: 'var formatted = Platform.Function.FormatDate(Platform.Function.Now(), "MMMM d, yyyy");\nWrite(formatted); // e.g. "August 5, 2025"',
|
|
619
662
|
},
|
|
620
663
|
{
|
|
621
664
|
name: 'SystemDateToLocalDate',
|
|
622
665
|
minArgs: 1,
|
|
623
666
|
maxArgs: 1,
|
|
624
|
-
description:
|
|
667
|
+
description:
|
|
668
|
+
'Converts a date-time value from Marketing Cloud system time (CST) to the local time of the account or user.',
|
|
625
669
|
params: [
|
|
626
|
-
{ name: '
|
|
670
|
+
{ name: 'dateValue', description: 'Date-time string in system time (CST)', type: 'string' },
|
|
627
671
|
],
|
|
628
672
|
returnType: 'string',
|
|
629
|
-
syntax: 'SystemDateToLocalDate(
|
|
673
|
+
syntax: 'SystemDateToLocalDate(dateValue)',
|
|
674
|
+
example: 'var systemDate = Platform.Function.Now();\nvar localDate = Platform.Function.SystemDateToLocalDate(systemDate);\nWrite(localDate);',
|
|
675
|
+
},
|
|
676
|
+
{
|
|
677
|
+
name: 'LocalDateToSystemDate',
|
|
678
|
+
minArgs: 1,
|
|
679
|
+
maxArgs: 1,
|
|
680
|
+
description:
|
|
681
|
+
'Converts a date-time value from the local time of the account or user to Marketing Cloud system time (CST).',
|
|
682
|
+
params: [
|
|
683
|
+
{ name: 'dateValue', description: 'Date-time string in local account/user time', type: 'string' },
|
|
684
|
+
],
|
|
685
|
+
returnType: 'string',
|
|
686
|
+
syntax: 'LocalDateToSystemDate(dateValue)',
|
|
687
|
+
example: 'var localDate = "8/5/2025 12:00:00 PM";\nvar systemDate = Platform.Function.LocalDateToSystemDate(localDate);\nWrite(systemDate);',
|
|
630
688
|
},
|
|
631
689
|
{
|
|
632
690
|
name: 'GetValue',
|
|
@@ -638,6 +696,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
638
696
|
],
|
|
639
697
|
returnType: 'string',
|
|
640
698
|
syntax: 'GetValue(variableName)',
|
|
699
|
+
example: '// Retrieve an AMPscript variable from within SSJS:\nvar sk = Platform.Function.GetValue("SubscriberKey");\nWrite(sk);',
|
|
641
700
|
},
|
|
642
701
|
{
|
|
643
702
|
name: 'SetValue',
|
|
@@ -650,6 +709,20 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
650
709
|
],
|
|
651
710
|
returnType: 'void',
|
|
652
711
|
syntax: 'SetValue(variableName, value)',
|
|
712
|
+
example: 'Platform.Function.SetValue("greeting", "Hello from SSJS");\n// @greeting is now accessible in subsequent AMPscript blocks',
|
|
713
|
+
},
|
|
714
|
+
{
|
|
715
|
+
name: 'GetQueryStringParameter',
|
|
716
|
+
minArgs: 1,
|
|
717
|
+
maxArgs: 1,
|
|
718
|
+
description:
|
|
719
|
+
'Retrieves the value of a named query string parameter from the URL of the current CloudPages or landing page.',
|
|
720
|
+
params: [
|
|
721
|
+
{ name: 'parameterName', description: 'Name of the query string parameter to retrieve', type: 'string' },
|
|
722
|
+
],
|
|
723
|
+
returnType: 'string',
|
|
724
|
+
syntax: 'GetQueryStringParameter(parameterName)',
|
|
725
|
+
example: '// Page URL: /mypage?email=jane@example.com\nvar email = Platform.Function.GetQueryStringParameter("email");\nWrite(email); // "jane@example.com"',
|
|
653
726
|
},
|
|
654
727
|
{
|
|
655
728
|
name: 'RaiseError',
|
|
@@ -662,6 +735,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
662
735
|
],
|
|
663
736
|
returnType: 'void',
|
|
664
737
|
syntax: 'RaiseError(message[, skipSend])',
|
|
738
|
+
example: 'var status = Platform.Function.Lookup("MyDE", "Status", "Email", emailAddress);\nif (!status) {\n Platform.Function.RaiseError("Subscriber not found", true);\n}',
|
|
665
739
|
},
|
|
666
740
|
{
|
|
667
741
|
name: 'Redirect',
|
|
@@ -674,6 +748,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
674
748
|
],
|
|
675
749
|
returnType: 'void',
|
|
676
750
|
syntax: 'Redirect(url[, permanent])',
|
|
751
|
+
example: 'Platform.Function.Redirect("https://www.example.com/thank-you");',
|
|
677
752
|
},
|
|
678
753
|
{
|
|
679
754
|
name: 'CloudPagesURL',
|
|
@@ -702,6 +777,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
702
777
|
],
|
|
703
778
|
returnType: 'string',
|
|
704
779
|
syntax: 'MicrositeURL(pageId[, param1, value1, ...])',
|
|
780
|
+
example: 'var url = Platform.Function.MicrositeURL(456, "source", "email");\nWrite(\'<a href="\' + url + \'">Visit microsite</a>\');',
|
|
705
781
|
},
|
|
706
782
|
{
|
|
707
783
|
name: 'GUID',
|
|
@@ -724,6 +800,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
724
800
|
],
|
|
725
801
|
returnType: 'string',
|
|
726
802
|
syntax: 'Base64Encode(value[, encoding])',
|
|
803
|
+
example: 'var encoded = Platform.Function.Base64Encode("username:password");\nWrite(encoded); // "dXNlcm5hbWU6cGFzc3dvcmQ="',
|
|
727
804
|
},
|
|
728
805
|
{
|
|
729
806
|
name: 'Base64Decode',
|
|
@@ -736,6 +813,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
736
813
|
],
|
|
737
814
|
returnType: 'string',
|
|
738
815
|
syntax: 'Base64Decode(value[, encoding])',
|
|
816
|
+
example: 'var decoded = Platform.Function.Base64Decode("dXNlcm5hbWU6cGFzc3dvcmQ=");\nWrite(decoded); // "username:password"',
|
|
739
817
|
},
|
|
740
818
|
{
|
|
741
819
|
name: 'EncryptSymmetric',
|
|
@@ -754,6 +832,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
754
832
|
],
|
|
755
833
|
returnType: 'string',
|
|
756
834
|
syntax: 'EncryptSymmetric(value, algorithm, passwordKey, password, saltKey, salt[, ivKey, iv])',
|
|
835
|
+
example: 'var encrypted = Platform.Function.EncryptSymmetric("sensitive data", "AES", "", "myPassword", "", "mySalt");\nWrite(encrypted);',
|
|
757
836
|
},
|
|
758
837
|
{
|
|
759
838
|
name: 'DecryptSymmetric',
|
|
@@ -772,6 +851,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
772
851
|
],
|
|
773
852
|
returnType: 'string',
|
|
774
853
|
syntax: 'DecryptSymmetric(value, algorithm, passwordKey, password, saltKey, salt[, ivKey, iv])',
|
|
854
|
+
example: 'var plain = Platform.Function.DecryptSymmetric(encryptedValue, "AES", "", "myPassword", "", "mySalt");\nWrite(plain);',
|
|
775
855
|
},
|
|
776
856
|
{
|
|
777
857
|
name: 'SHA256',
|
|
@@ -784,6 +864,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
784
864
|
],
|
|
785
865
|
returnType: 'string',
|
|
786
866
|
syntax: 'SHA256(value[, encoding])',
|
|
867
|
+
example: 'var hash = Platform.Function.SHA256(emailAddress);\nWrite(hash);',
|
|
787
868
|
},
|
|
788
869
|
{
|
|
789
870
|
name: 'SHA512',
|
|
@@ -796,6 +877,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
796
877
|
],
|
|
797
878
|
returnType: 'string',
|
|
798
879
|
syntax: 'SHA512(value[, encoding])',
|
|
880
|
+
example: 'var hash = Platform.Function.SHA512(emailAddress);\nWrite(hash);',
|
|
799
881
|
},
|
|
800
882
|
{
|
|
801
883
|
name: 'MD5',
|
|
@@ -808,6 +890,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
808
890
|
],
|
|
809
891
|
returnType: 'string',
|
|
810
892
|
syntax: 'MD5(value[, encoding])',
|
|
893
|
+
example: 'var hash = Platform.Function.MD5(emailAddress);\nWrite(hash);',
|
|
811
894
|
},
|
|
812
895
|
{
|
|
813
896
|
name: 'IsEmailAddress',
|
|
@@ -819,6 +902,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
819
902
|
],
|
|
820
903
|
returnType: 'boolean',
|
|
821
904
|
syntax: 'IsEmailAddress(value)',
|
|
905
|
+
example: 'if (Platform.Function.IsEmailAddress(emailInput)) {\n Write("Valid email");\n} else {\n Write("Invalid email format");\n}',
|
|
822
906
|
},
|
|
823
907
|
{
|
|
824
908
|
name: 'IsNull',
|
|
@@ -830,6 +914,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
830
914
|
],
|
|
831
915
|
returnType: 'boolean',
|
|
832
916
|
syntax: 'IsNull(value)',
|
|
917
|
+
example: 'var phone = Platform.Function.Lookup("MyDE", "Phone", "Email", email);\nif (Platform.Function.IsNull(phone)) {\n Write("No phone on record");\n}',
|
|
833
918
|
},
|
|
834
919
|
{
|
|
835
920
|
name: 'Empty',
|
|
@@ -841,6 +926,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
841
926
|
],
|
|
842
927
|
returnType: 'boolean',
|
|
843
928
|
syntax: 'Empty(value)',
|
|
929
|
+
example: 'var city = Platform.Function.GetQueryStringParameter("city");\nif (Platform.Function.Empty(city)) {\n city = "Unknown";\n}',
|
|
844
930
|
},
|
|
845
931
|
{
|
|
846
932
|
name: 'IIf',
|
|
@@ -854,6 +940,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
854
940
|
],
|
|
855
941
|
returnType: 'any',
|
|
856
942
|
syntax: 'IIf(condition, trueValue, falseValue)',
|
|
943
|
+
example: 'var label = Platform.Function.IIf(score > 50, "Pass", "Fail");\nWrite(label);',
|
|
857
944
|
},
|
|
858
945
|
{
|
|
859
946
|
name: 'DataExtensionRowCount',
|
|
@@ -865,6 +952,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
865
952
|
],
|
|
866
953
|
returnType: 'number',
|
|
867
954
|
syntax: 'DataExtensionRowCount(deName)',
|
|
955
|
+
example: 'var count = Platform.Function.DataExtensionRowCount("MyDE");\nWrite("Total rows: " + count);',
|
|
868
956
|
},
|
|
869
957
|
{
|
|
870
958
|
name: 'CreateObject',
|
|
@@ -876,6 +964,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
876
964
|
],
|
|
877
965
|
returnType: 'object',
|
|
878
966
|
syntax: 'CreateObject(objectType)',
|
|
967
|
+
example: 'var sub = Platform.Function.CreateObject("Subscriber");\nPlatform.Function.SetObjectProperty(sub, "EmailAddress", "jane@example.com");\nPlatform.Function.SetObjectProperty(sub, "SubscriberKey", "sk-123");',
|
|
879
968
|
},
|
|
880
969
|
{
|
|
881
970
|
name: 'SetObjectProperty',
|
|
@@ -889,6 +978,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
889
978
|
],
|
|
890
979
|
returnType: 'void',
|
|
891
980
|
syntax: 'SetObjectProperty(apiObject, propertyName, value)',
|
|
981
|
+
example: 'var sub = Platform.Function.CreateObject("Subscriber");\nPlatform.Function.SetObjectProperty(sub, "EmailAddress", "jane@example.com");',
|
|
892
982
|
},
|
|
893
983
|
{
|
|
894
984
|
name: 'AddObjectArrayItem',
|
|
@@ -902,6 +992,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
902
992
|
],
|
|
903
993
|
returnType: 'void',
|
|
904
994
|
syntax: 'AddObjectArrayItem(apiObject, propertyName, value)',
|
|
995
|
+
example: 'var ts = Platform.Function.CreateObject("TriggeredSend");\nPlatform.Function.AddObjectArrayItem(ts, "Subscribers", sub);',
|
|
905
996
|
},
|
|
906
997
|
{
|
|
907
998
|
name: 'InvokeCreate',
|
|
@@ -916,6 +1007,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
916
1007
|
],
|
|
917
1008
|
returnType: 'string',
|
|
918
1009
|
syntax: 'InvokeCreate(apiObject[, statusMessage, errorCode, requestId])',
|
|
1010
|
+
example: 'var sub = Platform.Function.CreateObject("Subscriber");\nPlatform.Function.SetObjectProperty(sub, "EmailAddress", "jane@example.com");\nvar statusMsg = "";\nvar errorCode = "";\nvar status = Platform.Function.InvokeCreate(sub, statusMsg, errorCode);\nWrite(status); // "OK" or "Error"',
|
|
919
1011
|
},
|
|
920
1012
|
{
|
|
921
1013
|
name: 'InvokeUpdate',
|
|
@@ -930,6 +1022,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
930
1022
|
],
|
|
931
1023
|
returnType: 'string',
|
|
932
1024
|
syntax: 'InvokeUpdate(apiObject[, statusMessage, errorCode, requestId])',
|
|
1025
|
+
example: 'Platform.Function.SetObjectProperty(sub, "Status", "Unsubscribed");\nvar status = Platform.Function.InvokeUpdate(sub);\nWrite(status);',
|
|
933
1026
|
},
|
|
934
1027
|
{
|
|
935
1028
|
name: 'InvokeDelete',
|
|
@@ -944,6 +1037,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
944
1037
|
],
|
|
945
1038
|
returnType: 'string',
|
|
946
1039
|
syntax: 'InvokeDelete(apiObject[, statusMessage, errorCode, requestId])',
|
|
1040
|
+
example: 'var status = Platform.Function.InvokeDelete(sub);\nWrite(status);',
|
|
947
1041
|
},
|
|
948
1042
|
{
|
|
949
1043
|
name: 'InvokeRetrieve',
|
|
@@ -959,6 +1053,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
959
1053
|
],
|
|
960
1054
|
returnType: 'object',
|
|
961
1055
|
syntax: 'InvokeRetrieve(apiObject, properties[, filter, statusMessage, requestId])',
|
|
1056
|
+
example: 'var req = Platform.Function.CreateObject("RetrieveRequest");\nPlatform.Function.SetObjectProperty(req, "ObjectType", "Subscriber");\nvar props = ["EmailAddress", "Status"];\nvar results = Platform.Function.InvokeRetrieve(req, props);',
|
|
962
1057
|
},
|
|
963
1058
|
{
|
|
964
1059
|
name: 'InvokePerform',
|
|
@@ -973,6 +1068,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
973
1068
|
],
|
|
974
1069
|
returnType: 'string',
|
|
975
1070
|
syntax: 'InvokePerform(apiObject, action[, statusMessage, errorCode])',
|
|
1071
|
+
example: 'var status = Platform.Function.InvokePerform(sendDef, "start");\nWrite(status);',
|
|
976
1072
|
},
|
|
977
1073
|
{
|
|
978
1074
|
name: 'InvokeConfigure',
|
|
@@ -987,6 +1083,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
987
1083
|
],
|
|
988
1084
|
returnType: 'string',
|
|
989
1085
|
syntax: 'InvokeConfigure(apiObject, action[, statusMessage, errorCode])',
|
|
1086
|
+
example: 'var status = Platform.Function.InvokeConfigure(configObj, "create");\nWrite(status);',
|
|
990
1087
|
},
|
|
991
1088
|
{
|
|
992
1089
|
name: 'InvokeExecute',
|
|
@@ -1001,6 +1098,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
1001
1098
|
],
|
|
1002
1099
|
returnType: 'string',
|
|
1003
1100
|
syntax: 'InvokeExecute(apiObject, method[, statusMessage, errorCode])',
|
|
1101
|
+
example: 'var status = Platform.Function.InvokeExecute(execObj, "LogUnsubEvent");\nWrite(status);',
|
|
1004
1102
|
},
|
|
1005
1103
|
{
|
|
1006
1104
|
name: 'AttributeValue',
|
|
@@ -1012,6 +1110,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
1012
1110
|
],
|
|
1013
1111
|
returnType: 'string',
|
|
1014
1112
|
syntax: 'AttributeValue(attributeName)',
|
|
1113
|
+
example: 'var phone = Platform.Function.AttributeValue("MobilePhone");\nif (phone) { Write(phone); }',
|
|
1015
1114
|
},
|
|
1016
1115
|
{
|
|
1017
1116
|
name: 'HTTPGet',
|
|
@@ -1067,6 +1166,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
1067
1166
|
],
|
|
1068
1167
|
returnType: 'string',
|
|
1069
1168
|
syntax: 'HTTPRequestHeader(headerName)',
|
|
1169
|
+
example: 'var auth = Platform.Function.HTTPRequestHeader("Authorization");\nWrite(auth); // e.g. "Bearer abc123"',
|
|
1070
1170
|
},
|
|
1071
1171
|
{
|
|
1072
1172
|
name: 'ParseJSON',
|
|
@@ -1100,6 +1200,7 @@ export const PLATFORM_FUNCTIONS = [
|
|
|
1100
1200
|
],
|
|
1101
1201
|
returnType: 'string',
|
|
1102
1202
|
syntax: 'URLEncode(value)',
|
|
1203
|
+
example: 'var param = "hello world & more";\nvar encoded = Platform.Function.URLEncode(param);\nWrite("?q=" + encoded); // "?q=hello+world+%26+more"',
|
|
1103
1204
|
},
|
|
1104
1205
|
];
|
|
1105
1206
|
|
|
@@ -1292,6 +1393,7 @@ export const HTTP_METHODS = [
|
|
|
1292
1393
|
],
|
|
1293
1394
|
returnType: 'object',
|
|
1294
1395
|
syntax: 'HTTP.Get(url[, headerNames, headerValues])',
|
|
1396
|
+
example: 'var body = HTTP.Get("https://api.example.com/data");\nvar obj = Platform.Function.ParseJSON(String(body));',
|
|
1295
1397
|
},
|
|
1296
1398
|
{
|
|
1297
1399
|
name: 'Post',
|
|
@@ -1307,6 +1409,7 @@ export const HTTP_METHODS = [
|
|
|
1307
1409
|
],
|
|
1308
1410
|
returnType: 'object',
|
|
1309
1411
|
syntax: 'HTTP.Post(url, contentType, payload[, headerNames, headerValues])',
|
|
1412
|
+
example: 'var payload = Stringify({ email: "jane@example.com" });\nvar response = HTTP.Post("https://api.example.com/items", "application/json", payload);',
|
|
1310
1413
|
},
|
|
1311
1414
|
{
|
|
1312
1415
|
name: 'GetRequest',
|
|
@@ -1316,6 +1419,7 @@ export const HTTP_METHODS = [
|
|
|
1316
1419
|
params: [],
|
|
1317
1420
|
returnType: 'object',
|
|
1318
1421
|
syntax: 'HTTP.GetRequest()',
|
|
1422
|
+
example: 'var req = HTTP.GetRequest();\nWrite(req.Method); // "GET"',
|
|
1319
1423
|
},
|
|
1320
1424
|
{
|
|
1321
1425
|
name: 'PostRequest',
|
|
@@ -1325,6 +1429,7 @@ export const HTTP_METHODS = [
|
|
|
1325
1429
|
params: [],
|
|
1326
1430
|
returnType: 'object',
|
|
1327
1431
|
syntax: 'HTTP.PostRequest()',
|
|
1432
|
+
example: 'var postBody = HTTP.PostRequest();\nvar data = Platform.Function.ParseJSON(String(postBody));',
|
|
1328
1433
|
},
|
|
1329
1434
|
];
|
|
1330
1435
|
|
|
@@ -1432,6 +1537,7 @@ export const WSPROXY_METHODS = [
|
|
|
1432
1537
|
],
|
|
1433
1538
|
returnType: 'object',
|
|
1434
1539
|
syntax: 'api.performItem(objectType, action, properties)',
|
|
1540
|
+
example: 'var api = new WSProxy();\nvar result = api.performItem("QueryDefinition", "start", { ObjectID: queryObjectId });\nWrite(result.Status);',
|
|
1435
1541
|
},
|
|
1436
1542
|
{
|
|
1437
1543
|
name: 'execute',
|
|
@@ -1444,6 +1550,7 @@ export const WSPROXY_METHODS = [
|
|
|
1444
1550
|
],
|
|
1445
1551
|
returnType: 'object',
|
|
1446
1552
|
syntax: 'api.execute(objectType, method)',
|
|
1553
|
+
example: 'var api = new WSProxy();\nvar result = api.execute("DataExtensionObject", "clearData");\nWrite(result.Status);',
|
|
1447
1554
|
},
|
|
1448
1555
|
{
|
|
1449
1556
|
name: 'setBatchSize',
|
|
@@ -1455,6 +1562,7 @@ export const WSPROXY_METHODS = [
|
|
|
1455
1562
|
],
|
|
1456
1563
|
returnType: 'void',
|
|
1457
1564
|
syntax: 'api.setBatchSize(batchSize)',
|
|
1565
|
+
example: 'var api = new WSProxy();\napi.setBatchSize(200); // default is 2500\nvar result = api.retrieve("DataExtension", ["Name"], {});',
|
|
1458
1566
|
},
|
|
1459
1567
|
{
|
|
1460
1568
|
name: 'setClientId',
|
|
@@ -1482,6 +1590,7 @@ export const WSPROXY_METHODS = [
|
|
|
1482
1590
|
],
|
|
1483
1591
|
returnType: 'object',
|
|
1484
1592
|
syntax: 'api.createBatch(objectType, propertiesArray)',
|
|
1593
|
+
example: 'var api = new WSProxy();\nvar items = [\n { CustomerKey: "MyDE", Properties: { Property: [{ Name: "Email", Value: "a@example.com" }] } },\n { CustomerKey: "MyDE", Properties: { Property: [{ Name: "Email", Value: "b@example.com" }] } }\n];\nvar result = api.createBatch("DataExtensionObject", items);\nWrite(result.Status);',
|
|
1485
1594
|
},
|
|
1486
1595
|
{
|
|
1487
1596
|
name: 'updateBatch',
|
|
@@ -1494,6 +1603,7 @@ export const WSPROXY_METHODS = [
|
|
|
1494
1603
|
],
|
|
1495
1604
|
returnType: 'object',
|
|
1496
1605
|
syntax: 'api.updateBatch(objectType, propertiesArray)',
|
|
1606
|
+
example: 'var api = new WSProxy();\nvar items = [\n { CustomerKey: "MyDE", Keys: { Key: [{ Name: "Email", Value: "a@example.com" }] }, Properties: { Property: [{ Name: "Status", Value: "active" }] } }\n];\nvar result = api.updateBatch("DataExtensionObject", items);\nWrite(result.Status);',
|
|
1497
1607
|
},
|
|
1498
1608
|
{
|
|
1499
1609
|
name: 'deleteBatch',
|
|
@@ -1506,6 +1616,7 @@ export const WSPROXY_METHODS = [
|
|
|
1506
1616
|
],
|
|
1507
1617
|
returnType: 'object',
|
|
1508
1618
|
syntax: 'api.deleteBatch(objectType, propertiesArray)',
|
|
1619
|
+
example: 'var api = new WSProxy();\nvar items = [\n { CustomerKey: "MyDE", Keys: { Key: [{ Name: "Email", Value: "old@example.com" }] } }\n];\nvar result = api.deleteBatch("DataExtensionObject", items);\nWrite(result.Status);',
|
|
1509
1620
|
},
|
|
1510
1621
|
];
|
|
1511
1622
|
|
|
@@ -1524,6 +1635,7 @@ export const PLATFORM_VARIABLE_METHODS = [
|
|
|
1524
1635
|
],
|
|
1525
1636
|
returnType: 'string',
|
|
1526
1637
|
syntax: 'Variable.GetValue(variableName)',
|
|
1638
|
+
example: 'var sk = Variable.GetValue("SubscriberKey");\nWrite(sk);',
|
|
1527
1639
|
},
|
|
1528
1640
|
{
|
|
1529
1641
|
name: 'SetValue',
|
|
@@ -1536,6 +1648,7 @@ export const PLATFORM_VARIABLE_METHODS = [
|
|
|
1536
1648
|
],
|
|
1537
1649
|
returnType: 'void',
|
|
1538
1650
|
syntax: 'Variable.SetValue(variableName, value)',
|
|
1651
|
+
example: 'Variable.SetValue("greeting", "Hello from SSJS");\n// @greeting is now available in subsequent AMPscript blocks',
|
|
1539
1652
|
},
|
|
1540
1653
|
];
|
|
1541
1654
|
|
|
@@ -1550,6 +1663,7 @@ export const PLATFORM_RESPONSE_METHODS = [
|
|
|
1550
1663
|
],
|
|
1551
1664
|
returnType: 'string',
|
|
1552
1665
|
syntax: 'Platform.Response.GetResponseHeader(headerName)',
|
|
1666
|
+
example: 'var contentType = Platform.Response.GetResponseHeader("Content-Type");\nWrite(contentType);',
|
|
1553
1667
|
},
|
|
1554
1668
|
{
|
|
1555
1669
|
name: 'SetResponseHeader',
|
|
@@ -1562,6 +1676,7 @@ export const PLATFORM_RESPONSE_METHODS = [
|
|
|
1562
1676
|
],
|
|
1563
1677
|
returnType: 'void',
|
|
1564
1678
|
syntax: 'Platform.Response.SetResponseHeader(headerName, value)',
|
|
1679
|
+
example: 'Platform.Response.SetResponseHeader("Content-Type", "application/json");\nPlatform.Response.Write(Stringify({ status: "ok" }));',
|
|
1565
1680
|
},
|
|
1566
1681
|
{
|
|
1567
1682
|
name: 'Redirect',
|
|
@@ -1576,6 +1691,7 @@ export const PLATFORM_RESPONSE_METHODS = [
|
|
|
1576
1691
|
],
|
|
1577
1692
|
returnType: 'void',
|
|
1578
1693
|
syntax: 'Platform.Response.Redirect(url[, permanent])',
|
|
1694
|
+
example: 'Platform.Response.Redirect("https://pub.pages.example.com/thank-you");',
|
|
1579
1695
|
},
|
|
1580
1696
|
{
|
|
1581
1697
|
name: 'Write',
|
|
@@ -1587,6 +1703,7 @@ export const PLATFORM_RESPONSE_METHODS = [
|
|
|
1587
1703
|
],
|
|
1588
1704
|
returnType: 'void',
|
|
1589
1705
|
syntax: 'Platform.Response.Write(content)',
|
|
1706
|
+
example: 'var data = { name: "Jane", status: "active" };\nPlatform.Response.Write(Stringify(data));',
|
|
1590
1707
|
},
|
|
1591
1708
|
];
|
|
1592
1709
|
|
|
@@ -1601,6 +1718,7 @@ export const PLATFORM_REQUEST_METHODS = [
|
|
|
1601
1718
|
],
|
|
1602
1719
|
returnType: 'string',
|
|
1603
1720
|
syntax: 'Platform.Request.GetQueryStringParameter(parameterName)',
|
|
1721
|
+
example: '// Page URL: /mypage?email=jane@example.com\nvar email = Platform.Request.GetQueryStringParameter("email");\nWrite(email);',
|
|
1604
1722
|
},
|
|
1605
1723
|
{
|
|
1606
1724
|
name: 'GetFormData',
|
|
@@ -1612,6 +1730,7 @@ export const PLATFORM_REQUEST_METHODS = [
|
|
|
1612
1730
|
],
|
|
1613
1731
|
returnType: 'string',
|
|
1614
1732
|
syntax: 'Platform.Request.GetFormData(fieldName)',
|
|
1733
|
+
example: 'var firstName = Platform.Request.GetFormData("firstName");\nWrite("Hello, " + firstName + "!");',
|
|
1615
1734
|
},
|
|
1616
1735
|
{
|
|
1617
1736
|
name: 'GetPostData',
|
|
@@ -1626,6 +1745,7 @@ export const PLATFORM_REQUEST_METHODS = [
|
|
|
1626
1745
|
],
|
|
1627
1746
|
returnType: 'string',
|
|
1628
1747
|
syntax: 'Platform.Request.GetPostData([encoding])',
|
|
1748
|
+
example: '// Read raw POST body once and store it:\nvar rawBody = Platform.Request.GetPostData();\nvar payload = Platform.Function.ParseJSON(rawBody);',
|
|
1629
1749
|
},
|
|
1630
1750
|
{
|
|
1631
1751
|
name: 'HasSSL',
|
|
@@ -1635,6 +1755,7 @@ export const PLATFORM_REQUEST_METHODS = [
|
|
|
1635
1755
|
params: [],
|
|
1636
1756
|
returnType: 'boolean',
|
|
1637
1757
|
syntax: 'Platform.Request.HasSSL()',
|
|
1758
|
+
example: 'if (Platform.Request.HasSSL()) {\n Write("Secure connection");\n} else {\n Platform.Response.Redirect("https://" + Platform.Request.RequestURL());\n}',
|
|
1638
1759
|
},
|
|
1639
1760
|
{
|
|
1640
1761
|
name: 'Method',
|
|
@@ -1644,6 +1765,7 @@ export const PLATFORM_REQUEST_METHODS = [
|
|
|
1644
1765
|
params: [],
|
|
1645
1766
|
returnType: 'string',
|
|
1646
1767
|
syntax: 'Platform.Request.Method()',
|
|
1768
|
+
example: 'var method = Platform.Request.Method();\nif (method === "POST") {\n var body = Platform.Request.GetPostData();\n // handle POST\n}',
|
|
1647
1769
|
},
|
|
1648
1770
|
{
|
|
1649
1771
|
name: 'RequestURL',
|
|
@@ -1653,6 +1775,7 @@ export const PLATFORM_REQUEST_METHODS = [
|
|
|
1653
1775
|
params: [],
|
|
1654
1776
|
returnType: 'string',
|
|
1655
1777
|
syntax: 'Platform.Request.RequestURL()',
|
|
1778
|
+
example: 'var url = Platform.Request.RequestURL();\nWrite("Current page: " + url);',
|
|
1656
1779
|
},
|
|
1657
1780
|
{
|
|
1658
1781
|
name: 'GetCookieValue',
|
|
@@ -1664,6 +1787,7 @@ export const PLATFORM_REQUEST_METHODS = [
|
|
|
1664
1787
|
],
|
|
1665
1788
|
returnType: 'string',
|
|
1666
1789
|
syntax: 'Platform.Request.GetCookieValue(cookieName)',
|
|
1790
|
+
example: 'var sessionId = Platform.Request.GetCookieValue("sessionId");\nif (sessionId) { Write("Session: " + sessionId); }',
|
|
1667
1791
|
},
|
|
1668
1792
|
{
|
|
1669
1793
|
name: 'GetUserLanguages',
|
|
@@ -1673,6 +1797,7 @@ export const PLATFORM_REQUEST_METHODS = [
|
|
|
1673
1797
|
params: [],
|
|
1674
1798
|
returnType: 'string',
|
|
1675
1799
|
syntax: 'Platform.Request.GetUserLanguages()',
|
|
1800
|
+
example: 'var lang = Platform.Request.GetUserLanguages();\nWrite(lang); // e.g. "en-US,en;q=0.9"',
|
|
1676
1801
|
},
|
|
1677
1802
|
];
|
|
1678
1803
|
|
|
@@ -1689,6 +1814,7 @@ export const PLATFORM_CLIENT_BROWSER_METHODS = [
|
|
|
1689
1814
|
],
|
|
1690
1815
|
returnType: 'void',
|
|
1691
1816
|
syntax: 'Platform.ClientBrowser.Redirect(url)',
|
|
1817
|
+
example: 'Platform.ClientBrowser.Redirect("https://www.example.com/landing");',
|
|
1692
1818
|
},
|
|
1693
1819
|
{
|
|
1694
1820
|
name: 'Write',
|
|
@@ -1700,6 +1826,7 @@ export const PLATFORM_CLIENT_BROWSER_METHODS = [
|
|
|
1700
1826
|
],
|
|
1701
1827
|
returnType: 'void',
|
|
1702
1828
|
syntax: 'Platform.ClientBrowser.Write(content)',
|
|
1829
|
+
example: 'Platform.ClientBrowser.Write("<h1>Hello, World!</h1>");',
|
|
1703
1830
|
},
|
|
1704
1831
|
{
|
|
1705
1832
|
name: 'SetCookie',
|
|
@@ -1716,6 +1843,7 @@ export const PLATFORM_CLIENT_BROWSER_METHODS = [
|
|
|
1716
1843
|
],
|
|
1717
1844
|
returnType: 'void',
|
|
1718
1845
|
syntax: 'Platform.ClientBrowser.SetCookie(name, value[, expires, path, domain, secure])',
|
|
1846
|
+
example: 'Platform.ClientBrowser.SetCookie("userId", subscriberKey, "12/31/2025", "/", ".example.com", true);',
|
|
1719
1847
|
},
|
|
1720
1848
|
{
|
|
1721
1849
|
name: 'RemoveCookie',
|
|
@@ -1727,6 +1855,7 @@ export const PLATFORM_CLIENT_BROWSER_METHODS = [
|
|
|
1727
1855
|
],
|
|
1728
1856
|
returnType: 'void',
|
|
1729
1857
|
syntax: 'Platform.ClientBrowser.RemoveCookie(name)',
|
|
1858
|
+
example: 'Platform.ClientBrowser.RemoveCookie("userId");',
|
|
1730
1859
|
},
|
|
1731
1860
|
{
|
|
1732
1861
|
name: 'SetResponseHeader',
|
|
@@ -1739,6 +1868,7 @@ export const PLATFORM_CLIENT_BROWSER_METHODS = [
|
|
|
1739
1868
|
],
|
|
1740
1869
|
returnType: 'void',
|
|
1741
1870
|
syntax: 'Platform.ClientBrowser.SetResponseHeader(headerName, value)',
|
|
1871
|
+
example: 'Platform.ClientBrowser.SetResponseHeader("Cache-Control", "no-store, no-cache");',
|
|
1742
1872
|
},
|
|
1743
1873
|
{
|
|
1744
1874
|
name: 'RemoveResponseHeader',
|
|
@@ -1750,6 +1880,7 @@ export const PLATFORM_CLIENT_BROWSER_METHODS = [
|
|
|
1750
1880
|
],
|
|
1751
1881
|
returnType: 'void',
|
|
1752
1882
|
syntax: 'Platform.ClientBrowser.RemoveResponseHeader(headerName)',
|
|
1883
|
+
example: 'Platform.ClientBrowser.RemoveResponseHeader("X-Powered-By");',
|
|
1753
1884
|
},
|
|
1754
1885
|
];
|
|
1755
1886
|
|
|
@@ -1757,6 +1888,34 @@ export const platformClientBrowserMethodNames = new Set(
|
|
|
1757
1888
|
PLATFORM_CLIENT_BROWSER_METHODS.map((m) => m.name.toLowerCase()),
|
|
1758
1889
|
);
|
|
1759
1890
|
|
|
1891
|
+
// ── Platform.Recipient methods ───────────────────────────────────────────────
|
|
1892
|
+
// Methods available under Platform.Recipient.* for accessing recipient/subscriber
|
|
1893
|
+
// attribute values and sendable data extension fields during email sends.
|
|
1894
|
+
|
|
1895
|
+
export const PLATFORM_RECIPIENT_METHODS = [
|
|
1896
|
+
{
|
|
1897
|
+
name: 'GetAttributeValue',
|
|
1898
|
+
minArgs: 1,
|
|
1899
|
+
maxArgs: 1,
|
|
1900
|
+
description:
|
|
1901
|
+
'Returns the value of a subscriber attribute or sendable data extension field for the current recipient.',
|
|
1902
|
+
params: [
|
|
1903
|
+
{
|
|
1904
|
+
name: 'attributeName',
|
|
1905
|
+
description: 'Name of the subscriber attribute or sendable DE field to retrieve',
|
|
1906
|
+
type: 'string',
|
|
1907
|
+
},
|
|
1908
|
+
],
|
|
1909
|
+
returnType: 'string',
|
|
1910
|
+
syntax: 'Platform.Recipient.GetAttributeValue(attributeName)',
|
|
1911
|
+
example: 'var email = Platform.Recipient.GetAttributeValue("EmailAddress");\nPlatform.Response.Write(email);',
|
|
1912
|
+
},
|
|
1913
|
+
];
|
|
1914
|
+
|
|
1915
|
+
export const platformRecipientMethodNames = new Set(
|
|
1916
|
+
PLATFORM_RECIPIENT_METHODS.map((m) => m.name.toLowerCase()),
|
|
1917
|
+
);
|
|
1918
|
+
|
|
1760
1919
|
// ── Script.Util HTTP constructors ────────────────────────────────────────────
|
|
1761
1920
|
// Request handler constructors under the Script.Util namespace.
|
|
1762
1921
|
// Instantiated with `new Script.Util.HttpRequest(url)` etc.
|