Kengolding’s Blog

Blogging about Junxure and CRM

Adding a Button to the Custom Database

Posted by kengolding on September 26, 2009

 

Hooking up the custom database to the Junxure Client Form

In Junxure, you have the ability to hook up a custom Access database to the
client form.  Once it is hooked up, you will have a new button on the top
left of the client form.


Clicking this button will open the custom database to the form that you have
specified in the options settings.  The beauty of this, is that you can
then build the form in your custom database to open for the client that you are
on in Junxure, allowing you to extend Junxure in a way that is seamless to the
users.

I will give you step by step instructions for completing this whole process. 
So let’s get started.

Setup the Options.

You will need to turn on the option to display this button, and then you will
need to specify a form to open in the custom access database.  In this
example, I am going to use the frmClients as the form that I want to open, but
that form actually does not exist in the access database.  We are going to
create it later.  For now, just turn on the option by going to Maintain
System, System Options, Global Options , custom and checking the box and adding
“frmClients” to the form name.


No that you have turned on this option, Junxure will open the custom database
and then open the frmClients.  Since you probably don’t have a frmClients,
you will probably get an error if you were to try this right now.  You will
first need to configure your custom database.

Custom Database Location

The custom database is located in

 

 

c:\junxure\code and it is called customJunxure.mdb.  If you have a
newer version of Junxure, you may not have either that folder or that file. 
If it is there, you can open it now.  If you don’t have it I have provided
the file that I am building in this example, so you can download it and it will
already have the form that I am showing you how to build.  You can download
a copy of one here.  This is a self extracting zip file that will extract
to the proper folder.
CustomJunxure.exe

 

 Once you have the c:\junxure\code\customjunxure.mdb file on your system, double-click on it to
open it and you will see this screen.
 

 

 


This is the custom database screen that I have created, but you are not forced
to use this database.  You can actually use any access.mdb file in place of
this file as long as it is named customjunxure.mdb.

In this blog entry, I am going to assume that you are using this file. 
Before you will be able to “read” any of the Junxure data, you will need to be
sure you have configured and ODBC Connection to your Junxure database. 
Here is a link that has directions for setting up and ODBC connection. 

http://www.junxure.com/kb/ViewArticle.aspx?ArticleID=151

Now lets get started setting up the frmClients in the custom database. 
The first thing you will notice in this custom database, is that you are
basically “Locked” out of the design of the menu and you probably cannot figure
out how to get to the “database Container” in the database.  We hide it
when this opens, and to see the database container, you will click “F11″. 
That will open the database container and you will see something like this, if
you are using Access 2003, and something a bit different if you are using
another version of access.  It all works the same but the interface is a
bit different.  Go ahead and hit “F11″ with the open database.


Here you will see a list on the left that allows you to select the different
object types in the database.  In this demo, we will be working with
Tables, queries, forms and Modules.  Don’t worry about the modules, there
is only one thing that we need to do and I will walk you thru it.

Refresh Table Links

The next thing that we will want to do is to refresh the table links. 
This requires that you have the link table manager installed in your access
version.  If you did not install the link table manager, you can drop and
reattach all the tables, but I would recommend that you install the link table
manager when prompted if you do not have it installed.

Click on Tools |  Database Utilities | Linked Table Manager and that
will open the linked table manager. 


If you are using Access 2007 it is on the Ribbon on the Database Tools Tab


It will look like this. 


Click Select all, then click OK.  If your ODBC connection is properly
setup, it will refresh all of the links and this database will now be able to
view the data in Junxure. 

 

 

Caution: When you are looking at “DATA” in the
custom database, you are actually looking at data in
Junxure’s SQL
database and any changes or deletions made here, will also be made in
Junxure.

 

 

 

 

 

 

 In order to assist you in really getting the most benefit out of the custom
database, we have build a “hook” into Junxure to allow you to see the what
client your are on in Junxure and what employee you are logged in as.  In
order to take advantage of this, you will need to create a module that will call
some functions that we have created.  Don’t worry if you don’t understand
this, just follow these steps.

 

1.  Click on the Modules entry in the database container.


2 Click the New button on the top


This will open a module window and it will be called Module 1.  It is in
this module that we will want to “Paste” in some code. 


3.  Copy this code below and paste it into the window, below the “Option
Compare Database” text that appears in the module windows.  The code is
between the horizontal lines, not including the lines.


 

Function getCurrentID()
   Dim o As Object
    Set o = CreateObject("JxPublicObject.clsPublicObject")
    Dim msg As String
    msg = o.GetCurrentInfo
    Dim ClientID
    Dim emp
    If msg & "" = "" Then
      'added for testing, if clientform is not open, I return 1187, you can change this for your favorite client
      getCurrentID = 1187
      Exit Function
    End If
 
 
    If InStr(msg, ",") >= 0 Then
        ClientID = Right(msg, Len(msg) - InStr(msg, ","))
        EmpID = Left(msg, InStr(msg, ",") - 1)
     Else
        ClientID = 0
     End If
     getCurrentID = ClientID
End Function
Function getCurrentEMPID()
   Dim o As Object
    Set o = CreateObject("JxPublicObject.clsPublicObject")
   
    'I am not sure why this is not regestring
    Dim msg As String
    msg = o.GetCurrentInfo
    Dim ClientID
    Dim emp
    If InStr(msg, ",") >= 0 Then
     ClientID = Right(msg, Len(msg) - InStr(msg, ","))
     EmpID = Left(msg, InStr(msg, ",") - 1)
     Else
     ClientID = 0
    End If
    getCurrentEMPID = EmpID
End Function

 

 

 


 

 

 

 

When you paste in that code it should look something like this. 


If you only see the first function, don’t worry, you may have the editor
setup to only show one function at a time.


 We are going to test it in a second so just continue along.

Testing the Functions

Open Junxure and Go to a client in Junxure.  With the client form open,
we want to get the ID of the client that you are on.

Leave Junxure open and go back to the code windows.  Look for the window
that is labeled Immediate Window. 


If you do not see it in the code window you can click on “View”
Immediate
Window

In the immediate window, type the following.  A question mark followed
by getCurrentID() and hit enter. 


You should see the current ID from Junxure below what you typed.  If
that works, you now have the ability to get the current client ID.  Now
lets test it for the current logged on employee.

Type ?GetCurrentEMPID() and hit return


You should see the employee ID.  If you get any errors, you need to
check the following.

1. Junxure is started and Running.

2. The client form is open and on a client.

3. You have installed the Junxure Public Object.  This is found in

C:\Junxure\codeDN\JxPublicObject\SetupJxPublicObject.msi
.  If you have
done number 1 and 2, then run this MSI and try again.  If it still does not
work, then you have a problem and you should call support, they can help you
with getting the public object installed.

Save The Module.


Click the save Icon and then follow the prompts to save the module, then
close the module window by clicking the X in the top right of the window.

Build a query to return the current Client’s Information

1. Return to the database container, and click on Queries.

2. Click the new button like you did for module.  This will open a query
designer dialog.


Select Design view and click OK, this will open a table selection dialog.


Select tblClients and click OK and Close.  This will take you to the
query designer with tblClients at the top of the designer.


Double click on the any fields that you think you may want to use, but for
this demo, we are going to use these fields.

ID
Lastname
Firstname

This will give you something that looks like this.

Now what we want to do, is filter this query to only
return the client that we have open in Junxure.  To do that we are going to
add criteria to the ID field.

In the cell under ID and to the right of Criteria, you
are going to type =getcurrentID() and that will call the function that we made
in previous steps.

Once you are done, it will look like this.

To test this, you can click on the menu bar “View” and
“Datasheet View’ and you should see the client that you have open in Junuxre.

Now click the save Icon and save this query as “qryClients”

close the query by clicking the X in the top right
corner.

Building the Form

From the database container, click on forms and click
new

Click Autoform:Columnar and put qryClient in the box at
the bottom, then click OK.  This will create a form that shows the fields
that you selected in your query.

The newly designed form should look like this.

You now have a form that will open to your open client
in Junxure.  We will do a few things to this form and you will be well on
your way to being able to use the custom database.

Click on View | Design View from the menu. This will put
the form in Design View.

I am going to do the following.

1. Make the form a bit bigger.

Drag the bottom right corner of the form to make it a
bit bigger.  I would make it about an inch taller and an inch wider for
now.  You can always design it to your hearts content later.

2. Resize the white text boxes to be the same size

Select the three white boxes and use the menu “Format”
size To Shortest

This will make them all the same size.

3. put a button on the form to close the application.

Find the toolbox and select a button from the toolbox. 
If you don’t see the toolbox, you can click View Toolbox from the menu and it
will toggle it on and off.  Find the button that will make a button on the
toolbox, click it and then draw a button on your form.  It does not matter
where you draw it, just put it on the form somewhere. 

that will pop up a dialog box, that will help you tell
Access what you want that button to do when it is clicked.

Select Application, Quit Application, and then click
Finish, you will then have a button on your form, that when clicked will close
the application, returning you back to Junxure.

4. Save the form as frmClients.

Click the same save button you used above to save the
form.  It will want to save it as qryClients, since that is what you based
the form off of, but you want to change that to frmClients to match what you
have in Junxure on your options page.

5. Put some code on the form to maximize it when it
opens.

Find the box in the top right of the form designer and
double click it. Select the event tab, then click in the On Open cell to reveal
the ellipsis button then click the ellipsis button to open the code builder.

Double click the code builder item in the list box.

This will open the code editor with a new OnOpen event
for the form.  Type the following in that event so it looks like this

That will cause the form to maximize when you open it. 
Now close the code editor by clicking the X at the top.

Close the toolbox and the properties windows and then 
close the form by clicking the X at the top of it. 

Be sure to SAVE everything when you are prompted.

Be sure to close the Access Custom Database and exit
Access or it will not be able to open the form when you click the button to test
it.

Testing the database from Within Junxure

Return to Junxure and open the client form to a client
of your choosing.  I choose to open the form for Ken Golding

Now click the button for that the arrow is pointing to
and it will open the custom database to the client that you have open in Junxure

Now you click the stop sign button and you will return
to Junxure.

Summary

This gives the user a seamless hook into your custom
database.  While this demo does not give you much in terms of
functionality, it does demonstrate that you can easily hook into Junxure to open
your Access database to the form that you decide, and if you write reports in
that custom database, and those reports are for the displayed client, you can
really extend Junxure allowing you to design your own reports and you need.

For more information on creating reports in Access, you
can see my previous blog posts, or just google microsoft access report designer
tutorial for a list of resources.
Click
here for Link

 

Code to find the current client in Junxure

Posted in CRM, Custom database, Development, Training, Tutorial | Leave a Comment »

Windows 7 First Look

Posted by kengolding on September 21, 2009

As someone who really did not like Vista, and tried my best to avoid it,  I will have to say that I am liking Windows 7.  I have had it installed since the RTM release and have been using it exclusively for my Email system.

What?  Email System?  what are you talking about.  Well I am a big proponent of efficiency and my main machine has two monitors, but I don’t use email on it.  You see, as a devleoper, there are lots of little periods of time, where I am waiting for the program to compile and during those times, I like to check email, answer forum posts etc.  So I use a separate system for that.  that is my email computer, and it has a single monitor and my email is alwasy up and running.  this allows me to quickly move from system to system, keeping up on email, while not slowing down the compiler.

 

