How to use "oN24 Attendee" script-accessible objects

Yan_Mak
Level 2

Hi, 

 

I am trying to see what I can do with the:
${oN24Attendee_cList.get(0).eventid} or ${oN24Attendee_cList.get(0).email} On24 Attendee Object.

 

My idea is to look up the ON24 event id to check if the lead $attendee the webinar or not. I think this should be possible by using oN24Attendee_cList.get(0).eventid?? 

Something like this? 

 

#foreach( $attendee in $oN24Attendee_cList )
#if($attendee.eventid == 3046872)
<h4>I watched Webinar</h4>
#elseif ( Lead is noshow??)
<h4>I did not watched Webinar</h4>
#end
#end

 

14 REPLIES 14
SanfordWhiteman
Level 10 - Community Moderator

#foreach( $attendee in $oN24Attendee_cList )
#if($attendee.eventid == 3046872)
<h4>I watched Webinar</h4>
#elseif ( Lead is noshow??)
<h4>I did not watched Webinar</h4>
#end
#end

This is somewhat of a start, though you should be using .equals(), not ==.

 

But you have to know the property names (field names on the CO). Not sure what you’re trying to do here. It seems like you want to switch on some other property name, but you need to find that name in the tree in Script Editor.

Yan_Mak
Level 2

Hi, 

I don't see other names on the tree in Script Editor. 😖

I am trying to show content on top of the email or on the bottom of the email depending on the lead attendee some webinars from the past. 

 

I did a test on myself, which I attended the webinar, and the "I watched webinar" and the "I did not watch the webinar" both show up on the email. So I am just thinking maybe I can add an "else if" for the "did not watch"? 

SanfordWhiteman
Level 10 - Community Moderator

I don't see other names on the tree in Script Editor. 😖

Then you have no other fields to determine what they did during the webinar or not? That isn’t right. There should be a number of fields detailing the person’s attendance (minutes watched, etc.). That’s what makes the custom object useful as opposed to just program status (which you also must have).

 

Anyway, your other logic does not make sense. You need to avoid code for the moment because I can tell Velocity is unfamiliar. Describe your technical goals in full — don’t try to write Velocity.

Yan_Mak
Level 2

Here are the goals:

In a smart campaign, it will send out a dynamic content email:

- If watched the selected webinar, then that related content will show at the bottom of the email.

- If did not watch the selected webinar, then that related content will show at the top of the email.

 

There will be 5 past-selected webinars.  So I want to look up 5 webinar IDs.

*But I will talk with our Admin, I don't know why I only see oN24 Attendee on the tree, hope is something show and hides on the setting. 

Jo_Pitts1
Level 10 - Community Advisor

@Yan_Mak ,

are you saying you want to display content for EACH of the five webinars - with content for the un-watched Webinars at the top and the content for the watched Webinars at the bottom?

Cheers

Jo

Yan_Mak
Level 2

@Jo_Pitts1 

Yes.

Jo_Pitts1
Level 10 - Community Advisor

OK.  And does the ON24 list ONLY have records for the Webinars that have been viewed by a Person?

 

Yan_Mak
Level 2

@Jo_Pitts1 

Yes, only oN24 Attendee on the tree. 

Jo_Pitts1
Level 10 - Community Advisor

And you have a known event ID/Name for each of the 5 Webinars.

 

So, there is probably a more elegant way, but if it were me, I'd:

  1. Create a master map of the 5 Webinars with the ID as key, and both the text for viewed and the next for not viewed.
  2. Iterate your CO list and match against your master webinar map.  Use this to build up a NEW map of viewed Webinars with the viewed text and the Webinar ID.
  3. Iterate the master webinar map and test for all the webinars not in the viewed map.  Use this to build up a NEW map of unviewed Webinars
  4. Iterate your unviewed map and display output.
  5. Iterate your viewed map and display output.

The nice thing about this approach is that if you add more webinars, you just need to add them to the master map and everything will keep working without the need for additional if then statements.

 

This code is untested and I'm sure full of bugs (that @SanfordWhiteman will both point out, and also detail a better way of doing things), but something along these lines:

 

#set( $viewedWebinarDetails = {} )
#set( $unviewedWebinarDetails = {} )

