Friday, May 1, 2009

Picking a single node from an eventObj

While we have already done code for a walkthru of all of the notes, after a column of buttons to our Daily Activity Worksheet Form it is important for us to be able to select values associated with that row, and only that row.

The object orientation of the JSCript code makes that a snap.

The button that was pressed, in particular, is the eventObj passed to the event handler. The "Source" Property is a reference to the other items in the row.

If we reference the form as seen, then the particular participant bound to the button in the row pressed is referenced as eventObj.Source.selectSingleNode("my:Participant").text



One important item of note, while doing the walkthru we used the path starting at the root... i.e. "//my:Participant". Since the button is already below the parent you need to reference it as "my:Participant" or at best, you'll always get the first child node.

Monday, February 23, 2009

Clearing some underbrush


One mistake I've noticed with the budget developer is the tendancy for webservie functions to grow like weeds. With a week left before deployment it's time to take a crack at seperating out those functions that are no longer required...

Thursday, February 12, 2009

Next Up

I'm on the SharePoint Tour, friday, in Torrance. Hoping that will go well while at the same time I'm going back to the Budget Developer. So I'll be spending time in this space organizing my thoughts, with a special concentration on "What-If" additions to budgeting.

So here is a very early list of what if's
  • Income impact of program income by percentage
  • Line item, across the board or by entity tree percentage changes
  • Reducing staff work days
  • Ratio tools for employment related costs

But I do need some basis for better study...

Friday, January 30, 2009

Forms within Forms

An interesting InfoPath request; Quality has a project where I would like to use an InfoPath form for intakes. The idea is that the Intake form would be a form of forms where the user would launch each of the forms required for enrollment from a single master form. This form should be able to launch a blank copy of each of the enrollment forms, and this is the kicker, that follow “Paul’s Golden Rule” and avoid requiring any duplicate typing.

Launching a form is a point and click exercise, doing so while exposing the other forms fields requires a bit of code, but as it turns out, not much.