Anyway back to Windows 7.   I don’t like to upgrade operating systems, so I did not test out that part, but what I did was purchase a new desktop computer with Vista 64 already installed.  I then installed Windows 7 on top of the Vista installation, so I don’t have a dual boot system, just windows 7.   The install was very easy and I did not have any problems.   All the drivers where present and I did not have to do anything other than the standard install.  Once it was booted, I went to install SQL Express and Junxure as the main purpose for my testing was to see how Junxure will work on Windows 7.

First issue was the SQL Express install that I had was for a 32 bit system and it would not install.  No real issue here, just needed to get the 64 bit version.  I went to the web and since I was already feeling ambisious I decided to try the SQL Express 2008 version.  Microsoft has a new web installer and it installed SQL Express without really leaving the broswer.  Nothing too big, but it was a timesaver and it may help those who don’t know how to save and find a file.

Once sql was installed, I attached the SQL 2000 database and it attached without any problems.  I then installed Junxure and that is where the problems started.  Nothing too big, but since our installer used the 32 bit sql, and it won’t install, I wound up installing it manually.  A manual installtion simply entails copying the files over and making an Icon for the Junxure.exe.

Now the real testing started.  Out of the box, it all worked just fine, but seemed a bit slow.  I changed the sql compatibility mode to 2008 and then it was back to normal.  Windows seven is different, but I can’t exactly put my finger on why.  It seems smoother as you open windows.

Windows 7 has a variable DPI (Dots Per Inch) setting that allows you to adjust it to any of the  numbers in the range of the slider.  I choose 200% and logged in again, as you need to log in for the changes to take effect.  That is where I started noticing some issues.  Most of the labels and buttons where either too large and cutting off stuff, or just out of reach on the screens.  I spend the next couple of days going thru the program and fixing all the issues that I was able to see, but every now and then I come across a screen that I will need to adjust.  Now that I have made those changes it all seems to work pretty good.

I now feel comfortable in saying that Junxure will work with Windows 7 although will will probably have to do a bit of work with the installer.  Before giving the final word, I am going to wait for the retail version and double check everything, but if you are thinking about upgrading to windows 7, it may be work a look. 

UAC is Improved

I was really disappointed with the UAC in Vista, but in windows 7 they have seemed to make it where it is not too intrusive.  You don’t get as many prompts to do regular stuff, but the security is still there.  Programs don’t run as an administrator, so you still need to right click and run as administrator if you want to do this, but you should not have to.  It has a slider bar that you can set the “Annoyance” level.  You can get to the settings for UAC right from the UAC prompt.  Overall it is much better and the number of clicks is greatly reduced.

Here is a short look at some of the new features in windows 7 that I have found to be  pretty cool.

Pinning Applications to the Taskbar

You can right click on an application to “Pin” it to the taskbar.  Once pinned it is like the quick lauch in XP, and you can start the program from that Icon.  The difference is that applications when pinned to the taskbar, use the same Icon to indicate that they are running.  When they are running, there will be a box around the icon and when they are not runnign, the box will disappear.  In this screenshot, you can see that Internet Explorer and Outlook are both pinned but only outlook is running.  I have found this very usefule as I always know where to start outlook, running or not.

w7pinned

Snipping Tool

While not as robust as Snagit, my favorite screen clipping tool, windows 7 ships with a snipping tool, that allows you to easily create screen shots of a portion of the screen by dragging the mouse and releasing it.  I took the above screen shot with that tool.

Win Tab

The Windows button tab, works like in Vista, alt tabbing between screens with the 3D presentations of the open windows.

 w7wintab

Taskbar Preview

When you have an application open on the task bar, you get a preview when you mouse over it, and if there are multiple windows open, you see each of the open windows.  Hove over that windows and it will display that window in the background, click on the preview and it opens to that window.  At first it was a bit wierd, but as you use it, it becomes pretty usefule, especially when you have multiple windows open, like in an email application, where I may have 15 different emails open.

w7taskpreview

Magnifier

There is a magnifier built into the OS, and when you hit the Windows button and + or – it brings it up.  It has 2 modes,  FullScreen, Lens and Docked.  Here is a picture of the lens, the full screen zooms the whole screen and the docking put a magnifier docking panel at the edge of the screen and it mags wherever your mouse goes.   This is something that I am finding more and more useful when I go to a site that is too small, and since it is tied to the OS is it easy to open and use, with nothing to install.

w7Mag

 Windows Left / Windows Right

Another feature that is available, but I have not yet determined if I will use it, is the ability to pin any windows to the left or right side, so it only takes up 1/2 the screen.  Hit Windows Left or Windows Right and the active window will move over.  With a dual monitor system, it will move the window to the other screen.

Windows Space

This allows you to preview the desktop, so you can look at gadgets if you use them.  There is also a small pad on the right of the taskbar that will minimize all the windows.   Although you could always right click on the taskbar, and click show desktop, this is easier and something that I use often.

Windows + Number 1-0

This is kind of neat, it opens the programs on the taskbar depending on the number that you select.  If you click Windows 1, on my system it will open explorer as that is the first icon that I have on my taskbar.

Adding Toolbars

You can add folders as toolbars to the taskbar.  I have added a toolbar called computer and it gives me easy access to my computer right from the taskbar.

w7toolbar

Switching Views in Explorer

For me this is a great thing.  There are a lot owordpadf views in explorer but the one I like the most is Details,   In windows 7 you can hold down the control key while rolling the mouse and it will switch thru all of the view, including image previews, that you can size from many on a screen to just one, zoomed in view.  This also works in Vista.

Win Up and Win Down

This will toggle a window from a maximized to a non maximized state and vice versa.

Alt Up

The Explorer in Windows 7 does not have an up button, you know the one that goes up one level in explorer.

win7Up

In windows 7 you can click Alt and the Up Arrow and it iwll go up one directory, just like this button used to do.

 New calculator

It has a programmer mode, showing Hex, Binary,Oct and Decimal.  Nothing too big, but it can be useful.  Also has a history.

 Wordpad and Paint

They have been redone and now have a ribbon.  Not sure if I like the ribbon, still getting used to Office 2007 but this is new.

Posted in Windows 7 | Leave a Comment »

Using SharePoint Web Services WSS

Posted by kengolding on April 27, 2009

first_2

First time foray into Sharepoint

First time foray into SharePoint Web services.

We have been getting more and more clients asking us about interfacing with SharePoint but none of our clients were using it.  Finally we have a client that depends on SharePoint and needed us to write an interface.  With the demands on our programming pool, we always wait for demand before writing something.  Now was the time.  I decided to write this blog entry to help any other developers wade thru working with SharePoint Services.

I hope this information helps others who find themselves having to wade thru the SharePoint Web Services.  I cannot take much credit for the information in this article without first acknowledging the fact that I scoured the web looking for samples and tidbits of information.  I also hired Shervin Shabiki, from Computer Ways to help me get started.  Additionally, I attended the Orlando code camp and sat thru most of the SharePoint sessions so I could get a feel for what I was in for.

Getting Started

Install SharePoint.  I used WSS, (Windows SharePoint Services) a free download that runs on Windows 2003 Server.  SharePoint comes with an awesome object model that makes programming to it pretty easy, but we had a few restrictions that prevented us from using the object model.  We wanted to support interfacing with a hosted SharePoint site, and many of the hosted SharePoint sites do not allow access to the server, so we needed to be sure our interface would work without accessing the server by any method other than the browser interface and the web services.  This restriction alone is what prevented us from using the object model.  So for the purpose of this post,  be aware that there are easier ways to do this, but we are only going to use the web services.

Explore

Spend some time learning how SharePoint works.  Before the code camp, I had not even seen SharePoint, and was only vaguely familiar with what it actually was.  I had listened to a couple of DotNetRocks podcasts about it and I was under the impression that is was a product like Dot Net Nuke.  What an underestimation that was.  While Dot Net Nuke and SharePoint both allow you to create a portal, I think that SharePoint is much more than that.  I have heard it described in a number of ways, and when I ask people who know, what it is, I have heard a variety of descriptions.  Sort of like when several eye witnesses report the same event, they all see if a bit differently.  I guess that is because SharePoint is so big, that is allows you to do so much, it kind of depends on what you want it to be.  I am by no means an expert, but after about a month of total immersion, I still don’t feel like I fully know what it is. So keep that in mind as you read thru this stuff.

I have played around with some of the templates and it is a pretty neat tool that can solve a lot of problems when you need people to collaborate on things, over the web.  The easiest way to get started is to sign up for a hosting account and mess around with it.  I used www.apps4rent.com and it cost $8.95 a month to setup an account with no contract.  Within an hour or so I was using SharePoint without having to install it, or even have a Windows 2003 server.

While that worked for getting me familiar with SharePoint from a users point of view, their hosting plan did not give me access to the Admin site, so I could not fully use the Admin web services.  To get around that I installed windows 2003 server on a box and then installed SharePoint.  All development was done from a separate box, running windows xp and VS 2005

Dive in

There are many sites on the web that describe all of the different web services, so I won’t get into them here, I just want to show you what I learned thru this journey.  Here are a couple of links that I found useful.

MSDN Microsoft Documentation http://msdn.microsoft.com/en-us/library/cc752745.aspx
Steve Pietrek http://stevepietrek.com/
Zac Smith http://www.trinkit.co.nz/blog/archive/2008/09/10/tech-ed-2008-session-content.aspx
John Holliday http://www.johnholliday.net/products.aspx
Article by Klaus Salchner http://www.csharphelp.com/archives4/archive602.html
Code Project http://www.codeproject.com/KB/SharePoint/

Objectives

Our interface needed to do a few things.

1. Build a Sub Site that was separate from the clients main SharePoint site

2. Build a 3 document libraries in this sub site.

3. Build a predefined list of folders in these libraries

4. Add custom columns to these libraries

5. Upload a file into these folders

6. Set the values for the custom columns on the uploaded document

5. Retrieve a list of all files in a specific folder

6. Open a file from one of these folders.

Pretty easy on the surface, but for the first entry into this is was a bit challenging.  So here we go.

Before we can do anything we need to be sure that we can connect to the SharePoint server.  In order to do that we need a few pieces of information.  I am going to create a class called clsSharePoint and in that class I have some variables that will hold the site specific information

Public password As String = “password”
Public username As String = “Administrator”
Public domain As String =
“http://2003Server/default.aspx” Public SharePointURL As String = “http://2003Server”
Public AdminURL As String = “http://2003server:46487/default.aspx”
Public AdminEmail As String = “ken@kengolding.com”
Public sitename As String = “Junxure”
Public companyFiles As String =
“Company Files” Public Docs As String = “Docs”
Public AdminPort As String = “46487″

Variable Name Description
password Password for the user with rights
username A user with full permissions on that SharePoint site,  They will need full permissions because we will be adding subsites and other admin functions
domain The URL to the main SharePoint site.
SharePointURL The URL to the main site without the page name.
AdminURL The URL to the admin site,  this can be found by starting the Central SharePoint Administrator on the server (Administrative Tools) and clicking site settings.  Each SharePoint installation will probably have a different port number so you have to see what yours is.
AdminEmail Email address for the action user, only used as an argument when building a site.
sitename Name of the sub site that you want to build
Docs We build several document libraries, but in this example we are only going to build one.  I gave the users the ability to call it whatever they like, by changing the variable.
AdminPort This is used when we build the URL for the web services.

Setting up your project.

Create a new project in VS and add 6 web references.

first_1

