Form Numbering for Multiple Locations with ShareVis and SharePoint

I’m currently developing a Management of Change form using ShareVis. This is a large process, launching sub-forms and approval routings and links to drawings, so it’s also a great learning experience. As I tackle how best to proceed with all the requirements I’m going to share what I’ve done. I hope for two things; first, to give others the opportunity to see real examples of the working with ShareVis. Second, to get more eyes on what I’m doing for feedback. I don’t work with a team of developers so I’m alone when it comes to brainstorming and development. If you see something I’ve done and know of a better way, please let me know.

My first requirement with my management of change was how to handle form numbering. ShareVis comes with a name template that will automatically generate a unique name for the form. However, I needed to be able to sequence within the location – i.e. A change in San Diego and a change in Los Angeles will need to have two forms created, but the form will need to be named to include the location and the change number for that location not a count of all changes.

First I create a list to track the number count for each location.

This includes a calculated column to display the number in a way I want (with leading zeros), the code for the location, the partnering company (this will affect routing later on), and the plant manager. For this example we’re really only interested in the Location, NumberCount and Counter.

Next is the form:

I want to stop here and point out myFields in the Data source. If you rename “myFields” to something else, the ShareVis.Query will not work. I’ve reported this to ShareVis and they’ve been really good about fixing “features” I find, so it might not be long before this is handled as well. In the meantime, save yourself some frustration and don’t rename myFields and don’t group fields when you don’t need to. Field grouping was another gotcha I ran into.

Here is the detail of my ShareVis.Query:

Query: list=MOCFormInfo;filter=[Location]==@[//my:locationName];select=[NumberCount],[Location],[Code],[Company],[Counter]

Set Fields: locationNumberCount=NumberCount,locationCode=Code,locationCompany=Company,locationTitleCounter=Counter

Here is the detail of the ShareVis.FormName properties:

Template Name & Fields: TOMOC,//my:locationCode,//my:svHyphen,//my:stringCounter

stringCounter is used to strip out the leading characters from the calculated column. ShareVis already has the fix for this – but I haven’t applied it yet. Plus I thought it might be helpful to someone else to see how I handled this.

Calculate the next number for this location and promote this property so the workflow can process it.

TOMOC is the name template:

You’ll need to create the real Name Template and just ignore the one created when the form is published.

The last thing is handling the update of the NumberCount within the form process. I’m enjoying the simplicity of this flow while I can; it’s going to quickly get really messy.

Plugin “Set SharePoint Column”:

ValuePairs:

So this is how I’m handling the numbering within the location for multiple locations. My real form has to deal with 10 locations. Please give me your feedback. And if you’re using ShareVis, please join our Google Discussion Group.

Name Template Returns “NaN”

In ShareVis, linking a Name Template to a Form, I’ve found that it’s best to let the Form create the Name Template and then modify it in the Process.  I’ve struggled with creating it in the Process first and then adding it to the Form.

nametemplate1

Once that’s working though, I ran into trouble with the number showing up as “NaN”.  “NaN” means Not A Number. 

nan

Which would make sense if my field was a Whole Number (integer), but it’s Text (string).  I’ve checked it over and over.  And then I realized it used to be a number.  When I was first adding the fields, I had made it a number and then later changed it to text.  However, something was still treating it like a number in the form view.  I deleted and readded the field. Then reset the ShareVis.FormName custom control to the new field.  Then republished the form and the process.

nan2 

Using Data from Access in SharePoint via SQL

This is a reoccurring issue I have; I don’t know C# beyond one program I wrote 3 years ago when my career path took me away from development and toward other areas. But now, working with SharePoint, this has become a handicap – I want to accomplish a task that is more complicated than straight SharePoint Designer can handle. Unfortunately I don’t have time to defer the task while I learn the C# that would solve this task in a more efficient manner. OK, so it is imperative that I get around to learning C#. Until then what can I do? I do know SQL. This leads me to my current workaround.

Task: Create a site for an engineering project that will store drawings, pieces of equipment (known by their tags), and all specs and requisitions related to those tags. The drawings are created with a program called CADworks. CADworks stores information about the drawings (such as the tag numbers) in an Access database. Pull in the information from the Access database into a SharePoint Equipment list that can be used to tie together drawings (stored as PDF’s in a SharePoint library), Specs (information can be in lists or libraries), Requisitions (lists), and Purchase Orders (library.)

I hoped first to use a ShareVis workflow to take the drawing number as it’s uploaded into the library and pull the data from the Access database and manipulate the list then. However, that functionality does not currently exist with ShareVis – the plug-ins that looked like they might be able to do what I wanted are for forms only. (They did however pass on that request to their development department. I have hope that it will be possible in the future.)

Issue: Can’t insert into SharePoint List via SQL Insert. So can I pull data from Access AND SharePoint Libraries to create a cross-linking data view?

  1. Create a linked server to access an Access database. See Configuring a Linked Microsoft Access Server on SQL 2005 Server . Since the CADworks database is stored on the shared drive, I’ll need to create a batch file to copy it to the SQL server nightly.
  2. Create store procedure to query access database:

    set ANSI_NULLS ON

    set QUOTED_IDENTIFIER ON

    GO

    — =============================================

    — Author:        SharePoint Diva

    — Create date: 3/10/2009

    — Description:    Pull data from Linked Access Database

    — to display in a data view on SharePoint

    — =============================================

    ALTER PROCEDURE [dbo].[csp_GetComponentsMechanical]

        — Search by PID if provided, otherwise use wild card

        @pid varchar(40) = ‘%’

    AS

    BEGIN

        — SET NOCOUNT ON added to prevent extra result sets from

        — interfering with SELECT statements.

        SET NOCOUNT ON;

     

        — Inside declare for debugging

        — DECLARE @pid varchar(40)

        — SET @pid = ‘%’

     

    — Insert statements for procedure here

        SELECT DISTINCT REPLACE(DWG_NAME_,’.DWG’,”) AS [P&ID], REPLACE(TAG_,’-‘,”) AS [Equip. Tag]

        FROM AccessDatabase…[AccessTable]

        WHERE DWG_NAME_ like @pid

    END

     

  3. Create Database Connection in SharePoint Designer:


     


     

  4. Create a data view in SharePoint Designer:

     

  5. Modify the DataForm field to create a hyperlink to the drawings library based on the value of the field:

    Address example: http://DevActiveProject/DrawingsDesign/Forms/AllItems.aspx?&FilterField1=P%5Fx0026%5FID&FilterValue1={@P_x0026_ID}

     

    So now I have an equipment page containing data from Access that links to my document library, and because of the query string parameter, I can create a link in my document library that will redirect to a filtered view of my equipment page.

     

     

    I’ll cover in a following post the workflow I created for my library to create the hyperlink back to this list.

 

 

Adding ShareVis to My Bag o’ Tricks

I spent the last week at our office in Carlsbad, New Mexico getting trained up on ShareVis. ShareVis is a workflow designer for SharePoint. I’m really excited to dig in and start creating workflows and forms. They don’t have their community site set up, so I’ll start here by sharing my experiences. Right now I’m just trying to shake off the weekend and remember where I was.