Adding Javascript to Cvent Event Pages

Today our registration team were trying to add a jquery slider at the top of a cvent event summary page. Every time we’d add the script tags to the html editor, we’d save it and the script tags would be stripped out.

After hours of testing we called Cvent support team and here is your answer for anyone else trying this.

This is the ONLY way you can add a script to Cvent event pages.

1.  Any scripting can only go into the Event Summary Instructions section. Even if the code that uses the script is in a different section, you still have to add the script tags in this section (kind of like the <head> section in a regular page)

cvent_Event_editor

 

 

2. You can NOT add the script in the html editor, if you do it will be stripped out! What you have to do is do all your editting in the html editor without the scripting and then save it, then in the small box pictured above you add your script tags. If you ever go back into the html editor, it will also strip out the scripts so always save your code before going into the editor.

 

 

Technorati Tags: , , ,

     

Cvent API: Event Fields and Their Format

When working with Events in the API, many of the fields are searchable but when searching you don’t always know what the format of that field is. Here is an example to help those that are just getting into searching through the event objects.

FieldName,     Value,   Type

ArchiveDate #4/30/2014# Date
archiveDateField #4/30/2014# Date
archiveDateFieldSpecified True Boolean
ArchiveDateSpecified True Boolean
Capacity -1 Integer
capacityField -1 Integer
capacityFieldSpecified True Boolean
CapacitySpecified True Boolean
Category "Meeting" String
categoryField "Meeting" String
City "Las Vegas" String
cityField "Las Vegas" String
ClosedBy "" String
closedByField "" String
Country "USA" String
CountryCode "US" String
countryCodeField "US" String
countryField "USA" String
Currency "U.S. Dollar" String
currencyField "U.S. Dollar" String
EventCode "MYNB4V3XL" String
eventCodeField "MYNB4V3XL" String
EventDescription "" String
eventDescriptionField "" String
EventEndDate #1/26/2014 5:00:00 PM# Date
eventEndDateField #1/26/2014 5:00:00 PM# Date
eventEndDateFieldSpecified True Boolean
EventEndDateSpecified True Boolean
EventLaunchDate #11/1/2013 10:08:07 AM# Date
eventLaunchDateField #11/1/2013 10:08:07 AM# Date
eventLaunchDateFieldSpecified True Boolean
EventLaunchDateSpecified True Boolean
EventStartDate #1/26/2014 8:30:00 AM# Date
eventStartDateField #1/26/2014 8:30:00 AM# Date
eventStartDateFieldSpecified True Boolean
EventStartDateSpecified True Boolean
EventStatus "Active" String
eventStatusField "Active" String
EventTitle "Fly-In: National Standards" String
eventTitleField "Fly-In: National Standards" String
ExternalAuthentication False Boolean
externalAuthenticationField False Boolean
externalAuthenticationFieldSpecified True Boolean
ExternalAuthenticationSpecified True Boolean
Hidden False Boolean
hiddenField False Boolean
Id "45DA1D13-92B1-4871-80FF-3AD7DE724FEE" String
idField "45DA1D13-92B1-4871-80FF-3AD7DE724FEE" String
InternalNote "" String
internalNoteField "" String
LastModifiedDate #11/29/2013 12:14:18 PM# Date
lastModifiedDateField #11/29/2013 12:14:18 PM# Date
lastModifiedDateFieldSpecified True Boolean
LastModifiedDateSpecified True Boolean
Location "The Cosmopolitan of Las Vegas" String
locationField "The Cosmopolitan of Las Vegas" String
MeetingRequestId "00000000-0000-0000-0000-000000000000" String
meetingRequestIdField "00000000-0000-0000-0000-000000000000" String
MessageId Nothing String
messageIdField Nothing String
PhoneNumber "1-000-000-0000" String
phoneNumberField "1-000-000-0000" String
PlannerEmailAddress "registrar@domain.org" String
plannerEmailAddressField "registrar@domain.org" String
PlannerFirstName "Bill" String
plannerFirstNameField "Bill" String
PlannerLastName "Registrar" String
plannerLastNameField "Registrar" String
PlanningStatus "" String
planningStatusField "" String
PostalCode "89109" String
postalCodeField "89109" String
RSVPbyDate #1/20/2014 11:59:00 PM# Date
rSVPbyDateField #1/20/2014 11:59:00 PM# Date
rSVPbyDateFieldSpecified True Boolean
RSVPbyDateSpecified True Boolean
State "Nevada" String
StateCode "NV" String
stateCodeField "NV" String
stateField "Nevada" String
StreetAddress1 "3708 Las Vegas Boulevard South" String
streetAddress1Field "3708 Las Vegas Boulevard South" String
StreetAddress2 "" String
streetAddress2Field "" String
StreetAddress3 "" String
streetAddress3Field "" String
Timezone "Pacific Time" String
timezoneField "Pacific Time" String