Web service name Web Service URL Name of Reference (You can call it whatever you want, but I called it this)
Admin _vti_adm/admin.asmx WSPAdmin
Lists _vti_bin/lists.asmx WSPLists
Document Workspace _vti_bin/DWS.asmx WSPDocumentWorkspace
Webs _vti_bin/Webs.asmx WSPWebs
Site Data _vti_bin/sitedata.asmx WSPSitedata

Calling your first web service

I like to create a method called test in any project like this, just so I can know if things are working.  Because we are using web references, and we plan on distributing this application, we will need to do a few things so that our web references while initially hard coded to the location of our development server, will work on our clients machines.    Here is the initial test method.  I have removed all of the try catch blocks to save typing and space, but I will discuss errors towards the end of this article.

Public Sub TestAdmin()

Dim WSPAdmin As WSPAdmin ‘ we are creating an object based off of our above web reference

Dim nc As New System.Net.NetworkCredential(username, password) ‘ we need to set our credentials

Dim xn As System.Xml.XmlNode = m_admin.GetLanguages() ‘ now we will just query the service for the languages

‘that returns an xml node, we will display the outerxml just to see if we were successful in connecting

MsgBox(xn.OuterXml)

End Sub

I created a form in this project to test this class, and on this form I have this code.

Dim sp and new clsSharePoint
sp.TestAdmin()

When that is called it produces this messagebox showing the outerxml that is returned in that webservice method.

first_2

Success, we asked the admin web service to let us know what languages are supported and it returned 1033 in an xml node.  Most of what is returned will be in xml nodes.  Now we will discuss a implementation items.

Dynamic Web Services

As you move your application from one client to another, we want to be able to dynamically change the URLs and credentials for the web services.  I attacked that this way.  First I made some private web services that were based on the web references that we hooked up in the previous steps.  This will give us some available services and we won’t have to instantiate them for every call

Dim m_admin As New WSPAdmin.Admin

Dim m_folder As New WSPDocumentWorkspace.Dws

Dim m_list As New WSPLists.Lists

Dim m_web As New WSPWebs.Webs

Dim m_sitedata As New WSPSiteData.SiteData

I then created a function that will return the network credentials so I am only having to get credentials in one place.  This will return a valid network credential

Public Function getcredentials() As System.Net.NetworkCredential
Dim nc As New System.Net.NetworkCredential(username, password)
Return nc
End Function

Now I created a function that will return a valid URL for the webserver depending on the inital setting of the variables with the server information.

Public Function getWebserviceURL(ByVal Service As String)
Select Case Service
Case “Admin”
Return SharePointURL & “:” & AdminPort & “/_vti_adm/admin.asmx”
Case “Sites”
Return SharePointURL & “:” & AdminPort & “/_vti_adm/admin.asmx”
Case “Lists”
Return SharePointURL & “/sites/” & sitename & “/_vti_bin/lists.asmx”
Case “DWS”
Return SharePointURL & “/sites/” & sitename & “/_vti_bin/DWS.asmx”
Case “Webs”
Return SharePointURL & “/sites/” & sitename & “/_vti_bin/Webs.asmx”
Case “SiteData”
Return SharePointURL & “/sites/” & sitename & “/_vti_bin/sitedata.asmx”
End Select
End
Function

Now we need to create a new method that will initialize the above web services, so that we don’t have to deal with this in the remaining function.  Now when you instantiate this class, it will change the URLs, Credentials and Timeouts on the 6 private web services

Public Sub New()

’set the urls for each web service to the localized URL
m_admin.Url = getWebserviceURL(“Admin)
m_admin.Credentials = getcredentials()
m_admin.Timeout = 60000
m_folder.Url = getWebserviceURL(“DWS)
m_folder.Credentials = getcredentials()
m_folder.Timeout = 60000

’set the credentials and timeout for each webservice
m_list.Credentials = getcredentials()
m_list.Url = getWebserviceURL(
“Lists”)
m_list.Timeout = 60000
m_web.Credentials = getcredentials()
m_web.Url = getWebserviceURL(“Webs)
m_web.Timeout = 60000
m_sitedata.Credentials = getcredentials()
m_sitedata.Url = getWebserviceURL(“SiteData)
m_sitedata.Timeout = 60000
‘They are now all ready to use

End Sub

Now that we have a class that has some web services instantiated and hooked up, lets use them to do some stuff.

Get a list of Sites

This function will return a dataset that contains a list of sites on the server.  It uses a helper function that is described later in the article.  xmlNodeToDS that takes an xml node and converts it into a dataset.

This is handy to check if a site exists before you add it.

Public Function getSitesDS() As DataSet
Dim ds As New DataSet
Dim node As Xml.XmlNode
Try
node = m_web.GetAllSubWebCollection()
ds = xmlNodeToDs(node)
Return ds
Catch ex As Exception
Return ds
End Try
End
Function

Add A new site

The documentation for this method is found here.  http://msdn.microsoft.com/en-us/library/administration.admin.createsite.aspx

Here is the signature for this method.

CreateSite(Url, Title, Description, Lcid, WebTemplate, OwnerLogin, OwnerName, OwnerEmail, PortalUrl, PortalName)
We are going to Create a site with the local of English 1033 and the Standard new site of STS

Public Sub AddSite()
Try
m_admin.CreateSite(SharePointURL & “/sites/” & sitename, “Junxure SharePoint Site”, “This site is used for document management in Junxure”, 1033, “STS”, username, username, AdminEmail, “”, “”)
Catch soapex As System.Web.Services.Protocols.SoapException
If soapex.Detail.InnerText.StartsWith(“Another site already exists at”) Then
Else
msgbox
(soapex.detail.innertext)
End If
End
Try
End
Sub

In the above code, I introduced the System.Web.Services.Protocols.SoapException.  This object will allow you to see why your web service calls fail.  You use the familiar try catch block, but instead of catching an exception, you catch a SoapException.  The soapexception has a detail property and it has an innertext property that will tell you what went wrong.

Add a list to a site

Pretty straight forward code, just adds a list to the site, takes a name of the list, a desc and a type.

Public Sub addList(ByVal listname As String, ByVal description As String)
‘101=shared documents  use this link below to see the other types of lists to use
http://msdn.microsoft.com/en-us/library/lists.lists.addlist.aspx
Try
m_list.AddList(listname, description, 101)
Catch ex As System.Web.Services.Protocols.SoapException
msgbox (soapex.detail.innertext)
End Try
End
Sub

Add A Folder to a list

Again pretty straight forward.  The trick to this is providing the rootstring to the folder that you want to add.  We want to add a folder called A to the list we added above.  If the above list was docs, it would be at

http://2003server/sites/junxure/docs then I would call it like this

sp.AddFolder(“docs”,”A”)

That would create http://2003server/sites/junxure/docs

sp.addFolder(“docs/A”, “New Folder”) would create

http://2003server/sites/junxure/docs/A/New Folder

Private Sub AddFolder(ByVal rootstring As String, ByVal infolder As String)
Try
m_folder.CreateFolder(rootstring & “/” & infolder)
Catch soapex As System.Web.Services.Protocols.SoapException
MsgBox(soapex.Detail.InnerText)
End Try
End
Sub

Retrieve all the lists in a site.

This function will return an xml node that represents all of the lists on a site. I have written it so that it will return a dataset of all of the lists on the site.  It uses a helper function, that takes an xml node and returns a dataset with the nodes contents.

Public Function getListSDS() As DataSet
Dim ds As New DataSet
Dim node As Xml.XmlNode
Try
node = m_list.GetListCollection()
ds = xmlNodeToDs(node)
Return ds
Catch ex As Exception
MsgBox(soapex.Detail.InnerText)
Return ds
End Try
End
Function

Here is the helper function It takes the xml node returned from many of the web service methods, and converts it into a dataset.  The one trick that you may notice is that I prepend the xml from the node with <?xml version=”1.0″ encoding=’UTF-8′ ?> .  Before I prepended it, I would only get errors trying to read the xml into the record set.  This function is really handy if you want to see what is in the nodes that are returned.

Public Function xmlNodeToDs(ByVal node As Xml.XmlNode) As DataSet
Dim ds As New DataSet
Try
Dim
result As New System.IO.MemoryStream
Dim sw As New StreamWriter(result, System.Text.Encoding.ASCII)
Dim xml As String = “”
xml = “<?xml version=’1.0′ encoding=’UTF-8′ ?>” & node.OuterXml.ToString
sw.Write(xml)
sw.Flush()
result.Seek(0, SeekOrigin.Begin)
ds.ReadXml(result, XmlReadMode.Auto)
Return ds
Catch ex As Exception
MsgBox(soapex.Detail.InnerText)
Return ds
End Try

End Function

Get all items in a list (Recursively)

If there are folders in a list, the standard calls do not work for getting the items in the list.  You will have to use some CAML to query recursively.    in this example we are going to query the list that is passed in and we are going to get a list of all of the items in that list, even if they are in subfolders in the list.  It will be recursive as deep as the list is.  This is written to return a datatable.

It uses the method GetListItems

GetListItems(listName, viewName, query, viewFields, rowLimit, queryOptions, webID)

Listname the name of the lsit

Viewname is the name of the view and an empty string will use the default view for that list.  Any fields that are not in the view will not be returned.

query – this is an xml node that defines the query for the method call.  In our case, we set it up by creating an xmlDoc and then using the doc to create an xmlNode.  We then set an element of the node to “Query”

Viewfields is optional and we are just passing in an xmlNode that is equal to nothing

nodeQueryOptions is where you tell it what folder and what attributes to search on. Again we use the xmlDoc to create a queryoptions node, and then from that we set the innerxml to the folder that we want to query by using <Folder></Folder>  that will search from the root folder.  If we want to specify a folder, then we would put the folder path inbetween the <folder> tags like this <folder>FOLDERNAME\SUBFOLDERNAME</Folder>.  That entry would search for all items in the Subfoldername folder

We can then put some attributes on the Node.  The trick in this one is to use the <ViewAttributes Scope=”recursive”/>  With this attribute set, it will search recursively thru the whole list.

When we take the resulting node, and use our helper function to put it into a dataset, we can inspect the dataset and see that it is the second table that contains the items for the list, so we return the second table.  ds.tables(1)

Public Function getListItems(ByVal Listname As String) As DataTable

‘this is a recursive search for all items in the list
Dim ds As New DataSet
Try
Dim
innerxml As String

Dim nodeView As Xml.XmlNode = Nothing
Dim
nodeResult As Xml.XmlNode
Dim xmldoc As New System.Xml.XmlDocument()
Dim nodeQuery As XmlNode = xmldoc.CreateNode(XmlNodeType.Element, “Query”, “”)
Dim nodequeryOptions As XmlNode = xmldoc.CreateNode(XmlNodeType.Element, “QueryOptions”, “”)
innerxml = “<Folder></Folder><ViewAttributes Scope=” & Chr(34) & “Recursive” & Chr(34) & “/>”
nodequeryOptions.InnerXml = innerxml
nodeResult = m_list.GetListItems(Listname, “”, nodeQuery, nodeView, String.Empty, nodequeryOptions, “”)
ds = xmlNodeToDs(nodeResult)
If ds.Tables.Count = 1 Then
Dim
dt As New DataTable
Return dt
Else
Return
(ds.Tables(1))
End If

Catch soapex As System.Web.Services.Protocols.SoapException
msgbox (soapex.detail.innertext)
Dim dt As New DataTable
dt.TableName = “No Data”
ds.Tables.Add(dt)

End Try

End Function

Below is a partial screen shot of the above datatable loaded into a grid.  You can see the field names and the contents of the xmlnodefirst_3