#set( $allWebinarDetails = {
  124365 : {
    "id":124365,
    "valueViewed":"Congratulations - you watched a webinar about mice",
    "valueUnviewed": "Why haven't you watched this webinar about mice"
  },
  9843524 : {
    "id":9843524 ,
    "valueViewed":"Congratulations - you watched a webinar about the great wall of china",
    "valueUnviewed": "Why haven't you watched this webinar.  It talks about dead slaves"
  },
  742353 : {
    "id":742353 ,
    "valueViewed":"Congratulations - you watched a webinar about paint drying",
    "valueUnviewed": "You know you want to watch this.  What could be more exciting"
  }
})

#foreach( $viewedWebinar in $oN24Attendee_cList )
  #set($aWebinar = allWebinarsDetails[$viewedWebinar.eventid])
  #set($dummy = $viewedWebinarsDetails.put[$aWebinar.eventid: {"id":$aWebinar.id, "valueViewed":$aWebinar.valueViewed}]) 
#end

#foreach ( $aWebinar in allWebinarDetails)
  #set($viewedWebinar = viewedWebinar[$viewedWebinar.eventid])
  #if( ! $viewedWebinar )
    #set($dummy = $unviewedWebinarsDetails.put[$aWebinar.eventid: {"id":$aWebinar.id, "valueUnviewed":$aWebinar.valueUnviewed}]) 
#end

#foreach ( $aWebinar in viewedWebinarDetails)
  $aWebinar.valueViewed
#end

#foreach ( $aWebinar in unviewedWebinarDetails)
  $aWebinar.valueUnviewed
#end

 

 

SanfordWhiteman
Level 10 - Community Moderator

 


This code is untested and I'm sure full of bugs (that @SanfordWhiteman will both point out, and also detail a better way of doing things)

Like the approach but it’s true that it won’t even compile that way.

 

More like

#set( $viewedWebinars = {} )
#set( $unviewedWebinars = {} )

#set( $allWebinarDisplayContent = {
  124365 : {
    "outputViewed":"Congratulations - you watched a webinar about mice",
    "outputUnviewed": "Why haven't you watched this webinar about mice"
  },
  9843524 : {
    "outputViewed":"Congratulations - you watched a webinar about the great wall of china",
    "outputUnviewed": "Why haven't you watched this webinar.  It talks about dead slaves"
  },
  742353 : {
    "outputViewed":"Congratulations - you watched a webinar about paint drying",
    "outputUnviewed": "You know you want to watch this.  What could be more exciting"
  }
})

#foreach( $viewedWebinar in $oN24Attendee_cList )
  #set($details = $allWebinarDisplayContent[$viewedWebinar.eventid] )
  #set($void = $viewedWebinars.put($viewedWebinar.eventid, {"output": $details.outputViewed}) ) 
#end

#foreach ( $webinar in $allWebinarDisplayContent)
  #if( !$viewedWebinars.containsKey($webinar.eventid) )
    #set($details = $allWebinarDisplayContent[$webinar.eventid] )
    #set($void = $unviewedWebinars.put( $webinar.id, {"output": $details.outputUnviewed}) )
  #end
#end

#foreach ( $webinar in $viewedWebinars )
  $webinar.output
#end

#foreach ( $webinar in $unviewedWebinars )
  $webinar.output
#end

 

Jo_Pitts1
Level 10 - Community Advisor

@Yan_Mak ,

have you tried the solution put forward by @SanfordWhiteman and myself?

 

FWIW - you can split @SanfordWhiteman's version into three tokens.  One that does the set up of the two output lists, and then one token each for outputting the data.

 

 

Jo_Pitts1
Level 10 - Community Advisor

@SanfordWhiteman ,

I knew mine wouldn't work as it was, it was hacked together with my slightly janky Velocity skills.  I'm slightly astounded it was as close as it was :).

 

I didn't know about containsKey... that's SUPER handy :), especially as it means the viewedWebinars and unviewedWebinars can just be arrays rather than maps.  I'm very happy to have learned about that today.

 

I notice $void gets chromakeyed differently.  Does it have special meaning vs. $dummy (which I used from a quick look on stackoverflow).

 

Cheers

Jo

 

SanfordWhiteman
Level 10 - Community Moderator

$void isn’t special in Velocity, but we have to use the Java highlighter, and void is special in Java.

 

Speaking of which @Jon_Chen can we get the JavaScript highlighter back, please? It’s giving me a bad vibe to make people highlight JavaScript as Java, when they’re very different.

SanfordWhiteman
Level 10 - Community Moderator

Hi,

 

Why would you be using the first (0th) object in the list?  Don’t you want to act on the object that pertains to their most recent webinar?