var newForm = Application.XDocuments.NewFromSolution(http://sharepoint/sites/it/area54/Sample Face Sheets/Forms/template.xsn);

var participant = newForm.DOM.selectSingleNode("my:FaceSheet/my:Client_Name");

myField = XDocument.DOM.selectSingleNode("my:myFields/my:Test");

participant.text = myField.text;

The first line launches the form, you’ll need the path to the form template, but that’s it. Your newForm variable then contains XDocument for the form just launched, in this case the face sheet. Now you can grab a field value from the parent form and copy it into the new form.

Wednesday, January 28, 2009

Dash Phone as a laptop Internet connection

We are replacing Verizon as a carrier with T-Mobile, and so the QPhones we have been using are changing to a Dash phone, which has the same windows mobile operating system. But T-Mobile is actually sending out the USB cables to synch the new phones, if we would like, to a laptop or other workstation.

While our default configuration connects directly with our exchange server, limiting the ActiveSync to a workstation’s utility, there is one really nifty feature I tried out on the new phone last night.

You can use the phone as a cellular modem to connect your laptop to the internet while on the road.

To do so first install the ActiveSync software that comes with the phone. If you have already set-up your access to exchange it will keep that configuration and by default will only load your Internet favorites to the phone on synch, otherwise it changes nothing. In our case we really don’t want the synch, just the drivers it installs, which is why we never bothered with doing this on the Q Phones.

Once installed, close the program, and connect the phone to the laptop using the USB cable provided.

From now on you’ll be able to use the phone to connect to the internet wherever you have a signal for your phone. Just connect the cable, and then select “Start”, “Accessories”, “Internet Sharing” on the phone. There will be three fields on the phone, “Status”, “PC Connection”, and “Network Connection”. Leave the Network Connection on T-Mobile Data, make sure the PC Connection is still USB, and then use the left button on the phone to change the status from disconnected to connected.

The speed is not blazing, functionally its speed is roughly equal to a 28.8 modem, but it operates anywhere. That is worth it…

Monday, January 26, 2009

InfoPath Date Math Shuffle

Late Friday I got asked one of those seemingly simple questions whose simple answer is, as it turned out, missing. All my user wanted to do was have the difference between two dates calculate in her Infopath 2003 form. Naturally it’s a piece of cake in 2007… sigh.

But it can be done in 2003 with a fairly short VB script. Problem was I started out trying to write it as a Jscript and kept running into a lack of functionality… So anyway here is how to do the InfoPath 2003 Date Math Shuffle in all it’s glory.

Step One: Set the form to use VB Script in place of Jscript. This can only be done at the start, before you write any code for the form. Select Tools, then form options. This will open the form options dialog box, allowing you to select the Advanced Tab, where you can set the programming language to Visual Basic Script (VBScript as shown above).

To test it I added two date fields and a text field to a blank form.



Once there we can open our editor so we can add the code by grabbing the properties of the second date picker, select the onAfterChange event and click on the Edit button.



This will launch the Microsoft script editor for the proper event.

Of course after we’re done we should go back and add a call to the first date to the second date’s event in case the form’s user changes the first date after the second… heh.

But for now let’s just add the code. Thank goodness that the VB editor seems to have all the functionality that the Jscript lacked. At one point I was even considering a web-service call, but as it turns out that this VB script can handle this in a flash and without any of the nasty delays inherent in a web-service.

So, Step two is to write the code for the event. First we need to leave the premade code alone, it's only there in the event an "If eventObj.IsUnDoReDo" argument is present, and we don't care.

Below is the code, with further descriptions commented in the event you want to cut and paste it in as is...

‘==========
‘ date_from follows the XDocument path to get access to the forms SecondDate Field
‘ date_to is the same for the first date field
‘ dt1Val is a variable where we will load the value of the date_from field
‘dt2Val is a variable where we will load the value of the date_to field
‘daysElapsed is a variable where the difference is calculated
‘==========

Dim date_from
Dim date_to
Dim dt1Val
Dim dt2Val
Dim DaysElapsed

‘=====
‘ Now we set the date_from and date_to so we can read the fields
‘=====

Set date_from = XDocument.DOM.selectSingleNode("/my:myFields/my:SecondDate")
Set date_to = XDocument.DOM.selectSingleNode("/my:myFields/my:FirstDate")

‘======
‘ Then we test the fields to see if we have dates in both fields, if so then we calculate the difference and put

‘ it into the display field on the form, otherwise we make the display field blank
‘======
If (date_from.Text <> "") and (date_to.Text <> "") Then
dt1Val = CDate(date_from.Text)
dt2Val = CDate(date_to.Text)
daysElapsed = DateDiff("d",dt2Val,dt1Val)
XDocument.DOM.selectSingleNode("/my:myFields/my:Difference").Text = daysElapsed
else
XDocument.DOM.selectSingleNode("/my:myFields/my:Difference").Text = ""
End If

All that is left is to call this function when the first date changes by creating it’s event just as you did the second date fields and copying the function call, in this case:

msoxd_my_SecondDate_OnAfterChange(eventObj)

Not too shabby, but having Microsoft add the DateDiff function to InfoPath, as I believe they did in 2007 would have saved my people a lot of trouble.

Tuesday, January 20, 2009

Trouble with Key-loggers

Came in this morning, opened my email, and discovered that one of my users had fallen prey to a key-logger. While no corporate accounts were accessed, only her personal email, it is nevertheless disturbing. Increasingly we find ourselves using public facilities to access the internet, and many internet features are secured with weak passwords.

In our case, here at ESSC, we are also protected with Passfaces, which can and does defeat key-logging. Additionally, outside of some executive accounts for GotoMyPC, we live behind a very strict firewall.


It’s those accounts that presented a security hole, since the users would remain logged in to our network for ease of access when connecting via GotoMyPC, skipping the security of Passfaces and therefore leaving us vulnerable.

To fix this issue we are requiring those who have GotoMyPC accounts to set their workstation to require a password on waking the screen saver.

To do this the user first needs to right click on a blank area of the screen, which will open a pop-up menu. Selecting “Properties” from the pop-up menu will open the Display Properties dialog box.

The user can then click on the Screen Saver tab, select a screen saver (it will not work without a screen saver selected) and put in the length of time before the screen saver is activated. If the checkbox labeled “On resume, password protect” is checked, then the user will be required to log back into our network whenever the screen saver activates itself.

This solves our GotoMyPC issue since the faces in the Passfaces grid cannot be hacked by a key-logger.