Get the info for an item given a listname and a URL

Using this function, you can retrieve just the information for one item, rather than all the items in a list.  We will query the list based on the ows_FileRef that is the URL for the items.

If you have a document with a URL of  http://2003Server/sites/Junxure/Company Files/A/Anderson-Allen-1187/Financial Plan/Add.bmp you can all this function with the name of the list and this URL and you will receive a datatable with one row, containing all of the information for that one item.  we use the same code as above, but we are going to change the query node to include a where clause, and that where clause will specify that we are looking for the FieldRef field to be equal to the passed in search URL.

Public Function getListItemsRecursiveByURL(ByVal Listname As String, ByVal fileURL As String) As DataTable
‘this is a recursive search for an item in the list with that URL
Dim searchURL As String = fileURL
Dim ds As New DataSet
Dim dt As New DataTable
Try
searchURL = URLDeEncode(searchURL)
searchURL = searchURL.ToLower.Replace(SharePointURL.ToLower & “/”, “”)
Dim innerxml As String = “”
Dim nodeView As Xml.XmlNode
Dim nodeResult As Xml.XmlNode
Dim xmldoc As New System.Xml.XmlDocument()
Dim nodeQuery As XmlNode = xmldoc.CreateNode(XmlNodeType.Element, “Query”, “”)
innerxml = “<Where>”
innerxml += “<Eq>”
innerxml += “<FieldRef Name=’FileRef’/>”
innerxml += “<Value Type=’Text’>” & searchURL & “</Value>”
innerxml += “</Eq>”
innerxml += “</Where>”
nodeQuery.InnerXml = innerxml
Dim nodequeryOptions As XmlNode = xmldoc.CreateNode(XmlNodeType.Element, “QueryOptions”, “”)
innerxml = “<Folder></Folder><ViewAttributes Scope=” & Chr(34) & “Recursive” & Chr(34) & “/>”

nodequeryOptions.InnerXml = innerxml
nodeResult = m_list.GetListItems(Listname, “”, nodeQuery, nodeView, String.Empty, nodequeryOptions, “”)
ds = xmlNodeToDs(nodeResult)
If ds.Tables.Count > 1 Then
Return
(ds.Tables(1))
Else
Return
dt
End If

Catch soapex As System.Web.Services.Protocols.SoapException
msgbox (soapex.detail.innertext)
Return dt
End Try

End Function

The trick to the above code is getting node query xml entered properly.  If you look above you will see that we use a helper function to URLDeEncode the url that is passed in.  We also have an URLencode fuction.  These simply take URLS and make them safe to pass around, adding or replacing unsafe characters. Here are the two function

