Thursday, November 8, 2012

Some Advanced InfoPath Rules

In this tutorial I will create a "smart" InfoPath form that will change its contents based on some scenarios.

Scenario: 

> employees subscribe each month for some company benefit in the upcoming month.
> subscriptions are open from 24th till the end of the month otherwise closed.
> once an employee has subscribed it cannot subscribe again in that month (show instead a thank you page).

Solution:

This can be achieved by creating a Site Workflow that registers the data into a SharePoint List. The Workflow form is customized with InfoPath. In this post I will insist on the form.

Prerequisites:

1. Have a SharePoint List to store subscriptions. Fields:

  • Person (Person type)
  • MonthTag (String type. It will contain "2012-11" like strings to identify the month when the subscription was made. This will allow easy grouping and filtering for later processing.)
  • SuperscriptionID (String type. Combination of Person Username and MonthTag to determine if a person already subscribed for that month. Its value is calculated by the workflow and filled in at creation. E.g.: "2012-11.Levente.Rog")
  • Any other fields that need input from the user.

2. A Site Workflow that creates the subscription (adds an entry in the above mentioned list). End users will Start the workflow itself (by giving them a link). This Workflow will have the following steps:

  • Generate the Month Tag (2012-11 like strings)
  • Generate SuperscriptionID (2012-11.Levente.Rog -like strings)
  • Create an Item in the Subscriptions List with the previously mentioned values. Using the Workflow Context:Initiator variable we know who is the logged in user so the end user does not have to fill out his own name in the form (that would be lame isn't?)
  • Send a confirmation email
Upon request I can create a tutorial explaining in greater detail covering these workflow steps.


Form Customization


The form of the Workflow is the one that I will customize now.
This is how I managed to solve this scenario:


What I did is I created separate sections for three scenarios (disregard the 201-12. section for now, I will explain that later).

1. First scenario is when registrations are open. Two conditions have to fulfill for this section to show up:

  • Date of month >= 24
  • User has not subscribed yet in the upcoming month


To achieve this, I created the following InfoPath Formatting rules with the action to Hide the section.

  • The expression: number(substring(xdDate:Today(), 9, 2)) < 24



  • Any occurence of Subscription ID is equal to concat(substring(addDays(today(), 30), 1, 7), ".", translate(userName(), "ABCDEFGHIJKLMNOPQRSTUVWYXZ", "abcdefghijklmnopqrstuvwyxz"))

    What I did with that function is:
    Generate the "Month Tag" that is a unique string each month. Since we subscribe for benefits for the next month we calculate one month (addDays 30) forward and crop the first 7 characters from the ISO Date to get a 2012-11-like key. We concatenate that with the lowercase username. This way we'll get something like:
    2012-11.levente.rog . We also record that same string in the SharePoint list as well. This way we know if that user already subscribed for that month.
    - Any occurrence of Subscription ID - we get that by creating a second connection to the same SharePoint List (Data Ribbon -> To SharePoint List). If any of those empty comes out true, the section will be hidden.





2. If the user has already subscribed show a thank you message.
One rule I have here, basically the negated version of rule #2 seen previously:

  • All occurences of Subscription ID are not equal to concat(substring(addDays(today(), 30), 1, 7), ".", translate(userName(), "ABCDEFGHIJKLMNOPQRSTUVWYXZ", "abcdefghijklmnopqrstuvwyxz"))









3. Show a registrations are closed message if date is <= 24th.
This is also a variation, negating the #1 rule used in the first scenario.

  • The expression: number(substring(xdDate:Today(), 9, 2)) >= 24









4. That dummy "2012-12" section is just a calculated value containing the Subscription ID generation formula. For some reason, when I haven't actually used this formula, it was not evaluated in the rule. This section is always hidden from the end user (by creating a dummy rule: myfield does not equal "asdf" => Hide).
  • Calculated Value XPath expression: concat(substring(xdDate:AddDays(xdDate:Today(), 30), 1, 7), ".", translate(xdUser:get-UserName(), "ABCDEFGHIJKLMNOPQRSTUVWYXZ", "abcdefghijklmnopqrstuvwyxz"))





















That's it. Save and Publish.

The workflow is redirected to itself by changing the &Source= parameter in the URL the link to the workflow itself. For example:
http://sptest/Subscriptions/_layouts/IniWrkflIP.aspx?TemplateID={fd570692-3e3e-4c6d-a613-d11932bfc5e2}&Source=http://sptest/Subscriptions/_layouts/IniWrkflIP.aspx?TemplateID={fd570692-3e3e-4c6d-a613-d11932bfc5e2}

After completing the workflow, it will be redirected to itself again, showing the same form. But since the user now is subscribed, the "Thank you" section will show up this time.

Tuesday, November 6, 2012

SharePoint Workflow Cannot Access External List

SharePoint Server 2010.


I set up a Site Workflow that reads some properties of an employee from an external SQL Database.
> created a dbreader user in SQL Server
> added the SQL credentials to Secure Store
> created External Content Type in Designer
> created External List based on the previously created ECT
> user is able to see data in the External List
> created Workflow that reads data from the External List.
> running the Workflow will return empty data for any query from the External List
> following error in the logs

w3wp.exe (0x029C)                         0x3D4C  Secure Store Service            Secure Store                    efr5  High      ValidateCredentialClaims - Access Denied: Claims stored in the credentials did not match with the group claim for a group app.
w3wp.exe (0x029C) 0x3D4C Secure Store Service Secure Store 7493 Critical The Microsoft Secure Store Service application Secure Store Service failed to retrieve credentials. The error returned was 'Access is denied.'. For more information, see the Microsoft SharePoint Products and Technologies Software Development Kit (SDK).
w3wp.exe (0x029C) 0x3D4C Secure Store Service Secure Store efp6 Monitorable GetRestrictedCredentials failed with the following exception: System.ServiceModel.FaultException`1[Microsoft.Office.SecureStoreService.Server.SecureStoreServiceFault]: Access is denied. (Fault Detail is equal to Microsoft.Office.SecureStoreService.Server.SecureStoreServiceFault). &nbsp
w3wp.exe (0x43B8) 0x4320 SharePoint Foundation Workflow Infrastructure el2x Medium The workflow could not find the specified item in the external data source. Make sure the user has permissions to access the external data source and read items.

Solution:

The System Account had no permission over the Secure Store Object to read the credentials to the SQL Server. The System Account is the account which is running the Application Pool .

Central Administration -> Manage Service Applications -> Secure Store Service : Manage -> Edit the application ID -> Next -> Next -> Add the AppPool user to the Members list.


A really nice, detailed guide on Business Connectivity Services can be found here.

Wednesday, October 24, 2012

Delete a wireless profile in Windows 8

Sometimes you're in the need to manually delete a wireless network profile, for example when your settings have changed and you can no longer connect to the wireless network.

Apparently, Windows 8 has removed this functionality from the GUI.

You have the following options left:


  • NETSH command


C:\Users\levente.rog> netsh wlan delete profile name="Chihuahua"
Profile "Chihuahua" is deleted from interface "Wi-Fi".

As a side-note, it's worth exploring the other options of netsh wlan.


  • 3rd Party Tool
WiFi Profile Manager 8 is a nice little tool written by Lee Whittington. Nice GUI, lightweight and easy to use. Get the tool from here.



  • Registry

Find the profile under the following registry path and delete the key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles


  • Windows Explorer

Navigate to C:\ProgramData\Microsoft\Wlansvc\Profiles\Interfaces to find and delete your profile (it's an xml file).



The hack explorer.exe shell:::{1fa9085f-25a2-489b-85d4-86326eedcd87} no longer seems to work, at least with build 6.2.9200.

Monday, October 1, 2012

Graph icons not showing up in Centreon

Ubuntu Server 12.04 x64
Nagois 3.4.1
Centreon 2.3.9
Nagios-Plugins 1.4.16
NDOUtils-1.5.2

I followed this excellent guide to install Nagios + Centreon from the ground.

After completing all steps and adding some Windows hosts to Centreon, the graph icons did not show up although I configured graphing at the service properties (except for ping).



Checking the logs revealed that in fact my db username was incorrect (it was Centreon instead of ndouser).

tail -n 5 /usr/local/centreon/log/centstorage.log

2012-10-01 16:37:49 - Error when connecting to database : Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
2012-10-01 16:37:51 - Error when connecting to database : Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
2012-10-01 16:37:53 - Error when connecting to database : Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
2012-10-01 16:37:55 - Error when connecting to database : Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
2012-10-01 16:37:57 - Error when connecting to database : Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)


so I opened up ndo2db.cfg to correct the credentials then restarted Centreon.

sudo vim /usr/local/nagios/etc/ndo2db.cfg