Tuesday, October 6, 2009

JScript birth date madness

I had an earlier post on calculating a birth date in VBScript, but the IIR form was already set in java script which lacks a “datediff” function to calculate an age. It shouldn’t have been all that difficult to calculate just using date math, but there is a conversion issue when trying to use a date field in place of a string as the birth date source.

The issue is the use of ISO8601 format of YYYY-MM-DD versus the entry format of MM-DD-YYYY. The solution is to parse the string before doing the math. A complete "age" functions is as follows:

if (eventObj.IsUnDoRedo)
{
return;
}

//==============================================
//= On date of birth changed calculate age in years and set age field
//==============================================

var DOB = XDocument.DOM.selectSingleNode("my:myFields/my:DateOfBirth");

if ((DOB != null) && (DOB.text != ""))
{
var myStringList = DOB.text.split('-');
var DOBText = myStringList[1]+'/'+myStringList[2]+'/'+myStringList[0];

var dt1 = new Date();
var dt2 = new Date(DOBText);

var years = dt1.getFullYear() - dt2.getFullYear();

// Check to see if it's before or after this years birthday
dt2.setYear(dt1.getFullYear());

if (dt1 <>
{
years--;
}
SetField("Age",years);
}
}






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.

Wednesday, January 7, 2009

The Employee Newsletter and Really Simply Syndication

In the prior post I defined a number of Social Networking technologies and what they are normally used for. Our starting hypothetical, replacing the print version of an employee newsletter, frankly, just screams Blog. Unlike many other Social Networking techniques, a blog can remain directive in that, like this one, it can have one author with many readers (you can stop laughing anytime now.)

Blogs are designed specifically to host the same kind of articles and photos normally seen in a newsletter, while allowing for shorter posts and links to other resources of interest. In the case of our "hypothetical", an existing intranet page can be slightly rebranded and reorganized to fill this role, and remain sited on an already well-known and public Internet address.

The only realistic limitation with the Employee Newsletter in the form of a blog is the “opt-in” problem. Simply providing the message and advertising the site location internally is unlikely to see widespread adoption, and it doesn’t provide any medium for more urgent communication since the slowly changing nature of the content does not encourage staff to regularly visit the page.

One solution suggested was to co-opt Email as a means of notification by providing a link to the new story when it comes out. This suggestion can overcome the Opt-In issue, but at a heavy price. For an organization like mine, which has many employees in the field (and without corporate email accounts) the difficulty and propriety of maintaining a list of employees home email accounts for work related communications is a nightmare. Beyond that, even for employees with work accounts, such Email can easily become little more than spam to them, getting buried in the ever increasing email load. Also, we optimally want our newsletter to be directive not collaborative like email is, and therefore routinely advertising new stories via email will inevitably lead to more and more recursively generated email responses, which is what pretty much sunk the concept of ListServ’s (which attempted to leverage email in a similar fashion.)

An alternative to using Email is to use RSS (Really Simple Syndication.) While unlike email RSS still requires some form of simple opt-in, its flexibility and simplicity as well as its increasingly widespread adoption will encourage the maximum possible participation.

RSS

RSS revolves around the concept of subscription rather than a particular application. Its flexibility is that the subscriber decides the method of presentation by selecting the application he or she wants to use to subscribe to the site.


For our hypothetical, staff members at work can be subscribed as a team through SharePoint as pictured. The feed is typical in that it shows the latest headlines in a gadget on each team’s site; if someone has an interest in a particular post they can click on the link and be taken to that story. Or they can click on the title and be taken to the page. The communications person(s) publishing the story need do nothing except create the post. The RSS will update itself automatically.




The biggest advantage of RSS is that the user can select which application he or she wants the headlines to appear. If the person is Email centric to the point where they insist upon it (although I do not like it much) they can subscribe thru Email with most email systems, including all versions of outlook


One of the most popular methods, my own favorite for home use, is to fit the RSS feeds onto the personalized home page of your subscribed search engine, such as iGoogle, My Yahoo, or MSN, in the form of a widget or gadget or web-part or whatever else it's called this week.


This method is “work independent” since the person would be able to subscribe their search home page which will make it showup on any of their computers, including ones at home.

The final option I’m going to cover, although by no means the last kind of feed reader is the most mobile, and can be applied to all employees with company cell phones, or given as an opt-in to employees to use with their own phones. That is the cell phone news reader.