Public Function URLEncode(ByVal inUrl As String) As String
Try
‘reserved
inUrl = inUrl.Replace(“%”, “%25″)
inUrl = inUrl.Replace(“/”, “%2f”)
inUrl = inUrl.Replace(” “, “%20″)
inUrl = inUrl.Replace(“$”, “%24″)
inUrl = inUrl.Replace(“&”, “%26″)
inUrl = inUrl.Replace(“+”, “%2B”)
inUrl = inUrl.Replace(“,”, “%2C”)
inUrl = inUrl.Replace(“:”, “%3A”)
inUrl = inUrl.Replace(“;”, “%3B”)
inUrl = inUrl.Replace(“=”, “%3D”)
inUrl = inUrl.Replace(“?”, “%3F”)
inUrl = inUrl.Replace(“@”, “%40″)
inUrl = inUrl.Replace(Chr(34), “%22″)
inUrl = inUrl.Replace(“<”, “%3C”)
inUrl = inUrl.Replace(“>”, “%3E”)
inUrl = inUrl.Replace(“#”, “%23″)
inUrl = inUrl.Replace(“{“, “%7B”)
inUrl = inUrl.Replace(“}”, “%7D”)
inUrl = inUrl.Replace(“\”, “%5C”)
inUrl = inUrl.Replace(“|”, “%7C”)
inUrl = inUrl.Replace(“^”, “%5E”)
inUrl = inUrl.Replace(“~”, “%7E”)
inUrl = inUrl.Replace(“[", "%5B")
inUrl = inUrl.Replace("]“, “%5D”)
inUrl = inUrl.Replace(“`”, “%60″)
Return inUrl
Catch ex As Exception
msgbox (ex.message)
Return
inUrl
End Try

End Function


Public Function URLDeEncode(ByVal inUrl As String) As String
Try
‘reserved
inUrl = inUrl.Replace(“%25″, “%”)
inUrl = inUrl.Replace(“%2f”, “/”)
inUrl = inUrl.Replace(“%20″, ” “)
inUrl = inUrl.Replace(“%24″, “$”)
inUrl = inUrl.Replace(“&”, “%26″)
inUrl = inUrl.Replace(“%2B”, “+”)
inUrl = inUrl.Replace(“%2C”, “,”)
inUrl = inUrl.Replace(“%3A”, “:”)
inUrl = inUrl.Replace(“%3B”, “;”)
inUrl = inUrl.Replace(“%3D”, “=”)
inUrl = inUrl.Replace(“%3F”, “?”)
inUrl = inUrl.Replace(“%40″, “@”)
inUrl = inUrl.Replace(“%22″, Chr(34))
inUrl = inUrl.Replace(“%3C”, “<”)
inUrl = inUrl.Replace(“%3E”, “>”)
inUrl = inUrl.Replace(“%23″, “#”)
inUrl = inUrl.Replace(“%7B”, “{“)
inUrl = inUrl.Replace(“%7D”, “}”)
inUrl = inUrl.Replace(“%5C”, “\”)
inUrl = inUrl.Replace(“%7C”, “|”)
inUrl = inUrl.Replace(“%5E”, “^”)
inUrl = inUrl.Replace(“%7E”, “~”)
inUrl = inUrl.Replace(“%5B”, “[")
inUrl = inUrl.Replace("%5D", "]“)
inUrl = inUrl.Replace(“%60″, “`”)
Return inUrl
Catch ex As Exception
msgbox (ex.message)
Return inUrl
End Try
End
Function

Building the Query

There is a great tool out there called U2UCamlCreator.exe and with this tool you can create and execute CAML queries and see how they work.

Here are a couple of links that discuss that tool

http://www.u2u.info/Blogs/Patrick/Lists/Posts/Post.aspx?ID=1252

http://www.u2u.be/res/Tools/CamlQueryBuilder.aspx

This tool was very useful for helping figure out the required CAML queries.

Add A field to a list

If you go to the SharePoint site via a browser, you can see that it is very easy to add columns and set their properties.  We need to do this programatically.  I wrote a couple of functions to accomplish this.

Before I add a field, I want to see if that field already exists.  I pass in a listname and a fieldname, and return true or false depending if that field exists.   This function uses some classes in the Site Data Web services.

Public Function FieldExists(ByVal listname As String, ByVal Fieldname As String) As Boolean
Dim
exists As Boolean = False
Try
Dim
lstMetaData As New WSPSiteData._sListMetadata
Dim lstFields() As WSPSiteData._sProperty
m_sitedata.GetList(listname, lstMetaData, lstFields)

Dim field As WSPSiteData._sProperty
For Each field In lstFields
If Fieldname.ToLower = field.Title.ToLower Then
exists = True
Exit
For
End
If
Next
field
Return exists
Catch soapex As System.Web.Services.Protocols.SoapException
msgbox (soapex.detail.innertext)
Return exists
End Try
End
Function

This function is the fuction that adds the field to the list.  It takes a listname, a fieldname, a datatype and a description.  If the field is already there, it exits otherwise it adds the field to the list.

Public Sub AddField(ByVal listname As String, ByVal fieldname As String, ByVal datatype As String, ByVal description As String)
If FieldExists(listname, fieldname) Then Exit Sub
Dim
innerxml As String = “”

Dim ndList As XmlNode = m_list.GetList(listname)
Dim ndVersion As XmlNode = ndList.Attributes(“Version)
Dim xmlDoc = New System.Xml.XmlDocument()
Dim ndDeleteFields As XmlNode = Nothing
Dim
ndProperties As XmlNode = xmlDoc.CreateNode(XmlNodeType.Element, “List”, “”)
Dim ndTitleAttrib As XmlAttribute = Nothing ‘ CType(xmlDoc.CreateNode(XmlNodeType.Attribute, “Title”, “”), XmlAttribute)
Dim ndDescriptionAttrib As XmlAttribute = Nothing ‘CType(xmlDoc.CreateNode(XmlNodeType.Attribute, “Description”, “”), XmlAttribute)
Dim ndNewFields As XmlNode = xmlDoc.CreateNode(XmlNodeType.Element, “Fields”, “”)
Dim ndUpdateFields As XmlNode = Nothing ‘xmlDoc.CreateNode(XmlNodeType.Element, “Fields”, “”)

innerxml = “<Method ID=’1′>”
Select Case datatype
Case “DateTime”
innerxml += “<Field Type=’DateTime’ DateOnly=’TRUE’ DisplayName=’” & fieldname & “‘ FromBaseType=’TRUE’/>”
Case “Text”
innerxml += “<Field Type=’Text’ DisplayName=’” & fieldname & “‘ Required=’FALSE’ FromBaseType=’TRUE’ Description=’” & description & “‘/>”
Case “Number”
innerxml += “<Field Type=’Number’ Name=’” & fieldname & “‘ DisplayName=’” & fieldname & “‘ Required=’FALSE’ FromBaseType=’TRUE’ Description=’” & description & “‘/>”
End Select
innerxml += “</Method>”
ndNewFields.InnerXml = innerxml

Try

‘code to actually add the field
Dim
ndReturn As XmlNode = m_list.UpdateList(listname, ndProperties, ndNewFields, ndUpdateFields, ndDeleteFields, ndVersion.Value)

Catch soapex As System.Web.Services.Protocols.SoapException
msgbox (soapex.detail.innertext)
End Try
End
Sub

This is a function that will get a datatable that contains all of the fields in a list


Public Function GetFieldsDT(ByVal listname As String) As DataTable
Dim dt As New DataTable
dt.Columns.Add(“FieldTitle)
dt.Columns.Add(“FieldName)
dt.Columns.Add(“DataType)
Try
Dim
lstMetaData As New WSPSiteData._sListMetadata
Dim lstFields() As WSPSiteData._sProperty
m_sitedata.GetList(listname, lstMetaData, lstFields)
Dim msg As String = lstMetaData.Title + ” :: “ + lstMetaData.DefaultViewUrl + ControlChars.Lf
Dim field As WSPSiteData._sProperty

For Each field In lstFields
dt.Rows.Add(field.Title, field.Name, field.Type)
Next field
Return dt
Catch soapex As System.Web.Services.Protocols.SoapException
msgbox (soapex.detail.innertext)
Return dt
End Try
End
Function

Update a field for a specific item in a list.

You will pass in the listname, the URL of the item, the fieldname and the value to set it to.

Public Sub updateItem(ByVal Listname As String, ByVal fileURL As String, ByVal Fieldname As String, ByVal fieldValue As String)
Try

‘we need to get the ID of the item
Dim
itemID As String
Dim
ds1 As New DataSet
Dim dtItem As New DataTable
dtItem = getListItemsRecursiveByURL(Listname, fileURL)
If dtItem.Rows.Count = 0 Then
Exit
Sub
Else
itemID = dtItem.Rows(0)(“ows_ID”)
End If

‘now we Get Name attribute values (GUIDs) for list and view.
Dim ndListView As System.Xml.XmlNode = m_list.GetListAndView(Listname, “”)

‘Create an XmlDocument object and construct a Batch element and its ‘attributes. Note that an empty ViewName parameter causes the method ‘to use the default view.
Dim doc As New System.Xml.XmlDocument()
Dim batchElement As System.Xml.XmlElement = doc.CreateElement(“Batch)
batchElement.SetAttribute(“OnError, “Continue”)
batchElement.SetAttribute(“ListVersion, “1″)
batchElement.SetAttribute(“RootFolder, Listname)
Dim innerxml As String = “”

‘You will see similar code to this all over, but not too many explanations.  Here is where you pass the method in.
‘you can actually batch as many methods as you want together, and each method will have it’s own ID, starting with 1 and incrementing up
‘as you add addtional methods.  In this case we are only adding one method.
’see the notes below for information on this xml

innerxml = “<Method ID=’1′ Cmd=’Update’>”
innerxml += “<Field Name=’ID’>” & itemID & “</Field>”
innerxml += “<Field Name=’FileRef’>” & URLDeEncode(fileURL) & “</Field> “
innerxml += “<Field Name=’” & Fieldname & “‘>” & fieldValue & “</Field>”
innerxml += “</Method>”
batchElement.InnerXml = innerxml

Dim resultNode As XmlNode
resultNode = m_list.UpdateListItems(Listname, batchElement)
ds1 = xmlNodeToDs(resultNode)

Catch ex As System.Web.Services.Protocols.SoapException
SPpex(ex, “WSSupdate”)
End Try
End
Sub

////////////// NOTE ON XML////////////////////////////////////////
innerxml =
“<Method ID=’1′ Cmd=’Update’>”
innerxml += “<Field Name=’ID’>” & itemID & “</Field>”
innerxml += “<Field Name=’FileRef’>” & URLDeEncode(fileURL) & “</Field> “
innerxml += “<Field Name=’” & Fieldname & “‘>” & fieldValue & “</Field>”
innerxml += “</Method>”
batchElement.InnerXml = innerxml
While you will see this all over, it was a bear to make it work.  You pass in the method ID as described above, it just increments for each command that you want to execute.
You then pass in the FieldName and that is the ItemID that we got from the ows_ID in the top part of this function
You also need to pass in the DEEncoded URL for the item
Then you pass in the value that you want to update it to.  If you do not pass in the DeEncoded URL it will not update the value.
///////////////////////////////////////////////////////////////////////////////////////

Finally we upload a Document

After searching all over the place I could not find out how to upload a document into a list using the web services.  In talking with Shervin Shabiki, he told me that you cannot upload a document using the web services.  You must use another method.  Here is what I came up with, borrowing from this post on CodeProject and adding some of my own ideas.

In using this function on my site, we have already added the appropriate lists, and each list has some custom columns added to them.  I will pass in the clientname and since we added the clientname to our list in our custom program, it will update the clientname column with the passed in value

Public Function UploadDocument( ByVal localFile As String, ByVal remoteFile As String, ByVal Listname As String, ByVal folder As String, Optional ByVal Clientname As String = “”) As String

‘// Read in the local file
Dim sRemoteFileURL As String = “”
Dim attemptNumber As Integer = 0
Dim maxAttempts As Integer = 5
Try

Dim r As Byte()
Dim sDocLib As String = “”
Dim Strm As System.IO.FileStream = New System.IO.FileStream(localFile, System.IO.FileMode.Open, System.IO.FileAccess.Read)
Dim reader As System.IO.BinaryReader = New System.IO.BinaryReader(Strm)
Dim filecontents As Byte() = reader.ReadBytes(CInt(Strm.Length))
reader.Close()
Strm.Close()
Dim sSPURL As String = SharePointURL & “/sites/” & sitename
sDocLib = Listname & “/” & folder

Dim NC As System.Net.NetworkCredential = New System.Net.NetworkCredential(username, password, domain)
sRemoteFileURL = sSPURL & “/” & sDocLib & “/” & Trim(LTrim(RTrim(remoteFile)))
sRemoteFileURL = Replace(sRemoteFileURL, ” “, “%20″)
sRemoteFileURL = Replace(sRemoteFileURL, “\”, “/”)
Dim m_WC As WebClient = New WebClient
m_WC.Credentials = NC
Dim dtcheck As New DataTable


Do Until dtcheck.Rows.Count > 0
attemptNumber = attemptNumber + 1
‘we want to try the upload for as many times as we specified in maxAttempts variable.

r = m_WC.UploadData(sRemoteFileURL, “PUT”, filecontents)
‘After we attempt to upload it, we then use our getListItems function to see if the item made it up there, if not we try again.

dtcheck = getListItemsRecursiveByURL(Listname, sRemoteFileURL)
‘if the datatable dtcheck has rows, then the item was uploaded successfully
‘Here we have some custom code that will process a failure if the attemp number is = the max attempts meaning that we did not get the file uploaded so we
‘need to log it and move on.  I do not show the code for logging the failure as it does not pertain to this post.
If attemptNumber = maxAttempts And dtcheck.Rows.Count = 0 Then
MsgBox(“Error Loading file into SharePoint” & vbCrLf & “The files as been placed into the Failed Bin”)
processfailure(localFile, remoteFile, Listname, folder, clientname)
Return localFile
End If
Loop

‘We use the update item code we wrote earlier to update the clientname field with the passed in clientname
If clientname <> “” Then updateItem(Listname, sRemoteFileURL, “ClientName”, Clientname)
Return sRemoteFileURL

Catch ex As Exception
msgbox (ex.message)

Return “Failed”
End Try
End
Function

Hopefully these functions will help others as then embark on the SharePoint webservices programming tour.

If you would like me to post the code to this post, please leave a comment.



Posted in Development, SharePoint | Leave a Comment »

Creating a custom report (Part 3) Where’s the data.

Posted by kengolding on March 30, 2009

As you probably already know, Junxure keeps all of the data inside of a Microsoft SQL server database. This database contains a number of tables, and if you know where to look and how to ask for the data, you can pull anything and everything out of the database for your own custom reports. I will try to show you the tables and the relationships for the main parts of the program. Here is what I will cover.  While I am not going to cover all of the tables below, you will see that the clients tables are prefaced with tblclients so you should be able to figure them out pretty easily

Clients – tblClients
Phones -tblClientPhones
Addresses -tblClientAddresses
Emails – tblClientEmailAdds
Classifications -tblClientClassifications
Keywords – tblClientkeywords

Actions -tblClientActions
Emails – tblClientActionsEmails
Attachments – tblClientActionsEmailAttachments
Documents – tblClientActionsDocuments

Accounts – tblClientDBCamIDs
Owners -ContactAccountXref
Assets – FAS-Assets

Hopefully this will help you find where the data is for your custom reports.

Clients

The main data for the clients is stored in tblClients.  In that table you will find all of the fields that pertain to any contact in your database.  Since Junxure is a product that has been evolving since since 1995, there are a few things that you should not about this table.  There are some fields that we no longer use, those fields were left in the table, because many of our clients have written custom reports that use that table, and if we removed the fields, many of their reports would have been broken.  We decided to leave all of the phone, email and address fields in the table, even though we no longer use them.    All of that data was moved to the appropriate tables as show in the photo below.

If you look in the center of the picture, you will see the clients table.  The Primary key and main identifier for each client is the ID fields.  Each client can have unlimited records in each of the tables that the arrows are pointing to.  The 3 tables highlighted in blue are the tables that hold the phone, email and addresses on the contact info tab in Junxure.  The tables highlighted in Yellow, are the tables that hold the data in the bottom part of the profile tab.

schemaclients

Here is a diagram that shows the relationships between employees and the clients.

schemaclient

Actions

The actions are contained in a main table, and the emails and documents are located in additional tables.  Here is a diagram that shows the relationships for the actions.

tblClientActions -In the diagram below, you can see the white box in the center is the main action table.   It contains the main part of the actions.

tblClientActionKeywords -The pink table is the action keywords table, and you can have many records in this table for each action.

tblClients -The purple table is the clients table, and it is related to the actions via the client ID field.

tblAlerts -The darker yellow table is the alerts, and if an action has a task assigned to it, then an alert is placed into this table.  Once alerts are completed, they are deleted from this table

tblClientActionsFYi -The light yellow table at the top left is where we store the FYI’s for this actions.

tblClientActionsEmails and tblClientActionsEmailAttachments -The Green table are the emails and the email attachments.  Each action can have multiple emails, and each email can have multiple attachments.

tblClientActionsDocuments -Finally the blue table is the table where we store the documents.  We do not actually store the document in the database, but we store the path to the document in the filename fields.

schemaactions

Also on actions you may be interested in seeing what employees are related to the action.  Here is the diagram for that.

schemaactionemp

Accounts and Assets

Accounts and Assets are a bit harder to comprehend and because of the way Junxure has evolved, the naming on these tables is a bit strange.  One thing to remember is that Junxure, in it’s evolution, now allows multiple clients to own an account, so the accounts table is not really associated with the clients at all, that is where we use the cross reference table.  To help you understand how it is all related, it would help if you think of these 4 entities, and then look at the names of the tables that hold these entities.

Clients  – tblClients

Accounts – tblClientDBCamIds

Owners – ContactsAccountsXREF

Assets – FAS-ASSETS

Looking at the picture below you can see that each assets belongs to an account.  Each account has owners, and each owner is a record on the clients table.

schemaassets

Asset Fields

The field names on the asset form do not match the field names in the tables.  Here is a screen shot that shows what the actual field names are for the asset form.

schemaassetfields

This should answer many questions you may have about the location of the data and the how the data is related.  In my next post, I will try to show you how you can “Hook” the custom database to the Junxure database using the Junxure Public Object.

Posted in CRM, Custom database, Development, Schema, Tutorial | Tagged: , , , , , , | 2 Comments »

Hanselman of the East

Posted by kengolding on March 29, 2009

I am sure that some of our readers will see the title of this post and think that it is a bit strange.  There actually is a story behind it.   A lot of people do not understand the world that computer programmers live in.   For those of you who use Junxure, it is pretty easy to use the program and I hope we have done a pretty good job at hiding the complexity.  If you could peek into our world, you would see that Junxure is actually a blend of technologies, all working together to allow you to run your practice in the most efficient manner.

All of these technologies allow us to do some incredible things, but at the same time they are very complicated and forever evolving.  The challenge for me and our development staff is how do we keep up with the technology and it’s ever changing status.  The problem of keeping up is not unique to the programmers who develop Junxure,  it is a universal problem.  To help developers keep up with the changes, Microsoft has put together a team of people whose main purpose is to spread the news of what is new, what is coming, and how do you use these technologies.  Additionally,  just like we at Junxure listen to our users to find out what is working and what need to be added or changed, they listen and meet with many of their users to do the same thing.

They do this via a variety of ways, and one of them is something that is called “Code Camp”.  This weekend Microsoft, Infragistics and a host of other companies hosted a “Code Camp” and they were able to have it at a local community college.  Orlando Code Camp This Saturday, they put together 50 speakers, and 65 sessions designed to help developers use the technology.  There we sessions on Dot Net Nuke, Sharepoint, Data Services, Sql Programming, Programmer related management and development stuff, The Dotnet Framework, MVC and a whole bunch of other stuff.    You can click the link above if you are really interested in the details.

So if you have gotten this far in the post,  then you are probably asking yourself what the title “Hanselman of the East” has to do with all of this.  We it all goes back to a maintenance man at a theater in Fort Lauderdale.  You see, about 4 or 5 years ago, I went to another event that was hosted by Microsoft,  and this event was at a theater.  I arrived a a bit early and got a seat near the front.  While they were setting up it looked like there where having trouble with the audio visual system and in walks a maintenance man wearing a hard had and a old leather tool belt.

itsallaboutthetools_12

I have to admit, I thought it was a bit funny seeing all of these highly trained Microsoft employees standing around while this maintenance man was called in to make it all work.  He fiddled with some cables  and settings a low and behold, as if a by magic, the Microsoft logo appears on the huge theater screen.  Internally I had a bit of a chuckle thinking how the maintenance man saved the day.  Then they said that they were going to get started.  Much to my surprise, the same maintenance man goes to the front of the room and introduces himself as Russ Fustino, host of the, now world famous Russ’Tool Shed.  Russ gave a fantastic presentation on how to program on what was then the new Visual Studio and some of it’s new features.  Russ is one of the guys who helps us learn all of this new stuff.  His discussion and demonstrations of the tools that are available to developers is top notch.

So again you are probably asking again “What does this have to do with Hanselman of the East”.   Well there is another person who has devoted lot’s of his time to helping developers learn about technology, and his name is Scott Hanselman.  Scott is very well known but mostly hangs out in the West,  but he has a great reputation in this field.   Many people when they think of great leaders in the area of Microsoft development they are can’t help but immediately think of these two guys, along with a slew of many others.

To give you an idea of how many people Russ has helped over the years, I’ll share a story about a session this weekend.  Ryan Morgan was giving a presentation on Jquery, and a lady walked into the room and said she had some extra tickets to Russ’ TV show.   There were about 40-50 people in that room, with many standing in the back of the room because of  Ryan is an awesome presenter and everyone wanted to hear him.  Anyway, when she said she had a few tickets to the show, one poor guy asks “Who is Russ Fustino?”  The whole room went silent and almost in unison whole room cried out “WHO’S RUSS FUSTINO?”  like they were so surprised that someone in this field, would not know who Russ is.  The poor guy then had to listen as people began to say “EVERYONE KNOWS WHO RUSS IS.”  He as probably feeling pretty bad by then, but that shows the impact that Russ has made on the developer community.

Overall it was a great weekend for the Junxure developers.  We were able to fan out and cover a huge variety of topics and the knowledge that we gained will help us to make Junxure, Clientview and Junxure Mobile much better products.

So this is the end of the weekend and the Junxure developers have spent a couple of days reviewing our code, looking at things that we are working on and refining our road map.  We topped it all off with a whole day at Code Camp, and now we are going to be heading back to work, fully charged, loaded with new ideas,  and excited to get started using them.

Hopefully you now have a better appreciation of what we do behind the scenes to keep up to date on all of the current technology.

Posted in Development, Training, Uncategorized | Tagged: , , , | Leave a Comment »

Creating A Custom Report (Part 2) – Designing the report

Posted by kengolding on March 22, 2009

Creating custom reports in Junxure (Part 2) The Reports

Recap

In the previous post,  I covered the most basic parts of Access, and described how Access has 2 parts, the database and the programming environment.  Using the first part to hook up to the data, you can then build queries to extract the data that you want.  You can use the queries to limit what fields you see and how that data is “Joined” together to show you want you want.  You can also put filters on the queries so you further limit what is returned from the database.    Here is a link to (Part 1)

Creating the Report

When you create a query that displays the fields that you want and contains the appropriate filtering, you can look at it in “Datasheet view”, and see what data is returned.   It will look something like this.

qryfilterresults

This is great for making a simple list of data, but if you want a printable, formatted report, you will need to do a bit more work.  The good news is that you can leverage all of the work you did in creating the query, all you need to do is to create a report that pulls it’s data from your query.

I will show you a step by step creation of a report using the query that we made in the previous blog entry.  In the sample database that I have provided, I have called the query qryDemoActions.

If you need a copy of the custom database you can get it http://s3.amazonaws.com/Junxurebasics/CustomDemo.mdb

Finding the Report Wizard

You will need to open the database container.  There are a couple of ways to accomplish this.   Hit {F11} and it should open up, or you can click on the menu item Window | Database,  (If you do not see Database on the window menu, you will have to click Window | Unhide Window to make it visible).  Once you have the database container open, you will click on the reports tab, and then click New Report.  That will open the starting page of the report builder.

rpt1

Here there are 6 items that you can select from

  • Design View – This will just open a report in design view and you will have to place all content on the report.  Access does nothing for you.
  • Report Wizard – This will walk you thru some choices and you will wind up with a basic report,  ready for additional editing.  (This is the one we are going to walk thru.)
  • Auto Report: Columnar – This option will create a report with each field entered one on top of another, with the labels going down the left side of the page and the data on the right.
  • Auto Report: Tabular – This option will create a report similar to a spreadsheet, but you will be able to edit it further.
  • Chart Wizard – If you query had data that was suitable for charting, you could select his and create a chart.
  • Label Wizard – This option will allow you to use the Access label wizard and create many different labels.

In our case you will select Report Wizard at the top, then select the query that we built in the previous blog entry.  qryDemoActions.  That tells Access that you want it to create the report automatically for you.  Once you click OK you will then get a screen where you can select the fields that you want in your report.

rpt2

On this form, on the left side you will see all of the fields in the query.   You can double click on any of the fields to add them to the report.  Once added to the report, they will disappear from the left column and appear in the right column.  In the above screen shot, I have selected all of the fields, so Access will create controls for each field on the report.  I will discuss the controls a bit later in this entry, but you should know that Access will place a text box on the report and when you run the form, the data for that field will appear in the text box.  When you click Next from this screen, you will be prompted for any grouping that you would like on the report.  Grouping is useful when you want to group report records under a particular field.  For instance, I would like to group all of the actions in the qryDemoActions by who they have been assigned to.

rpt3

By selecting Assigned to, my report will have a group header and the records in the query will be grouped by the person who they have been assigned to.  This will make it easy to see all of the record by each employee.  You can select additional groups if you like, but for this example we are going to stick to one grouping.  When you click next you will be prompted for the sorting.  Again you can select multiple sorting levels.

rpt4

Here we have chosen to sort by Last name, First name and Date.   This will produce a report that is grouped by the employee the actions are assigned to and then sorted by clients in last name, first name order, then in date order.  You can change the order of any field so it is either ascending or descending order, so if you want the oldest actions at the top of each group, you would select Descending order.   When you click next you will be prompted for the alignment of the fields within the report.  You can try each setting to see how it will look, but other than cosmetic purposes, it does not matter what you select on this screen.  You can also choose between landscape or portrait, along with forcing all of the fields to appear on one page.  If you force all fields to appear on one page, you may have to do some adjusting to make it look right.

rpt5

When you click next you will be prompted for a format for your report.  Access provides several different formats and you can choose any of them.  You will just have to play around with each one to see what style you prefer.

rpt6

Finally, once you have selected your style, you are ready to create your report.  When you click finish, you will view your report in design view with the data from your query, and if you were to print it, that is exactly what it would look like.  Let’s click Finish and see what it looks like.

rpt8

Modifying your Report

If you click on View Design view, you will be taken from the above print preview view into design view of the report.  In design view you will be able to edit the look and feel of the report.

rpt81

In the above screen shot there are several things that I have pointed out.

  • Pink Arrow at top left – This is how you can switch back and forth from design view to print preview.  Click the little arrow and select either design or print preview.
  • Red Arrows -  This is the button that toggles the field chooser on and off.  You can drag any field from this list and it will be linked up to the query behind the report.  Notice where the black arrow is pointing to the lastname field.  That is a field that Access created for you, but if you were to drag it to the report again, you would get something that looked just like that.
  • Green Arrow – This toggles the toolbox on and off.   There are a number of controls in the toolbox.  The top two icons, highlighted in orange in this screenshot  are the selector and the autowizard tool.  The rest are listed below going across then down.
    • Large Italic Aa This is a label control and it allows you to type any text in it, an that text will just show up on the report.  The top control on the report, that says “Actions By Assigned to Employee for 2000″ is a label control and I have set the text in it to what I wanted.  Changing the reports underlying data does not change the contents of a label control
    • ab|  – This is a textbox control and generally it will display the underlying data if you bind it to the field.  If you look at the properties box for the lastname textbox, you will see that the control source is set to lastname. This tells access that when you run this report, take the data from the lastname and display it in this box.
    • Small box with xyz on top.  This is what you call a group by box.  We are not using it here, but it can be used to hold buttons  or checkboxes along with grouping controls for cosmetic reasons.
    • Toggle button – This can be bound to a yes no field and it will either display a depressed button or a raised button depending on the selection.
    • Radio button – These are usually placed inside of a group by box, and only one can be selected.
    • Check Box – This is usually bound to a yes not field, like I did on the action required field in this report.  If the action had action required, you will see a checked box, otherwise you will see an empty box.
    • Combo Box – This is a drop down control that holds both the value for the field and a list of items that you can choose from.
    • List box – Similar to a drop down, but it is a list of items and the selected item will be highlighted.
    • Button – Not usually used on reports, but it is just a button that you can click.
    • Image control – This is a control that you can bind to an image.  If you wanted a logo on your report you could place an image control and then set the properties for the path to the image.
    • Picture box – Similar to an image control but with some other options.  The image control is the lighter control and will give better performance.
    • The picture with the xyz is a bound object frame and you can use it to display an object, like a word document inside of your report.  Typically you do not use this item and there are a lot of things that you have to setup to make sure it works properly, including having the proper program installed to display the object.
    • Page Break – This will force a page break wherever you place this control.
    • Tab Control – This is a control that give you selectable tabs.  It is useful in a report for showing only certain controls at a certain time.  (This is a more advanced control)
    • Subform / Report  – This is a powerful control, that allows you to place another report inside of an existing report.  For instance, for the assigned employee, you could have a separate report that shows all of the information for that employee.   It would actually run the report for each employee and only show the data for the employee that it is linked to.   For more information, I would google Access Subreports to learn more.
    • Diaganol Line  – This allows you to draw lines on your report.  Notice in our report we have several lines.  The best way to make a line totally flat is to select it and set the height to 0.
    • Square – This allows you to draw squares on your report.
    • Toolbox – This is a link to additional active x controls on your system.
  • Black Arrows – This button toggles the property pages for the selected control.  The property pages are where you can set the value of properties on the control.  Properties can affect the behavior and appearance of a control.  Here are some examples.
    • Name – This is what you will refer to this control as, when you are in code or macros.
    • control Source – This tells Access what fields contains the data for this control
    • Decimal Places – Used when the control contains numeric data.  You can accomplish rounding to 2 decimal places by setting this to a 2
    • Can Shrink and Can Grow – Allows the control to either get taller or shorted depending on how much data is in the contro.  If you have a note field that can contain anywhere from no data to paragraphs, then setting this to Can Grow=True will allow it to display all of the data without having blank spaces in records with only a small amount of data.
    • Font Bold Size etc,  changes the size and attributes of the font.
    • Visible – If you can see the control in print or print preview mode.
    • Text Align – Left Center or right justified.
    • Width and height These set the size of the control
    • Others – there are many other properties but this covers the most used ones.
  • Green box in lower left – This is a text box that was dropped on the report, and =Now() was added as the control source.  It will cause the report to print the current date and time when the report is printed.
  • Blue text box at the lower right.  This is a special code called [Page] and [Pages].  Access is smart enough to know how many pages of data there will be when the report is printed and what page it is on.  Using these special codes you can display that information on  your report

Additional Formatting

Now you should have enough information to get started playing around with the format of your report.   You can try changing the size, alignment etc and see if you can make it look exactly like what you are wanting it to look like.

Posted in Custom database, Junxure, Tutorial, Uncategorized | Leave a Comment »

Creating a custom report – (Part 1) Tables and Queries

Posted by kengolding on March 18, 2009

Because of our open architecture, you can easily create custom reports in Junxure.

Every piece of data that is used by Junxure is accessible to you to create custom reports with.  Knowing where this data is and how to use it, is the key to having any kind of report that you can imagine.  You will need a few things before you can get started.

  • Some way to access the data -  I will show you how to use MS Access to do that.
  • An understanding of data types in databases.  This is important because when you begin to want to limit the data, you need to know what kind of data type you will be filtering on.
  • A bit of knowledge on how to access and aggregate that data.  This is basic database knowledge, and while there are many tutorials, book and courses available, I will try to give you the basics.
  • A Reporting package that will let you build the reports that you want to build.  Again I will show you how to use MS Access, but you could use Crystal Reports or Sql Server Reporting Services if you like.
  • An understanding of data relationships.  What is means when we say “One to One”,  “One to Many” and “Many to Many”.  How to use those relationships to get the appropriate data back.

Let’s get Started.

Since you are going to be using Microsoft Access to be the vehicle where you access your data and create your reports, you must first learn a bit of how to use the Program.   As mentioned before, there are whole books on this subject and entire courses that are taught at colleges and adult education classes.  I would strongly recommend that if you want to become proficient in learning how to do anything you can think of with custom reporting, then you should do what you can to get a thorough understanding of how Access works.  I have worked with many users who already had an understanding of MS Access and were pretty proficient with it, and these users were able to get started producing reports almost immediately.  I will do what I can, but you may want to deleve further into Access with a book or an online tutorial.

Here are a few links to help you find more information.

http://www.officetutorials.com/accesstutorials.htm

http://www.amazon.com/s/ref=nb_ss_gw?url=search-alias%3Daps&field-keywords=msaccess&x=16&y=19

Access is really two programs in one.

Most people do not realize this, but Access is really two programs in one.

It is a Database

Every access file can contain its own database tables.  There can be a virtually unlimited number of tables.  Although it can contain its own data, the file does not have to actually contain the data, because it also has the ability to link out to other data sources.  When it does this, the tables that it linked out to are called “Linked” tables.  For our programming examples, we are going to use Linked table, and we will be Linking out to the data that is stored in the Junxure tables on the SQL Server database.  If you do not want to use your live data, I will also provide a sample MDB file that contains a set of sample data that you can use instead of your live data.

It is a programming Environment

With the exception of the tables, everything else in the Access file is part of the programming environment.  When you think of a file on a computer system, you usually think of a single entity, like a word document, an excel spreadsheet, or a text file.  With Access, the files are a bit different.  They contain many items with them and those items are viewed by opening the file with the Access program.  The types of items are listed below

  • Tables
  • Queries
  • Forms
  • Reports
  • Macros
  • Modules

Tables

These are the items that contain the actual data.  A table is made up of Records and fields.  Most people are familiar with spreadsheets.  When you look at a spreadsheet like the one below you see rows and columns.  In this example, we have these columns

Name

Address

Phone

and we have 3 entries for each column

Ken

Bill

Tom

excel

If you were to translate what you know about spreadsheets into database tables, you would see the following

Columns become Fields, and in a database you need to specify what type of data is stored in these fields.  In a spreadsheet, you can just type whatever you like into a cell, but in a database, you need to determine ahead of time, what kind of data you want to store in that field.  There are many types of data that you can store,  but I will discuss the basics.

  • Text- Any type of characters that you can type with your keyboard
  • Numbers – Any type of numeric input, but they are even split further
  • Integers – Numbers that do not allow decimal points
  • Doubles – Numbers that do allow decimal points
  • Currency- Numbers that allow 4 decimal points
  • Dates

(There are actually more types but for this discussion, you need to understand that some numbers do not allow decimal places)

Rows become Records with each record contains one copy of each field.   The drop down list shows you want kind of data each field can hold.   Here is a screen shot of a table that will hold the same data as the spreadsheet above.  This is the design view of that table, the bottom picture is the data sheet view, where you can see the data.

tabledesign

In the picture below, you will see an additional column.  ID  This column was added by Access and it is a type of Autonumber.  That means each time a record is added to this table, Access will automatically insert the next available number into that field.  Once it is inserted, it can always be used to identify that record.  This is very useful when trying to find a record.  Since it is a number, it can be indexed (Pre sorted) internally to the database and Access will be able to find it very quickly.  If you have 2 records with the same data in every field, the ID field will allow access to be sure to find the proper record.  It is called a primary key and they are very useful.  In Junxure, the clients table has a field called ID and it uniquely identifies each individual contact record.  Once a number is used, it will never be reused, even if you delete the record.

tabledatasheet

Tables are “NEVER” sorted by any predictable method.  The data can be in the order that you enter it, or any random order.  This is important for you to understand.  You can sort the data however you want using queries.

Too Many Tables

If you look at all of the tables in Junxure you will see that there are over 300 tables and it appears that the data is scattered all over the place.  Your observations are correct. It is scattered all over, but there is a method to the madness. If you are familiar with spreadsheets, you are probably used to viewing data in rows and columns. While this is a valuable way to store data it is very limiting.  You can do pivots and sorts but the amount of reports is fairly limited. That is why a program like Act or Goldmine cannot compare with Junxure when it comes to database flexibility. In a typical spreadsheet where you track accounts you may seem something like this.

Client Address Phone Account1 Account2 Account 3

Ken Golding 123 lucky lane 444-4444 YG66855 FB-55544 KF7706

Bill Smith 234 Bull Market Ln. 4454455 GF06855 000-9985 5467765

This creates a real problem with trying to add the 4th, 5th and 6th account. What if you get a client that has

100 accounts? In a relational database we would split that sheet into 2 tables. Clients and Accounts so you would have something like this

Clients table Accounts Table

ID Name ClientID AccountNumber

1 Ken Golding 1 YG665855

1 FB-55544

1 KF7706

2 Bill Smith 2 GF06855

2 000-9985

2 5467765

Each piece of data goes in its own table and it is related to additional tables.

If you look at table alone, it would be pretty hard to use that data unless you had an exceptional memory

Some things to remember about tables:

  • They can have certain fields that populate themselves, for instance the ClientIDs in the above client table
  • They can have constraints on the data that is entered. You cannot enter a date into a money field.
  • The data in a table is in no particular order, usually it is in the order it was entered but not necessarily.

So how do you view the data in a meaningful way? That is where Queries come into play.

QUERIES

At this point, I am going to introduce a sample database for you to work with.  It has the same tables as Junxure, but you don’t have to worry about messing up any live data.

Download it at this link http://s3.amazonaws.com/Junxurebasics/CustomDemo.mdb

I have included the tables in the database so you can feel free to delete, edit add as you like. All of the data in these tables is local and not “live”

The tables we will be working with are

tblClients The main Client Table

tblClientclassifications A table that has unlimited classifications for each client

tblclientKeywords A table that has unlimited keywords for each client

tblclientActions This is the table that stores actions in Junxure

tblClientDBCamIDs This is the table where we store the account Numbers

ContactsAccountXref This is a table that links accounts to client.

FAS-Assets This is where we store the Asset position information

There are more tables but for the purpose of this demonstration these are the one we are going to use.

If you open any of these tables you will see a lot of fields that you don’t necessarily want to see while you are working with the custom database.

When working with queries you should remember that you are just gathering the data that you are going to include in your report.

Here I will show you how to limit what you see to a subset of the entire table.

Take a look at qryClients. This is a query that I have created in the customdemo.mdb file.

clients

These are the fields that we are going to have available. If we need more fields, we can just drag them to the grid. Notice that I have added a field called Addline and Cityline.

Here I have joined two fields together so that later you will not have to do it in your reports.

This is called an Alias. The syntax for this is Addline:[HomeStreet] & “ “ & [HomeStreet2]

Also notice that we selected Ascending under the last name on the sort row. That will return the records sorted by lastname.

If you switch this from the design view to the data sheet view, this is what you will see.

clientquery

Now lets take a look at a query that uses this query to show all of the classifications for each client.

clientclassdesign

In the above image, we have joined the previous query with the classification table. The line with the arrow pointing out tells us to show us every record in the qryclients and only the classifications if they exist. If a client has multiple classifications then they will appear multiple times.

clientquery

So you can see by using queries you can begin to make sense of this seemingly disconnected data.

Lets make another query that shows actions for clients. In this query I am going to show all actions with the clients name

clientactionis

Here I have joined the two tables to show all of the actions and the client for each action.

I have added the fields that I want to see.

If I switch to data sheet view this is what I see

clientactionsdatasheet

Now we are beginning to get something that we can use, but notice that the EmpID and ActionAssignedtoID are showing numbers and not the Employees names. If we what the names we will need to add some more joins out the the employees table. Since we have 2 fields that we are looking for we will add the employees table twice. When we do this Access will append a _1 to the second table.  Then we will use the alias to display a field that shows the lastname of the Employee. For the fields with a zero on a blank, no name will show up. The syntax for the new column is Emp:tblEmployees.Lame

clientactionsjoins

Notice that we now have the name of the employee along with the data. Another thing that you can do with queries it so filter the data by adding criteria. I will filter for only actions in the year 2000 and with a type of planning or service.

Here is the example for that

queryfilter

Notice that I have the critera on 2 lines. That is because I want to “OR” the filter.

I am saying between ((1/1/200 and 12/31/200) and Letter) OR ((1/1/200 and 12/31/200) and Service)

This changes the results to a smaller subset of the existing data.

qryfilterresults

<!–[if !mso]> <! st1\:*{behavior:url(#ieooui) } –>

By adjusting the criteria I could further filter this to only actions assigned to Mary Doe. In fact I could create as many different scenarios as I could imagine. This is the beauty of using queries to query a relational database.

You may be interested in knowing that the graphical interface is only a representation of the action

“Structured Query Language” or Sql that is behind this query. Here is the actual SQL text.

SELECT

LastName,

FirstName,

Date,

Type,

LName AS Emp,

ActionReq,

DateReq,

Note,

tblEmployees_1.LName AS AssignedTo

FROM

((tblClientActions LEFT JOIN qryClients ON tblClientActions.ClientID = qryClients.ID) LEFT JOIN tblEmployees ON tblClientActions.EmpID = tblEmployees.EmpID) LEFT JOIN tblEmployees AS tblEmployees_1 ON tblClientActions.ActionAssignedTo = tblEmployees_1.EmpID

WHERE

(((tblClientActions.Date) Between #1/1/2000# And #12/31/2000#) AND ((tblClientActions.Type)=”Letter”))

OR (((tblClientActions.Date) Between #1/1/2000# And #12/31/2000#) AND ((tblClientActions.Type)=”Service”))

ORDER BY qryClients.LastName, qryClients.FirstName;

The importance of knowing about the SQL text is that you can copy this sql and paste it into another database and access will draw the query assuming that the tables are available. It is also useful if you are using the Forum to ask a question about a query. You could paste the sql from your query and I could load it in my database to see what it is doing.

The SQL keywords are in this query are

Select

From

Where

Order by

In my next post, I will discuss how to take the data from the queries that you build and show you how to make them into a report.

Posted in Custom database, Junxure | Tagged: , , , , , | 5 Comments »

Effective Task Managment and Tracking

Posted by kengolding on March 17, 2009

More than a few times, either on the phone, forum or in person,

I have heard our users cry out “We want to assign a task to multiple people ! ”

This has always been a point of contention between different leadership styles.  I have always taken the line, that it is not a good practice to assign a task to multiple people, knowing that if more than one person is assigned, the chances of it being completed are diminished.  I just have to think about when my kids were younger and I asked them to mow the lawn.  Days would pass and each one would assume that the other was going to do it, and I frequently found myself, spending a Friday evening explaining to them, that if the yard was not mown before Saturday morning, then they would be spending the weekend inside instead of playing outside with their friends.  A poor decision on assigning the task, put me in the postion of having to drop the hammer on them.  In retrospect, it would have been much better to make it clear and easily understandable, that one of them specifically was to cut the grass.

Hildebrant International is a Global Leader in Professional Services consulting, and on their website  they have ten management principles.  Principle number seven is posted below.

Here is a the link to the source http://www.hildebrandt.com/Documents.aspx?Doc_ID=892

7. Do not assign an important task to any group that is co-led.
Co-leadership has multiple possible consequences and all but one of them is bad:

a) The work will be carried out competently,
b) Each co-leader will assume that the other will take responsibility for moving the matter forward and nothing will happen,
c) Both co-leaders will move forward independently creating:

i) A wasteful duplication of effort,
ii) Confusion among subordinates as to who is in charge of the matter,
iii)Maddening multiple subordination of subordinates and coworkers, or
iv) Contradictory instructions to coworkers and subordinates.

If you are serious about an assignment being carried out, assign it to one person, or to the leader of a group, such as a practice group leader, in his or her role as leader. Making assignments to a collectivity (e.g. ad hoc committee, partners meeting, practice group) defuses responsibility. Having delegated a task to an individual, neither disappear nor interfere, but maintain a consistent, light supervisory interest on the level of, “How are things going with such and such?”

Reading that just enforces what I learned years ago and I still subscribe to it today.

But are there exceptions?

As the main architect and developer of Junxure, I have learned a lot of things in the  14 years.  One of the things that I hold dear to my heart is the notion that our users are pretty smart people, and it is because of their ideas that Junxure has become a leader in the Financial services software space.  As I listened to many of them explain why they wanted to assign a task to multiple individuals, it became clear that what they really wanted is something a bit different.   About a month ago, one of our users articulated to me, a scenario that was like a beacon of light shining on the problem.

In their office, they have small teams of people who perform the same tasks for any or all of the advisors.  The advisors have gotten used to using Junxure’s Action Templates and Action Sequences, but they were having a problem making them work smoothly.  The problem was that certain tasks needed to be assigned to a team of people, because the advisor did not really care who did it,  they just needed to be sure that it got done.  They tried assigning all the tasks to the supervisor of the team, and then the supervisor would reassign the tasks out to the people on the team as they thought necessary.  While this was an improvement, it still had it’s flaws.

As is often the case, someone on the team would not come in one day, and the tasks that were assigned to that person were semi hidden from the view of the rest of the team.  While it is true, that with the report dashboard, the could have seen what was assigned and taken it, it required a change of course from their natural work flow.  In our discussions, I finally understood what they needed to make the system even more efficient.

Queues

Wikipedia defines a queue as  “,An area where a line of people wait. The verb queue means to form a line, and to wait for services. Queue is also the name of this line. “    This is the nature of this problem.  There is a line of work that needs to be done, and any of the team members can do it.  They just need and easy way to see the pending tasks for the queue and then they can grab one and do it.  Efficient and practical.

Rolling up the sleeves and getting to work.

After thinking this thru, I began to work on a solution that will make Junxure even more practical for bigger offices where for efficiencies sake, they employ queues to assign out tasks.  The first thing I did was I added a new task area, called “View Queues”  From this area, you can easily create a new queue and then, once it is created, you can assign tasks to the queue instead of a person.  Team members can easily view the queues, right from the main menu and work on the tasks as the come in from the different areas of the company.  Often times, with larger companies, the tasks come in from an office that is not even in the same city, so knowing who the actual person who is going to perform the task is not only not necessary, but also not practical.

The managers of the teams can easily monitor the queues and make sure that people are picking up the tasks in a speedy manner.  They also still have the full ability to assign a task to an individual just like before.  It really is the best of both worlds.  In fact, if you never setup a queue, then Junxure will work exactly how it did in the past, but once you create a queue, you can assign any type of action to the queue instead of a person.

My initial feedback on the queuing system has been great and I think that it will help solve a longstanding issue for many of our users. While I am not really that old, I am getting older and just a bit wiser, proving that you can teach an old dog new tricks.

If you would like to see more information about the new queuing system you can click this link.  http://s3.amazonaws.com/Junxurebasics/ActionQueues/default.htm

Let me know how you like the new queueing system.

Posted in CRM, Management | Tagged: , , | 3 Comments »

New Feature (Multi Custom Fields for Accounts)

Posted by kengolding on March 16, 2009

Tracking Account Information

Over the last year, I have had many requests from our users,  some work in the accounts area of the program.  Basically they were asking for 2 things.

More fields that we did not have

Better ability to report on the Accounts.

Due to the enormous efforts what went into rewriting Junxure 7, we did not have time to get these items into the main release, but we were listening and they will be in the next release.

Here is what is coming.

Unlimited Custom Fields

Accounts Rule Builder

Account Report Wizard

Enhanced Client User fields

I have just added a few new features to the Accounts details form.   These features are in the latest code, and they will be released as soon as testing gets underway.  Probably within 3-4 weeks.

 

Unlimited Custom Fields on Accounts

In order to use them, you will have to first set them up.

Go to List Data Maintenance click on the Program Setup Category,  and then select Multi Custom Fields.

There you will find a form where you can setup unlimited fields that will be associated with each account.

There are 4 attributes that make up each field

Data type – This determines the User interface control that you will use when you access this field.  The following types are available

Combo – this will present a drop down for the field.

Date – this will present a date time picker for the field.

Number – this will present a numeric editor for the field.

Text – this will present a text box for the field.

Currency – this will present a currency editor for the field

Y/N – This will present a check box for the field

Field name - This will be the name of the field on the Account form

Sort – This determines the order that the fields appear.  They will appear in two columns, down then across.

Key- This is a button that you can click to enter the contents of the drop down if you select Combo as the data type.  The button will only appear when you select Combo

Here is a screen shot where you setup the fields.  Another benifit of this enhancement it that it will allow us to expand the custom fields to the insurance at a later date.

setupfields

Once the fields are setup, you can see them on any account from the clients form.

customfields

Account Rule Builder

This is a rule builder, that works for Accounts.  You can use any of the fields that are on the account form, along with any of the custom fields that you have setup.

You can create unlimited rules and check them on the fly, or from the Account Rule list.

accountrulebuilder

Account Report Wizard

This is a report wizard, similar to the Report wizard and the Action Report Wizard, but it is for Account information.  You use an Account Rule to determine what accounts you want to see.  You can then enter a client rule to limit the list to a group of clients, and then you select what fields you want to see in your report.  Just like the other, you can send the results to a portrait or landscape report, or to an Excel spreadsheet.

accountreportwiz

Enhanced Client User Fields

I have taken the ability to select the data type for a custom field,  and have applied that to the existing user fields on the client form.  By default, they will all be combo fields, but you can change them to any of the above listed data types, so no conversion is necessary.

It is important to be sure that you do not change a field that has text in it to a Number.  I have put some checks into the system so you will not be able to do this.  When using this feature, if you do not see one of the data types in the drop down, it is because you have data already entered in that field, and it would conflict with the missing data type.

 

clientsetupfields

clientuserfields

 Hopefully, these changes will go a long way to making Junxure a more capable program, assisting you to run a better practice.

Posted in CRM, Junxure | Tagged: , , , | 1 Comment »

Efficiency with Junxure

Posted by kengolding on March 10, 2009

This is the first entry into a new blog that I have started,  hoping to help the users of Junxure, get more out of the system.  Hopefully you will find it useful and be moved to share a comment or two, to help get a discussion going.  At a mininum, I hope to achieve 2 things with this blog.

1.  To make you a better user of Junxure, finding out what the features are and how to use them.

2.  To engage users in a discussion of ways to improve your practice, and your insight on how to improve the program.

In this turbulent time of markets that are seemingly moving in a continuous downward spiral it is all the more important to have an efficient and easy to use CRM System.  Many financial planners, insurance agents CPA’s and others in the financial services industry have chosen to use Junxure to improve efficiency and customer service.  I want to give you a couple of examples of how others are using the system to impove service and hang on to client’s who are searching for competency and assuredness when it appears that none can be found.

Relating a Story

Here is a scenario that will illuminate one of the reasons why you need a quality CRM.  Imagine if you will, that you are an office that works with attorneys to take care of certain estate planning items.  In this case, you are working with a client to get a will created.  The client and the advisor have a meeting and discuss the things that need to be done, and one of the items was a will.  The advisor gets the information and sends it to the attorney.  The next day the attorney calls back but the advisor is not is, so they leave word with an associate telling them that it all looks good and they would be able to have the job completed by next Thursday.  Everything is good and life went on.  Later that week, the client calls back in to check on the status of the work.  When the client calls in, they get the receptionist, and they ask her if she knew the status of the work on the will.  Unfortunately, the advisor was out of the office, and the receptionist did not know the status of the work.  This begins a series of steps that highlight the reasons that any professional organization needs to have a system in place, and every employee in the company needs to utilize that system to its fullest.  Here is what happens.

1. The receptionist tells the client that she will check on it and get back with them.

2. She then calls the advisor who was not avilable so she leaves a message.

3. The advisor gets the message and calls the attorney to find out what the status is.

4. The attorney is out, so the advisor leaves a message.

5. The attorney calls the advisor back, and tells him “Yesterday I left a message with your associate but you must have not gotten it.  The work will be done next Thursday”

6. The advisor, armed with this new information called the receptionist back and tells her to call the client and let them know that it will be done next Thursday.

7. The receptionist calls the client, but the client is not avilabe, so she leaves a message telling them that the work will be ready next Thursday.

This scenario can be expanded upon but it is something that happens on a regular basis, causing people at every level of the company to waste precious time chasing information.

In this age of Google, and instant searches, you cannot afford to run a business like that.

If you were using a CRM system like Junxure, you would have had a much different scenario.  When the attorney called and told your associate the status of the work for that client, he would have went to the client’s record, and made an entry updating the status.  Then when the client called it would have went something like this.

1. The client calls and the receptionist opens the record, sees the note and tells the client that they have spoken with the Attorney and the work will be ready on next Thursday, “Is there anything else that I can help you with?”

DONE!

NOTICE A DIFFERENCE?

The first scenario, easily could have taken over a half hour to get back to the client. 

People at every level would have wasted time, accomplishing the same task. 

What would happen if the Advisor was out of touch, maybe on a plane, it could be hours or possibly days before the client got their answer?

What do you think the client would think about your firm’s competence when they cannot get an answer to something as simple as the status of some work?

Conclusion

When everyone in a company uses the system to document what they are doing, it will improve customer service at all levels.  It is important to deliver what you promise, and when you are prospecting for a new client, you are probably telling them that you are a high service, high touch, professional firm.  Without the proper systems in place and people using them as they are designed, you will not be able to deliver what you have promised.

Posted in CRM | Leave a Comment »