Monday, April 16, 2012

SharePoint 2010 PreSaveAction() saves the day...

Looking for a quick way to do some validation when working on a SharePoint 2010 Foundation product and you don't have access to the InfoPath toolbox that SharePoint Server 2010 provides??  Let me introduce you to PreSaveAction() javascript call!  This function is available in 2007 and 2010 it is just a little easier to access in the 2010 platform with the ability to edit list forms through the ribbon.  Below is a quick script from MSDN for validating that attachments are added to a List Item in a Custom List but this is just the beginning.  You could verify column formatting and any other PreSubmit work that you need to happen on your custom lists.  Place the script in a ContentEditor webpart on your NewForm.aspx and EditForm.aspx pages and you are ready to Validate your buns off!!

   <script language="javascript" type="text/javascript">;

function PreSaveAction() {
var attachment = document.getElementById("idAttachmentsTable");

if (attachment == null || attachment.rows.length == 0) {

document.getElementById(
"idAttachmentsRow").style.display = 'none';

alert("Attachments are required on this list.");
return false;
}else { return true; }

} </script>;

Wednesday, April 11, 2012

InfoPath 2010 Repeating Table Updates Field On Change

When working in InfoPath you can run into business situations where a fields value is set based on user selections in other fields.  This can add a layer of complexity when the fields exist in a Repeating Table as each row needs to be executed independently.  But do nt worry there is a simple solution for this requirement as each InfoPath form is just a structured XML document on the back end.  This solution is given as code behind as this provides the quickest solution.  The sample below executes on a change event of a control in a repeating table and not on the insertion of a row as this would present null issues in the code.

public void Control_Changed(object sender, XmlEventArgs e)

{
//check to ensure value changed and not just row add if so run the code
if (e.Operation == XmlOperation.ValueChange)
{
//connect to current row in dom
XPathNavigator xnDoc = e.Site.CreateNavigator();
xnDoc.MoveToParent();                               
//select node that was changed in current row
string myVar = xnDoc.SelectSingleNode("my:Node", this.NamespaceManager).Value.ToString();
//select node in current row to update
XPathNavigator UpdateNode = xnDoc.SelectSingleNode("my:NodeToUpdate"this.NamespaceManager);
UpdateNode.SetValue(myVar);
}

}

Thursday, March 8, 2012

Forms Based Authentication on an exisiting SharePoint 2010 Classic Mode web app

If you are trying to implement Forms Based Authentication on an exisiting SharePoint 2010 web application there is no way through Central Administration to change your existing Classic Mode Web Application to Claims Based.  Below is a quick and easy PowerShell script that will accomplish this for you.

$webapp = Get-SPWebApplication "http://yourwebappurl/"
$webapp.UseClaimsAuthentication = "True"
$webapp.Update()
$webapp.ProvisionGlobally()

At this point you are now set to complete the steps to implement Forms Based Authentication on your Web Application.

Wednesday, November 2, 2011

MUSCLE MAN...HULK OUT!!

Great after dinner action with my son showing his muscle pose after eating all of his celery like the wonder pets! 

Thursday, September 22, 2011

Blessed

Not sure if anyone else likes the show modern family but i love it. I mean i crack up like i havent ever or at least in a long time over a tv show. And i love it because they seem like a family. And is there anything better or more valuable than family? Today I took my son to the first of what i hope is many times to the golf course. And he had the time of his life. He absolutely had a blast. He loved being outside! He ran and splashed in mud puddles and had the time of his life. He even got to drive the golf cart. There was one scary moment but we made it through that too. Thank God!! We almost flipped the whole cart trying to catch his cap. Check him out.




On top of all this I birdied 17!

Friday, September 16, 2011

Rain

Thank you Lord for the rain that fell here in DFW. I dont remember the last time we saw rain. And my daughter says "God bless you Lord."

Thats a nice ending to a thank you blog post.

Thursday, September 15, 2011

Trying again....

This time i am back and hopefully here to chill a while. I have some good code snips to share and just ramblings on a windows and now apple life. 1st blog post from the ipad.