-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchapter16.amp
More file actions
38 lines (30 loc) · 1.5 KB
/
chapter16.amp
File metadata and controls
38 lines (30 loc) · 1.5 KB
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
%%[
/* Declare variables */
var @rows, @dataExtensionName, @attributeToSearch, @valueToSearch, @rowCount, @index, @row
var @column1, @column2, @column3, @id
/* Set the name of the data extension to be used */
set @dataExtensionName = "My_DataExtension"
/* Set the attribute to search by in the data extension */
set @attributeToSearch = {{attributeToSearch}}
/* Set the value to search for in the given attribute */
set @valueToSearch = {{valueToSearch}}
/* Use the LookupRows function to fetch all rows that match the search criteria */
set @rows = LookupRows(@dataExtensionName, @attributeToSearch, @valueToSearch)
/* Get the total number of rows returned by the LookupRows function */
set @rowCount = RowCount(@rows)
/* Check if any rows were returned */
if @rowCount > 0 then
/* Loop through each row and extract values for specified columns */
for @index = 1 to @rowCount do
set @row = Row(@rows, @index)
/* Fetch values for the specified columns and assign them to variables */
{{#columns}}
set @{{column}} = Field(@row, "{{column}}")
{{/columns}}
/* Create Salesforce Lead record */
set @id = CreateSalesforceObject("Lead",{{rows}},
{{#columns_comma}}"{{column}}", @{{column}}{{/columns_comma}}
)
next @index
endif
]%%