Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %%[
- VAR @sfid, @contactId, @centre, @email, @subLanguage, @rowCountSub, @subscriptionRow, @subscription, @contact, @rowCountCon, @contactRow, @today, @valid, @emailaddr, @ts, @tsDef, @ts_sub, @ts_statusCode, @errorCode
- SET @sfid = REQUESTPARAMETER('sk')
- SET @exp = REQUESTPARAMETER('exp')
- SET @today = FormatDate(Now(), 'yyyy-MM-dd')
- SET @subscription = RetrieveSalesforceObjects('MAG_Subscription__c', 'MAG_Language__c, MAG_Centre__c, MAG_Contact__c', 'Id', '=', @sfid)
- SET @rowCountSub = rowCount(@subscription)
- IF @rowCountSub > 0 THEN
- SET @subscriptionRow = Row(@subscription, 1)
- SET @subLanguage = FIELD(@subscriptionRow, 'MAG_Language__c')
- SET @contactId = FIELD(@subscriptionRow, 'MAG_Contact__c')
- SET @centre = FIELD(@subscriptionRow, 'MAG_Centre__c')
- ENDIF
- SET @contact = RetrieveSalesforceObjects('Contact', 'Email', 'Id', '=', @contactId)
- SET @rowCountCon = rowCount(@contact)
- IF @rowCountCon > 0 THEN
- SET @contactRow = Row(@contact, 1)
- SET @email = FIELD(@contactRow, 'Email')
- ENDIF
- IF @exp > @today THEN
- SET @valid = TRUE
- ELSE
- SET @valid = FALSE
- ENDIF
- IF @centre == 'Athens' and @valid == TRUE THEN
- SET @ts = CreateObject("TriggeredSend")
- SET @tsDef = CreateObject("TriggeredSendDefinition")
- SetObjectProperty(@tsDef, "CustomerKey", "test_trigger_2")
- SetObjectProperty(@ts, "TriggeredSendDefinition", @tsDef)
- SET @ts_sub = CreateObject("Subscriber")
- SetObjectProperty(@ts_sub, "EmailAddress", @email)
- SetObjectProperty(@ts_sub, "SubscriberKey", @contactId)
- AddObjectArrayItem(@ts, "Subscribers", @ts_sub)
- SET @ts_statusCode = InvokeCreate(@ts, @ts_statusMsg, @errorCode)
- ELSE
- SET @ts = CreateObject("TriggeredSend")
- SET @tsDef = CreateObject("TriggeredSendDefinition")
- SetObjectProperty(@tsDef, "CustomerKey", "test_trigger_1")
- SetObjectProperty(@ts, "TriggeredSendDefinition", @tsDef)
- SET @ts_sub = CreateObject("Subscriber")
- SetObjectProperty(@ts_sub, "EmailAddress", @email)
- SetObjectProperty(@ts_sub, "SubscriberKey", @contactId)
- AddObjectArrayItem(@ts, "Subscribers", @ts_sub)
- SET @ts_statusCode = InvokeCreate(@ts, @ts_statusMsg, @errorCode)
- ENDIF
- ]%%
Add Comment
Please, Sign In to add comment