API INVOKE FUNCTIONS

——————–
User initiated
——————–
%%[
var @senddef, @msg, @sc
Set @senddef = CreateObject(“EmailSendDefinition”)
SetObjectProperty(@senddef, “CustomerKey”, “t”)
Set @sc = InvokePerform(@senddef,”start”,@msg)
]%%

%%=v(@sc)=%%

%%=v(@msg)=%%
——————–
My program
——————–
%%[
SET @Program_Start = CreateObject(“Campaign”)
SetObjectProperty(@Program_Start,”CustomerKey”,”EmailTest”)
Set @sc = InvokePerform(@Program_Start,”Stop”,@msg)
]%%

%%=v(@sc)=%%

%%=v(@msg)=%%
——————–
Import Activity
——————–
%%[
SET @Program_Start = CreateObject(“ImportDefinition”)
SetObjectProperty(@Program_Start,”CustomerKey”,”A29DCC12-C2D5-407F-9277-BE0EACB891C5″)
Set @sc = InvokePerform(@Program_Start,”Start”,@msg)
]%%

%%=v(@sc)=%%

%%=v(@msg)=%%
——————–
File Transfer
——————–
%%[
SET @Program_Start = CreateObject(“FileTransferActivity”)
SetObjectProperty(@Program_Start,”CustomerKey”,”Product view file transfer”)
Set @sc = InvokePerform(@Program_Start,”Start”,@msg)
]%%

%%=v(@sc)=%%

%%=v(@msg)=%%

===========================
——————–
Invoke Delete
——————–

%%[SET @Subscriber=CreateObject(“Subscriber”)
SetObjectProperty(@Subscriber,”SubscriberKey”,”e1013″)

SET @list=CreateObject(“SubscriberList”)
SetObjectProperty(@list,”ID”,”3879″)
AddObjectArrayItem(@Subscriber,”Lists”,@list)
InvokeDelete(@Subscriber,@status_msg,@Update_err)

]%%
%%=v(@status_msg)=%%
%%=v(@Update_err)=%%

===========================
——————–
Invoke Retrieve
——————–
%%[
SET @rr2 = CreateObject(“RetrieveRequest”)
SetObjectProperty(@rr2,”ObjectType”,”Subscriber”)
AddObjectArrayItem(@rr2, “Properties”, “ID”)

/* We set the filter to retrieve only the subscriber for whom the email address has been provided */
SET @sfp2 = CreateObject(“SimpleFilterPart”)
SetObjectProperty(@sfp2,”Property”,”EmailAddress”)
SetObjectProperty(@sfp2,”SimpleOperator”,”equals”)
AddObjectArrayItem(@sfp2,”Value”,@Email)

SetObjectProperty(@rr2,”Filter”,@sfp2)
SET @atts = InvokeRetrieve(@rr2,@status)
IF RowCount(@atts) > 0 THEN
/* We must loop over the retrieved attributes and store each needed value in a variable */
SET @subAtts = Field(Row(@atts,1),”Attributes”)
FOR @c = RowCount(@subAtts) DOWNTO 1 DO
SET @att = Row(@subAtts,@c)
SET @att_name = Field(@att,’Name’)
SET @att_val = Field(@att,’Value’)

IF @att_name == “Salutation” THEN
SET @Salutation = @att_val
ENDIF
NEXT @C
ENDIF
]%%
===========================
——————–
Invoke Execute
——————–
%%[SET @lue = CreateObject(“ExecuteRequest”)
SetObjectProperty(@lue,”Name”,”LogUnsubEvent”)

SET @lue_prop = CreateObject(“APIProperty”)
SetObjectProperty(@lue_prop, “Name”, “SubscriberKey”)
SetObjectProperty(@lue_prop, “Value”, “sreedharan.narayan@rediffmail.com”)
AddObjectArrayItem(@lue, “Parameters”, @lue_prop)

SET @lue_prop = CreateObject(“APIProperty”)
SetObjectProperty(@lue_prop, “Name”, “JobID”)
SetObjectProperty(@lue_prop, “Value”, “350171”)
AddObjectArrayItem(@lue, “Parameters”, @lue_prop)

SET @lue_statusCode = InvokeExecute(@lue, @overallStatus, @requestId)

SET @Response = Row(@lue_statusCode, 1)
SET @Status = Field(@Response,”StatusMessage”)
SET @Error = Field(@Response,”ErrorCode”)

]%%

%%=v(@Error)=%%
%%=v(@Status)=%%
%%=v(@overallStatus)=%%

===========================
——————–
Invoke Create
——————–
%%[

/* DataExtensionObject: Object Instantiation */
SET @ob = CreateObject(“Subscriber”)

/* Data Extension Reference */

SetObjectProperty(@ob, “SubscriberKey”, “rams@ExactTarget.com”)
SetObjectProperty(@ob, “EmailAddress”, “rams@ExactTarget.com”)

/* Attribute: Object Instantiation */

SET @attr1 = CreateObject(“Attribute”)
SetObjectProperty(@attr1, “Name”, “FName”)
SetObjectProperty(@attr1, “Value”, “rams”)
/* New Object in ‘Attributes’ List */

AddObjectArrayItem(@ob, “Attributes”, @attr1)

/* Attribute: Object Instantiation */
SET @attr2 = CreateObject(“Attribute”)
SetObjectProperty(@attr2, “Name”, “LName”)
SetObjectProperty(@attr2, “Value”, “rams v”)

/* New Object in ‘Attributes’ List */
AddObjectArrayItem(@ob, “Attributes”, @attr2)

/* DataExtension Object: Create Method Invocation */
SET @obStatus = InvokeCreate(@ob, @obMessage, @errorCode)

/* Catch Exception */
IF @obStatus != “OK” THEN
RaiseError(@obMessage, 0, @obStatus, @errorCode)
ELSE
output(v(“Success”))
ENDIF
]%%

Leave a comment

Create a free website or blog at WordPress.com.

Up ↑