単一データエクステンションレコード内のフィールドの動的リストの更新

データエクステンションには、購読センターからのデータなど、購読者からの更新を必要とする多くの情報が含まれている可能性があります。ただし、使用可能なすべてのフィールドをすべての購読者に表示したくない場合があります。また、一部の購読者は他の購読者よりも多くのフィールドを参照する場合があります。この手順では、データエクステンション内の一部のフィールドを公開せずに、特定の購読者に公開するフィールドのみを更新する呼び出しを作成します。

次のサンプル AMPscript を独自のスクリプトを作成するためのひな型として使用してください。

1%%[
2/* We must keep retrieving querystring parameters for each value passed over from the front end */
3SET @email = RequestParameter("email")
4
5IF NOT EMPTY(@email) THEN
6
7/* Now get the total number of fields in the form (added as a hidden field to store the counter). */
8/* Since this is a pre-populating form, the user may have checked or unchecked options. This call must save/update them all. */
9SET @ListNum = RequestParameter("listnum")
10IF @ListNum > 0 THEN
11
12/* Build Subscriber Object & set properties in order to update */
13SET @sub_de = CreateObject("DataExtensionObject")
14SetObjectProperty(@sub_de,"CustomerKey", "Downstream_Subscriber_Preference")
15
16set @Attrib = CreateObject("APIProperty")
17SetObjectProperty(@Attrib,"Name","Email Address")
18SetObjectProperty(@Attrib,"Value",@email)
19AddObjectArrayItem(@sub_de,"Properties", @Attrib)
20
21SET @subrows = LookupOrderedRows("Downstream_Subscriber_Preference", 1, "Email Address", "Email Address", @email)
22SET @alreadysub = false
23IF RowCount(@subrows)==1 THEN
24SET @alreadysub = true
25ENDIF
26
27FOR @l = 1 TO @ListNum DO
28
29/* This is where the call populates the Subscriber preference record with the changes made on the front-end */
30SET @listval = RequestParameter(Concat("list",@l))
31SET @status = IIF(@listval == "on", "true", "false")
32SET @ListName = RequestParameter(Concat("listname",@l))
33Set @Attrib = CreateObject("APIProperty")
34SetObjectProperty(@Attrib,"Name",@ListName)
35SetObjectProperty(@Attrib,"Value",@status)
36AddObjectArrayItem(@sub_de,"Properties", @Attrib)
37NEXT @l
38
39/* Here is where we actually update the Subscriber object */
40IF @alreadysub THEN
41Set @update_sub = InvokeUpdate(@sub_de,@update_sub_status,@update_sub_errorcode,@options)
42ELSE
43Set @update_sub = InvokeCreate(@sub_de,@update_sub_status,@update_sub_errorcode,@options)
44ENDIF
45
46IF @update_sub == "OK" THEN
47/* Will display success on the Front End page */
48]%% <b>Your Information has been Saved Successfully!</b>
49
50%%[
51ELSE
52]%% <b><font color="red">%%=v(@update_sub)=%%! %%=v(@update_sub_status)=%% </font></b>
53%%[
54ENDIF
55
56ELSE
57%% <b><font color="red"> Error: No List Items found </font></b>
58%%[
59ENDIF
60
61ELSE
62]%% Bad Email value %%[
63ENDIF
64]%%