Not shown but remember when searching through an Event Custom Field, the structure is

thesearch.Filter(0).Field = “CustomEventField:3AE90367-1300-4BDD-A2D4-81030987F581″
thesearch.Filter(0).Value = “Conference Call”

The API docs show CustomEventField<FieldID> but in cvent (website) if you look at your custom fields the “fieldID” is shown as

Field Stub: 3ae90367-1300-4Bdd-a2d4-81030987f581

 

 

     

Cvent API: Compare Groups with your SQL Database

It’s been a couple years since I created the program to add and delete people from cvent standard groups as they’re added or deleted from our SQL database. Over time some of the groups have gotten out of sync because there will always be times with network outages, cvent is down or the nightly script just goes bad. With 10K users and over 100+ groups these is no way to update att groups all the time because of API limitations through Cvent, So I needed a way to compare the groups. The program I worte can be run every once in a while (maybe every 6 months) and get all groups back in sync.

Again because of the amount of members/groups we have, this needs to be done on a per group basis.

I first created a drop down list of all our Cvent Standard groups, I pulled these from our SQL table that I have our internal group name, cvents group name and cvents group ID. This helped because it doesn’t look as if in Cvent API you can choose between standard and distrubution lists.

Once someone choose the group they wanted to compare, the magic would begin.

First I pull a list of users from our SQL and put them in a list(of T)


Sub GetMembersFromSQL(ByVal groupAbbr As String)

Dim SQLlist As New List(Of Integer)

Using connection As New SqlConnection("Server=YOUR SERVER CONNECTION")

Dim sql As String = "SELECT YOUR MEMBERIDS FROM YOUR GROUP"
 connection.Open()
 Dim command As New SqlCommand(sql, connection)

Using reader As SqlDataReader = command.ExecuteReader()
 While reader.Read()
 SQLlist.Add(reader.GetInt32(reader.GetOrdinal("IndividualID")))
 End While
 End Using
 End Using

GetGroup(ddlGroupNames.SelectedValue)

End Sub

Now we get info from Cvent:

