Wednesday, December 29, 2010

SharaPoint CAML OrderBy DefaultView Limit

The Default List view has direct effect on the number of records that return for the CAML query with OrderBy.
Changed the List's Default View limit to 5 and U see only 5items. Wierd One.
Hope this post will save a lot of time for people researching what the heck happened

Thursday, November 18, 2010

Truncate and shrink Transaction Log file in SQL Server 2008

SQL Server 2008

In SQL Server this process have been changed. In 2008, just change the recovery model to simple and then use DBCC Shrinkfile command.

use [YourDatabaseName]
select name,recovery_model_desc from sys.databases
GO
Alter database [YourDatabaseName] Set Recovery SIMPLE
GO
Declare @LogFileLogicalName sysname
select @LogFileLogicalName=Name from sys.database_files where Type=1
print @LogFileLogicalName

DBCC Shrinkfile(@LogFileLogicalName,1)



______________________________

If you may want to set the recovery back to Full. If so, add the following.
Alter database [YourDatabaseName] Set Recovery FULL

Thursday, May 27, 2010

XSLT String Padding

Create the Template

  <xsl:template name="leftjustify">
    <xsl:param name="content"/>
    <xsl:param name="width"/>

    <xsl:choose>
      <xsl:when test="string-length($content) &gt; $width">
        <xsl:value-of select="substring($content,1,$width)"/>
      </xsl:when>

      <xsl:otherwise>
        <xsl:value-of select="$content"/>
        <xsl:call-template name="spaces">
          <xsl:with-param name="length">
            <xsl:value-of select="$width - string-length($content)"/>
          </xsl:with-param>
        </xsl:call-template>
      </xsl:otherwise>

    </xsl:choose>

  </xsl:template>

  <xsl:template name="spaces">
    <xsl:param name="length"/>
    <!-- the value of this next variable is 255 spaces.. -->
    <xsl:variable name="longstringofspaces">
      <xsl:text>                                                                                                                                                                                                                                                               </xsl:text>
    </xsl:variable>
    <xsl:value-of select="substring($longstringofspaces,1,$length)"/>
  </xsl:template>




Usage:


<xsl:call-template name="leftjustify">
      <xsl:with-param name="content">You can do this</xsl:with-param>
      <xsl:with-param name="width">40</xsl:with-param>
    </xsl:call-template>


Tuesday, July 7, 2009

InfoPath 2007 Template Parts

Finding tough to keep the he sections, tables, fields, data connections and dropdown lists consistent between all forms.

The InfoPath 2007 was released and it has a new feature called Template Parts. Template Parts is a new type of InfoPath template that allows for predefined forms to be saved and then imported into the InfoPath Controls Task Pane. A Template Part is capable of saving Data Connections, Rules, Conditional Formatting, Data Validation and many other things. Just having this capability has saved me a tremendous amount of time when designing forms and it has increased the ROI for the client. A standard address block is one of the first things that I create for a new client because I'm able reuse it right away and show immediate ROI. At first you might not think this would have a big impact but when you take in account that, you no longer have to worry about defining the data source fields, layout table, field widths, colors, font style/size, data connections for states/regions and country, data validation, rules or conditional formatting then the ROI is reached pretty quickly. Once I understood this capability it changed how I started developing forms.

A feature of a Template Part that you need to take in consideration when using them to help designing forms is the Update capability. The Update capability allows for existing Template Part control on a form to be updated once the master Template Part control has changed and re-imported into the designer. At first this capability was frustrating because I didn't design everything with this in mind but after understanding how it worked, I quickly changed how I was designing forms and took advantage of the Update capability.

Long story short, Template Parts are great if you put thought into how you are building and using them. If you don't do this then it will just adds more complexity when building your InfoPath form and shouldn't be used.


Thursday, July 2, 2009

Infopath - Edit in Browser + Close = "The form has been closed." Annoyed?

(12Hive)\TEMPLATE\FEATURES\IPFSSiteFeatures\FormServerEcbEntry\EcbEntry.xml

Refer
http://geek.hubkey.com/2007/01/infopath-forms-services-close-button_17.html

Forcefully Activate "IPFSSiteFeatures" feature scoped to WebApp.
iisreset / recycle the application pool.

It must take you back without the annoying page "The form has been closed."
Update your upgrade document to redo the changes after the upgrade as upgrade may reset this feature.

Monday, June 29, 2009

Sharepoint Site Creation Notification Email

Steps Involved:

1. Create an event reciever
2. Create a feature to call the reiever when activated.
3. Create a feature stapler to staple the feature to Site Defs.

public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPWeb CurrentWeb = properties.Feature.Parent as SPWeb;
String Body = "A Sub Site Created with Title \""+ CurrentWeb.Title+ "\" with the URL "+CurrentWeb.Url;
foreach (SPUser user in CurrentWeb.Groups["AllAlerts"].Users)
{
SPUtility.SendEmail(CurrentWeb, false, false, user.Email, "Site Creation Alert", Body);
}
}

//Use the sharepoint inbuilt capability of sendin and email fron the SPUtility