-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubscriber_search_in_DE.js
177 lines (136 loc) · 4.68 KB
/
subscriber_search_in_DE.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<script runat="server">
Platform.Load("core","1.1.1");
var foo = Base64Decode('{subscriberkey}');
var MasterDE = 'EngagementEvent';
var SubscriberKeyName = "Subscriber Key";
var debug = false;
function outputstr(any){
Write(Stringify(any));
}
function searchSubInDE(subkeyvalue, deName, key){
var testDE = DataExtension.Init(deName);
var data = testDE.Rows.Lookup([key], [subkeyvalue]);
return data;
}
// load the pub lists and locate the subscriber
try{
if (debug){
Platform.Response.Write('SubscriberKey: '+foo+"<br />");
Platform.Response.Write('Master DE: '+MasterDE+"<br />");
Platform.Response.Write('Subscriber Key Column: '+ SubscriberKeyName+"<br />");
}
// process form post values
var requestMethod = Request.Method();
if (requestMethod=='POST'){
// locate the subscribe object
var result = searchSubInDE(foo,MasterDE,SubscriberKeyName);
if(result.length>0){
if(debug){
Platform.Response.Write("Subscriber Object: ");
outputstr(result);
Platform.Response.Write("<br />");
}
Variable.SetValue("@res",result);
}else{
Variable.SetValue("@error",'No Subscriber Found!');
}
}
}catch (e){
Platform.Response.Write(e);
Variable.SetValue("@error",'Error Occured!');
}
</script>
<title>Event Activity Search</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<style>
* {
box-sizing: border-box;
}
.main {
float:left;
width:60%;
padding:0 20px;
}
.right {
background-color:#e5e5e5;
float:left;
width:20%;
padding:15px;
margin-top:7px;
text-align:center;
}
@media only screen and (max-width:620px) {
/* For mobile phones: */
.menu, .main, .right {
width:100%;
}
}
input[type=text], input[type=date], input[type=email],select {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
input[type=submit], button {
width: 100%;
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
border-radius: 4px;
cursor: pointer;
}
input[type=submit]:hover, button:hover {
background-color: #45a049;
}
div {
border-radius: 5px;
background-color: #f2f2f2;
padding: 20px;
}
@media only screen and (max-width:480px){
/* MOBILE GLOBAL STYLES - DO NOT CHANGE */
body, .tb_properties{font-family: Arial !important; font-size: 16px !important; color: #808080 !important; line-height: 1 !important; padding: 0px !important; }.buttonstyles{font-family: Arial !important; font-size: 16px !important; color: #FFFFFF !important; padding: 0px !important; }h1{font-family: Arial !important; font-size: 22px !important; color: #202020 !important; line-height: 1 !important; }h2{font-family: Arial !important; font-size: 20px !important; color: #202020 !important; line-height: 1 !important; }h3{font-family: Arial !important; font-size: 18px !important; color: #202020 !important; line-height: 1 !important; }a:not(.buttonstyles){line-height: 1 !important; }.mobile-hidden{display: none !important; }.responsive-td {width: 100% !important; display: block !important; padding: 0 !important;}
/* END OF MOBILE GLOBAL STYLES - DO NOT CHANGE */
}</style>
<div style="background-color:#e5e5e5;padding:15px;">
<h2>Event Activity Search</h2>
</div>
%%[ if empty(@error) then ]%%
<div style="overflow:auto">
<div class="main">
<form id="newObjectform" action="%%= RequestParameter('PAGEURL') =%%" method="post">
<label class="inputLabel">Subscriber Key: </label>
<input type="text" name="subscriberkey" value="" required="" maxlength="40">
<button class="button3" type="submit"> Search </button>
</form>
</div>
<div class="">
<script runat="server">
var result = Variable.GetValue("@res");
Write('<table><tr><th>Type</th>');
Write('<th>Event Date</th>');
Write('<th>Name</th>');
Write('<th>Job Name</th></tr>');
for (var index in result){
Write('<tr>');
Write('<td>Type: '+index["Type"]+'</td>');
Write('<td>Event Date: '+index["Event Date"]+'</td>');
Write('<td>Name: '+index["Name"]+'</td>');
Write('<td>Job Name: '+index["Job Name"]+'</td>');
Write('</tr>');
}
Write('</table>');
</script>
</div>
</div>
%%[
ELSE
outputLine(concat("Error Message: ", @error))
ENDIF
]%%
<div style="background-color:#e5e5e5;padding:10px;margin-top:7px;">© copyright Lavabox</div>