login into to Cvent API (see.. http://tek-works.com/knee-deep-in-cvent-api-logging-in/)

Grab all the id’s of users in the choosen group: (remember Cvent groupID pulled from database and added to the drop down list)


Sub GetGroup(ByVal groupID As String)
 Dim ids As String()
 Dim thesearch As New com.cvent.api.CvSearch()

 thesearch.Filter = New com.cvent.api.Filter(0) {}
 thesearch.Filter(0) = New com.cvent.api.Filter()

thesearch.Filter(0).Field = "GroupId"
 thesearch.Filter(0).Value = groupID

thesearch.Filter(0).Operator = com.cvent.api.CvSearchOperatorType.Equals

ids = _ws.Search(com.cvent.api.CvObjectType.[Contact], thesearch)
 GetCventSourceIDs(ids)
 End Sub

In Cvent we have all users have a sourceid (or at least they should, I also cover later if they don’t have one) but I need that source id to match with our SQL memberid’s

Here we run into another of the API limits, Cvent will only allow you to retrieve up to 200 objects at a time, so if the group has over 200 members, we need to do the retrevials in batches.

This code will retrieve all the id’s but if the list is over 190 (I give a little breathing room) I split the list, you can also see that if the user doesn’t have a sourceID, I put them in a different list, so we can correct it.


Sub GetCventSourceIDs(ByVal ids As String())

Dim objects As com.cvent.api.CvObject()
 Dim i As Int16
Dim Cventlist As New List(Of Integer)
 If ids.Length > 190 Then

 SplitIds(ids)
 Else
 If Not IsDBNull(ids) Then

objects = _ws.Retrieve(com.cvent.api.CvObjectType.contacts, ids) 'drop the s in contacts, it was messing up the blog
 For i = 0 To objects.Length - 1

Dim source As com.cvent.api.Contacts = objects(i) 'drop the s in contacts, it was messing up the blog
 If source.SourceId = "" Then
 NoSourcelist.Add(source.FirstName & " " & source.LastName & "(in Cvent)")
 Else
 Cventlist.Add(source.SourceId)
 End If

 Next i
 End If

LoopThroughLists()
 End If
 End Sub

Sub SplitIds(ByVal ids As String())

Dim arrayString As [String]() = ids
 Dim splitted As New List(Of String())()
 'This list will contain all the splitted arrays.
 Dim lengthToSplit As Integer = 190

Dim arrayLength As Integer = arrayString.Length

Dim i As Integer = 0
 While i < arrayLength
 Dim val As String() = New String(lengthToSplit - 1) {}

If arrayLength < i + lengthToSplit Then
 lengthToSplit = arrayLength - i
 End If
 Array.Copy(arrayString, i, val, 0, lengthToSplit)
 splitted.Add(val)
 i = i + lengthToSplit
 End While

Dim WhatsTheLength As Integer = splitted.Count
 Dim j As Integer = 0
 Dim k As Integer = 0
 Dim objects As com.cvent.api.CvObject()

 If Not IsDBNull(ids) Then
 While k < WhatsTheLength
 objects = _ws.Retrieve(com.cvent.api.CvObjectType.Contacts, splitted(k)) 'drop the s in contacts, it was messing up the blog
 For j = 0 To objects.Length - 1

 Dim source As com.cvent.api.Contacts = objects(j) 'drop the s in contacts, it was messing up the blog
 If source.FirstName = "" Then

Else
 If source.SourceId = "" Then
 NoSourcelist.Add(source.FirstName & " " & source.LastName & "(in Cvent)")
 Else
 Cventlist.Add(source.SourceId)
 End If
 End If
 Next j
 k = k + 1
 End While
 End If

LoopThroughLists()

End Sub

Now that we have a list of people that should be in the group (from our SQL) and people that are in the group (from Cvent) we can compare them. Since you can’t do a compare with list (of T) I loop through each list and see if that memberid is in the other list, this gives me an oput put of who isn’t in each list, I then know who needs deleted from the Cvent group (because they shouldn’t be there) and who needs added to the cvent group (because they’re in our SQL group)


Sub LoopThroughLists()
Dim CventListID As Integer
 For Each objectItem As Object In Cventlist

 CventListID = objectItem

 Dim IsInCventresult As Integer = SQLlist.Find(AddressOf FindIDinSQL)
 If InSQLReturned = "False" Then
 NotinSQL = NotinSQL & " " & getindividualnames(CventListID)

 End If
 Next

For Each objectSQLItem As Object In SQLlist

 SQLListID = objectSQLItem

 Dim IsInSQLresult As Integer = Cventlist.Find(AddressOf FindIDinCvent)
 If InCventReturned = "False" Then
 NotinCvent = NotinCvent & " " & getindividualnames(SQLListID)

 End If
 Next

End Sub

Private Function FindIDinSQL(ByVal bk As Integer) As Boolean
 'looks for cvent id in sql list
 If bk = CventListID Then
 InSQLReturned = "True"
 Return True
 Else
 InSQLReturned = "False"
 Return False
 End If
 End Function
 Private Function FindIDinCvent(ByVal bk1 As Integer) As Boolean
 'looks for sql id in cvent list
 If bk1 = SQLListID Then
 InCventReturned = "True"
 Return True
 Else
 InCventReturned = "False"
 Return False
 End If
 End Function

from here I now have my list of who to delete and who to add. For now I list them out and they can be manually done, my next step is to add a module to use the Cvent API add/delete those that are in each list (I just didn’t have time, since this was a something we need but do it between projects type of program)

     

Umbraco MSSQL Settings

Starting from nothing, I’ve never seen Umbraco or messed with it, so I figured the best way to learn is to install it. I installed Umbraco v6.1.6, the latest stable version.

My first install was through Microsofts Web Platform installer but 2 days after my install there was an update and I figured if I was going to be taking care of this beast, I should know how to do everything on it, so manual install it was.

I deleted everything and deleted the SQL database and started the manual install. Everything went as planned until I couldn’t connect to the sql server. I have other sites connecting to the server so I knew something was wrong with the user I created for the Umbraco DB.

After some seraching I came across a great walk through for the manual Umbraco install on Windows 2008 (works for Windows 2008 r2 also) http://our.umbraco.org/wiki/install-and-setup/how-to-install-umbraco-on-windows-server-2008

Step 4: Setup database

Open up SQL Server Management Studio and add a database by right-clicking on Databases and choosing New database. Give your database a name, and click “OK”.

The create a user for your database by going to Security and right-clicking on “Logins” and choosing “New login”. Give your user a name (for example: umbracouser), choose SQL Server authentication, and enter a password.

Then go to User Mapping and in the list that appears, check the database you just created. Then you check the following roles in the “Database role membership” list:

db_datareader

db_datawriter

db_ddladmin

db_securityadmin

public

Click “OK”.

After setting the user mappings to the correct settings, I could connect to the SQL server/database and I was next asked which starter kit I wanted.

And so the long road starts…..

     

Learning Umbraco

Work has decided that with taking care of our network, SQL Server, Webserver, doing all the development and admining all of this, that I don’t have enough under my belt. So I will be begining a deep dive into Umbraco. Umbraco is a CMS written in .net and runs on windows servers. As I slowly learn Umbraco, I’ll be posting what I’ve learned and any work arounds I come across.

     

Fixing: There is already an object named ‘sysnsobjs’ in the database

(I am not a DBA, I play one at work because I’ve been thrown into the position since I do all the .net programming, why shouldn’t I take care of the SQL server and web server also.. So this is what worked for me and probably are no where close to best practices)

My task: Move a database from SQL2000 to SQL2008 R2

Error:
System.Data.SqlClient.SqlError: There is already an object named ‘sysnsobjs’ in the database. (Microsoft.SqlServer.Smo)

Why I got this error:
I knew going into this that we’d have a problem. When I started at my company the SQL DB was already created for our website. Who ever it was, they just started throwing data into the master db and left it at that. Fast forward 10 years, I had made a copy of the db and made it, it’s own db but still I knew the copy of system files were still in there and when time came to do a update we were going to have problems. So it was no suprise when I received the error that a system file already existed.

What doesn’t work:
Looking online I’ve seen many people ask about this error and after about 2-3 pages of try this and try that, most just either give up or create some script to pull the data and create tables on a one off basis. So we know that a restore from backup doesn’t work, it gives our error of There is already an object named ‘sysnsobjs’ in the database.

So what about import data from one server to the other?
I created a new Database, named it the same as my sql2000 db and did an import from one server (2000) to the new server(2008 r2). At first glance all looked good, my tables were there and data and my stored procedures were all there but then when I checked on views, there was nothing. All the views were imported as tables (someone explained that it’s because that’s really what they are), so importing failed.

So what worked for me: A Walk through:

Importing from one db to the other but still on the SQL2000 server mostly worked.

1. Create your new db on the current (old) server

2. Right click new db and choose import

3. Choose your source and destination db’s

4. Instead of choosing “Copy tables and views from source database” choose “Copy objects and data between SQL Server databases”

5. On the select Ojects to Copy screen

objectstocopysql

uncheck Copy all objects and hit the button Select objects (choose everything, check everything)

uncheck use default objects, click Options button. Check everything except Generate Scripts in Unicode

copyoptionssql

6. Go have lunch this will take awhile

importsqldb

Mine actually failed (but not because of the system files) mine failed becuse of 2 views but everything else was copied over correctly.

7. Now make a backup of this new database

8. Copy bak file to new database server

9. Restore DB on new server

Make sure to check your permissions but all should be there and ready to use. Since you only need to make sure this DB is the same as your last (If you have both SQL servers still running) us something like the demo of http://www.sqlaccessories.com/SQL_Examiner_Suite/ to compare the table structure and it will also compare all of your stored procedures.

     

Cvent API: Multiple Searches

Narrowing Down a Search with Cvent API

In the past all of my searches in Cvent have been one search to find what I needed but today I ran into a problem. While doing a search for all users that have taken one of our surveys, the search returned 505 people. The next line does a Retrieve of those records, this is where my problem ended up. Cvent limits you to 200 Retrievals per call, so I either had to breakup the array or get less records.

My current code:


thesearch.Filter = New com.cvent.api.Filter(0) {}
 thesearch.Filter(0) = New com.cvent.api.Filter()

thesearch.Filter(0).Field = "Surveyid"

 thesearch.Filter(0).Value = "c382ea11-8825-4161-8513-########"
 thesearch.Filter(0).Operator = com.cvent.api.CvSearchOperatorType.Equals

ids = _ws.Search(com.cvent.api.CvObjectType.Respondent, thesearch)

There had to be away to do a deeper search, specially with the small retrieval requirements. I figured out that you can add more filters and require it to use AND or OR with them.

And or OR is controlled by:


thesearch.SearchType = com.cvent.api.CvSearchType.AndSearch

OR


thesearch.SearchType = com.cvent.api.CvSearchType.ORSearch

Adding more indepth searches (filters). This searches for the survey but also only those who have finished the survey which so far is only 10


'build array size
 thesearch.Filter = New com.cvent.api.Filter(1) {}
'new for array row 0
 thesearch.Filter(0) = New com.cvent.api.Filter()
'new for array row 1
 thesearch.Filter(1) = New com.cvent.api.Filter()
'type of search between filters
 thesearch.SearchType = com.cvent.api.CvSearchType.AndSearch
 thesearch.Filter(0).Field = "SurveyId"
 thesearch.Filter(0).Value = "c382ea11-8825-4161-8513-b977568b50f8"
 thesearch.Filter(0).Operator = com.cvent.api.CvSearchOperatorType.Equals

 thesearch.Filter(1).Field = "Status"
 thesearch.Filter(1).Value = "Complete Response" 'Real Survey
 thesearch.Filter(1).Operator = com.cvent.api.CvSearchOperatorType.Equals

Luckly, This survey will only have around 100 respondents, but what if at some point I need to import 200+, I guess that will be another blog post.

Technorati Tags: , , , , ,

     

vb.net variable name within a variable

 Otherwise know as “variable string to variable” or “How to blow you mind thinking about variables”

Here’s the setup:

3 Variables


 Dim PTCompSalE As Int32 = 0
 Dim PTCompSalX As Int32 = 0
 Dim PTCompSalM As Int32 = 0

Through a series of  Select Case statements I end up with another variable (FullColumnName) that equals the name of one of the above:

Dim FullColumnName As String

Dim beginColumn As String  'PTComp
Dim middleColumn As String  'Sal
Dim endColumn As String  'X

FullColumnName = beginColumn & middleColumn & endColumn   'equals PTCompSalX

The question is, now that I know which variable I want to change values of (PTCompSalX) how do I tell asp.net that I want to change the value of PTCompSalX when the name is actually in another variable?
I could make a Select Case which would work if like in the example I only had 3 options but I have hundreds of options.
After hours of searching I found that Reflection is what I needed, Thanks to shaul_ahuva at Xtreme Visual Basic Talk.

Dim t As Type = Me.GetType()
Dim fi As FieldInfo = t.GetField(FullColumnName) 'get the value of FullColumnName's string reference
fi.SetValue(Me, 1) 'change the value of FullColumnName's string reference

Now PTCompSalX = 1

This allows me to use FullColumnName’s String to find the original variable and change the string for that original variable. Mind Blown!
While Reflection is something new to be, it looks like it will be on my To Read List.

[answer found]

Technorati Tags: , , , ,

     

Adding a Web Reference in Visual Studio 2008

I’ve been doing most of my current projects in Visual Studio 2008, but when I was doing CVent API development I was using Visual Studio 2005. Today I needed to add the web reference for CVent’s API to a windows application I was creating.

First thing I noticed was the Add Web Reference option when I’d right click the project was missing. After a small amount of searching I was able to find the Add Web Reference option but it’s a bit hidden. Like in VS2005 right click the project but instead of Add Web Reference choose Add Service Reference

At the bottom of the Add Service Reference window, click the Advanced button

At the bottom of the Advanced window is the Add Web Reference button we’ve been looking for.

From here you’ll be able to add the Web Reference for your project. Here I’ve added CVents API, which is https:// so I had to click “allow the page” multiple times and also tell VS2008 not to block the page, thanks IE..

Technorati Tags: , , , , , ,

     

Validating or Validation of a CheckBoxList

On my web form I came across an instance that I needed a user to either check a box from a checkboxlist or leave a comment, this then would be emailed to someone. So I needed to validate that a checkbox had been checked or at least a comment was added.

On my button I added onclick=”Control_Click”


<asp:Button id="btnSend" runat="server" CssClass="submitLarge" onclick="Control_Click" Text="SEND"></asp:Button>

Then in the codebehind I added the code to validate and then if validation is true, I send email.

Sub Control_Click(ByVal S As Object, ByVal E As EventArgs)
 validate_chkboxlist()
 Dim sb As New System.Text.StringBuilder

If valChkBoxList = True Then
 CreateEmail()
 Else
lblMessage.Text = "<font color=""#FF0000""><b>You must select at least one CheckBox or add a comment!</b></font>"
 End If

 End Sub

Sub validate_chkboxlist()
 For ii = 0 To (cblInterest.Items.Count - 1)
 If (cblInterest.Items(ii).Selected) Or txtComments.Text <> "" Then
 valChkBoxList = True
 Exit Sub
 End If
 Next
 End Sub

As you can see, from Control_Click I call the validate_chkboxlist. In validate_chkboxlist I loop through the checkboxes but also check that the comment.text isn’t blank. If a box is checked or the commentbox has text in it, valChkBoxList is marked as true and the email is sent.

Technorati Tags: , , , , , ,