Guest User

Untitled

a guest
Dec 11th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. %%[
  2. VAR @sfid, @contactId, @centre, @email, @subLanguage, @rowCountSub, @subscriptionRow, @subscription, @contact, @rowCountCon, @contactRow, @today, @valid, @emailaddr, @ts, @tsDef, @ts_sub, @ts_statusCode, @errorCode
  3. SET @sfid = REQUESTPARAMETER('sk')
  4. SET @exp = REQUESTPARAMETER('exp')
  5. SET @today = FormatDate(Now(), 'yyyy-MM-dd')
  6.  
  7. SET @subscription = RetrieveSalesforceObjects('MAG_Subscription__c', 'MAG_Language__c, MAG_Centre__c, MAG_Contact__c', 'Id', '=', @sfid)
  8. SET @rowCountSub = rowCount(@subscription)
  9.  
  10. IF @rowCountSub > 0 THEN
  11.  
  12. SET @subscriptionRow = Row(@subscription, 1)
  13. SET @subLanguage = FIELD(@subscriptionRow, 'MAG_Language__c')
  14. SET @contactId = FIELD(@subscriptionRow, 'MAG_Contact__c')
  15. SET @centre = FIELD(@subscriptionRow, 'MAG_Centre__c')
  16.  
  17. ENDIF
  18.  
  19. SET @contact = RetrieveSalesforceObjects('Contact', 'Email', 'Id', '=', @contactId)
  20. SET @rowCountCon = rowCount(@contact)
  21.  
  22. IF @rowCountCon > 0 THEN
  23.  
  24. SET @contactRow = Row(@contact, 1)
  25. SET @email = FIELD(@contactRow, 'Email')
  26.  
  27. ENDIF
  28.  
  29.  
  30. IF @exp > @today THEN
  31. SET @valid = TRUE
  32. ELSE
  33. SET @valid = FALSE
  34. ENDIF
  35.  
  36. IF @centre == 'Athens' and @valid == TRUE THEN
  37. SET @ts = CreateObject("TriggeredSend")
  38. SET @tsDef = CreateObject("TriggeredSendDefinition")
  39.  
  40. SetObjectProperty(@tsDef, "CustomerKey", "test_trigger_2")
  41. SetObjectProperty(@ts, "TriggeredSendDefinition", @tsDef)
  42.  
  43. SET @ts_sub = CreateObject("Subscriber")
  44. SetObjectProperty(@ts_sub, "EmailAddress", @email)
  45. SetObjectProperty(@ts_sub, "SubscriberKey", @contactId)
  46.  
  47. AddObjectArrayItem(@ts, "Subscribers", @ts_sub)
  48.  
  49. SET @ts_statusCode = InvokeCreate(@ts, @ts_statusMsg, @errorCode)
  50.  
  51. ELSE
  52. SET @ts = CreateObject("TriggeredSend")
  53. SET @tsDef = CreateObject("TriggeredSendDefinition")
  54.  
  55. SetObjectProperty(@tsDef, "CustomerKey", "test_trigger_1")
  56. SetObjectProperty(@ts, "TriggeredSendDefinition", @tsDef)
  57.  
  58. SET @ts_sub = CreateObject("Subscriber")
  59. SetObjectProperty(@ts_sub, "EmailAddress", @email)
  60. SetObjectProperty(@ts_sub, "SubscriberKey", @contactId)
  61.  
  62. AddObjectArrayItem(@ts, "Subscribers", @ts_sub)
  63.  
  64. SET @ts_statusCode = InvokeCreate(@ts, @ts_statusMsg, @errorCode)
  65. ENDIF
  66. ]%%
Add Comment
Please, Sign In to add comment