How to use "oN24 Attendee" script-accessible objects

Jo_Pitts1
Level 10 - Community Advisor

Re: How to use "oN24 Attendee" script-accessible objects

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

Re: How to use "oN24 Attendee" script-accessible objects

 


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

Re: How to use "oN24 Attendee" script-accessible objects

@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

Re: How to use "oN24 Attendee" script-accessible objects

$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.

Jo_Pitts1
Level 10 - Community Advisor

Re: How to use "oN24 Attendee" script-accessible objects

@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.