The cell phone reader seems to be an excellent option for our hypothetical, since it does not require access to a computer at work or at home and does not interfere with people who prefer other methods or have access to different means.

One downside, or course, is still getting people to subscribe, in that all RSS types still have an opt-in component (as well as a means for people to opt themselves out). But this can be mitigated in our case, first by placing the reader at all team SharePoint sites to enroll everyone who works at a desk, and second to provide the option and (quite simple really) instructions on how people can subscribe on their home search engine, or finally, for those people completely isolated from all other technologies, subscribing their company cell-phone.

The limitation to the company cell-phone distribution method is, most often, the type of account more than the phone, since all of the modern phones have readers built in. Still, in some situations, while the phone itself will support RSS, the account the phone is on may not.

Social Media and Employee Communications

Suppose company X is considering eliminating the printed version of its employee newsletter in favor of an alternative method of sharing interesting and important stories of interest to its people. Its executives are all too likely to pick up on buzzword’s like Social Networking or Web 2.0 and ask the legitimate question, “Is there any technology that can help?” Like most buzzwords the answer is yes, or no, depending on what the meaning of “help” is.

In applying the term “Social Media” we are really talking about using technology as a conduit to facilitate communication. With modern technology the overhead costs normally associated with traditional media, such as printing presses and broadcast licenses, disappears. This allows us to discard the old model of one person communicating to N number of people, if we wish, with a model of N number of people communicating with M number of people. 1..N becomes M..N.

This is why social media is collaborative in nature, while traditional media is directive. And it can be a curse as well as a blessing. For internal corporate communications, the professional working in a communications department might very well be forced to spend all of his or her time policing collaborative communication, doing damage control and swatting down rumors rather than staying focused on getting out the message the company wants to get to its staff.

Nevertheless there are versions of technologies that more or less fit the social media model that may be appropriate, enough that it is worthwhile to take an inventory of the technologies currently available, and place them into appropriate categories.

Communication

Stuff in the Communication category encompasses Blogs and Micro-blogs, Forums, Social Networks, Social Network Aggregation and events.

Blogs, such as blogspot, livejournal, or typepad, allow one or more users to create a webpage to post very short stories, opinions, photos and links on one or more topics. Some bloggers concentrate their efforts less on original work and instead post link’s with comments to stories from other blogs or traditional media web-pages, acting as a form of editor. Others exist to distribute original content.

The “Micro-Blogs”, such as twitter, are generally used to let a person’s social network, of friends and family, know what they are doing at that moment. These facilitate ad-hoc events like joining up for a dinner or going to a show. Used with mobile phones, the idea is that you can check to see if friends are available for something you want to do, or if they are doing something of interest to you.

Forums are centered on threaded content, you may post a question or comment as a means to solicit answers or additional comments. A forum topic can generate a large number or replies, including replies to replies...

Social networks, such as Facebook or LinkedIn, contrary to popular belief, do not create social networks. That is to say that people rarely, if ever, use them to find new friends. Instead they are used to surface already existing social networks. These are obviously popular among youth, especially since it demonstrates their social network in concrete terms, while being less popular among adults, whose social focus tends to be more on immediate family.

Social Network Aggregation, like FriendFeed can be used to combine different social networking sites into a single display.

Event sites are used primarily to leverage email as a means to invite your social network to a party or other event.

Collaboration

Collaboration sites include Wikis, Social Bookmarking, Social News and opinion.

If a blog is a diary, then a Wiki is an encyclopedia. The largest of which is Wikipedia. Wikipedia is an example of crowd-sourcing, where you make an open call to an undefined group of volunteers to produce a product. In Wikipedia’s case, any person with knowledge of, or an interest in, any topic can edit or create a page and write an entry. (Here is the entry for Easter Seals: http://en.wikipedia.org/wiki/Easter_Seals_(US) as an example.)

Social Bookmarking is a way for social groups to share links to common web-pages, as well as rate various web-pages and blogs. Social News Sites such as Digg, are built around rating news related web-content to encourage the reading of the most popular stories.

Entertainment

These sites include photo and video sharing sites, such as youtube and Photobucket, Livecasting sites that stream live video content from amateurs such as UStream, Music sharing sites like ccMixter, and massively multiplayer online games (MMORPG) like Eve and World of Warcraft.

This post has already gone on too long, so I’ll go back to addressing my original hypothetical, the elimination of the paper copy of the employee newsletter, in the next post.