Checking User Group Membership in Nintex Workflow

I don’t do much with Nintex yet. If I’m able to do my processing with the SharePoint Designer Workflow I will. Unfortunately one thing that can’t be done in SharePoint Designer (OTB) is check if a user belongs to a SharePoint Group. It’s not that straight-forward in Nintex either. Tom O’Connor at CUBE4 wrote a great post instucting exactly how to do it: Nintex: Checking if a user is a member of a SharePoint group.

Export/Import Sub-Site with PowerShell

Thanks to Russ Ramirez’s SharePoint Blog for providing me with the answer I needed.  From his post, SPWeb move or clone in PowerShell, I was able to come up with the following script.

$moveFrom = https://WEBAPP1/sites/SITECOLLECTION/SITEA/SITEA1
$moveTo = https://WEBAPP2/sites/SITECOLLECTION/SITEB/SITEB1/SITEA1NEW
$backup = "E:\Backup\20120104_BACKUP.cmp"
$siteName = "SITE NAME"
$siteDesc = "SITE DESCRIPTION"
Get-SPWeb $moveFrom | Select-Object -Property WebTemplate, Configuration
# !! Based on the results of the Get-SPWeb, update the next line for Template (Concat WebTemplate + "#" + Configuration)
New-SPWeb -Url $moveTo -Template STS#0 -Name $siteName -Description $siteDesc
Export-SPWeb $moveFrom -Path $backup -IncludeVersions All -Verbose -CompressionSize 100000000
Import-SPWeb $moveTo -Path $backup -Force

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.

Using SQL inside Workflow

Thanks to iLove SharePoint for creating the “Execute SQL” action.

With it I was able to create a workflow against the add/change event in my document library to create a link to my equipment page based on if there is any information to link to.

I first store my select statement in a variable so I can log it to the history file (this was helpful with debugging the workflow.)

SELECT COUNT(DWG_NAME_) FROM AccessDatabase…[AccessTable] where DWG_NAME_ = ‘[%DocumentLibrary:FileName%].DWG’

Then using the Execute SQL action, I can query the Access Database to see if there is anything I want to link to and store the results in a variable. I can then also show how many items there are in the hyperlink text. (The connection string I used was: Data Source= OFFICESERVER;Initial Catalog=WSS_Content;Integrated Security=SSPI. This particular server uses Studio Express on the same server as SharePoint.)

So if there is something to link to, I create the URL text: Store Helpful text-[%Variable: SQLResult%] in Variable: URLText.

Then I build the URL string:

And store it in the hyperlink column of my document library. The user will know that only the drawings with links have something in the Access Database to look at:

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.

 

 

From SharePoint List thru Excel to Web Part

How do you take information from your SharePoint list and display it in a pivot table on a SharePoint page? This can be achieved by using Excel’s Data Connections and Excel Services. This article will walk through the steps of going from a SharePoint list to an Excel Pivot Table and then to displaying the pivot table on a SharePoint page.

 

Export the list to a pivot table

 

Change the view of the list to “Edit in Datasheet”.
  

On the right side of the list is a subtle arrow. This is the hidden task pane. Click the arrow to open the task pane.

 

Select “Create Excel Pivot Table Report”

  

Choose the fields to put on the pivot table.

 

For more information on creating Pivot Tables with Excel 2007 see the Excel 2007 Courses site.

  
Change the name of your Pivot Table to something meaningful. This is how you’ll identify the table to the web part.
Publish to Excel Services

 

When you’re ready to publish your table, select the windows button > Publish > Excel Services.
  

Select the SharePoint document library you’d like to publish to.

 

If you need to add a network place, use the “new folder” button to launch the wizard.

  
Open “Excel Services Options…”
  
Select “Items in the Workbook” from the Show selection dropdown.
  

Select the pivot table created and click “OK”.

 

After naming the file, click “Save”. This will publish the workbook to SharePoint and Excel Services.

  
Excel Services will open with a preview of the report created.

 

Close the tab when you’ve finished reviewing the output.

 

 

Create the Web Part Page

 

Back on the SharePoint site, create a new page.
  

Enter in a Title, the URL Name (without spaces, using CamelCase), and “Blank Web Part Page” for the layout.

 

Create.

  
Add a web part
  
Add an Excel Web Access web part.
  

In the web part, you’ll see “Click here to open the tool pane.”

 

Inside the tool pane, the ellipsis next to the Workbook will open a browse menu to libraries/lists in the site. Locate the document library the workbook was published to.

 

You may need to use the paging option at the top to retrieve the next set of options.

  

Select the workbook that was published earlier.

 

Alternatively, if you have the URL, you can just enter that into the Workbook field.

  

In the Named Item, enter the name of the pivot table (exactly as it was named earlier in the workbook.)

 

Click “Apply”.

 

Click “Save and Stop Editing” to view the page normally.

  

The page will be saved into the “Pages” document library, a library that is common to all SharePoint sites.

 

Copy the URL to add to a link list.

  
This link can then be added to another page more accessible to others.
Refreshing the list

 

When the originating SharePoint list has changed, for example new items have been added to the list, the excel pivot table will need to be opened and refreshed. (Instructions on having the data refresh automatically will be added in another post.)

 

Open the document library housing the spreadsheet, and “Edit in Microsoft Office Excel.”
  
On the “Data” tab, select “Connection” and “Refresh”, then “Close”.

 

You should see the new totals reflected on the pivot table in the workbook.

 

Click “Save”. Since the workbook was opened from SharePoint it will save back to SharePoint. You do not need to republish it.

 

Close the workbook and refresh the page with the web part to view new data.