Archive for the ‘InfoPath’ Category

How to know what site template are we using?

Reference:

· http://sharepointmadeeasy.blogspot.com/2009/01/how-to-identify-template-used-to-create.html

· http://blogs.solidq.com/sharepoint/Post.aspx?ID=55&title=How+to+know+what+site+template+are+we+using%3F

When we create a new Site in SharePoint, we have to choose what site template are going to use. We choose among a lot of options, considering what we are going to need in our Site, and after clicking on "Create", we forget the name of the template what we have chosen. Normally, we don’t need to remember the name of that template, but…what happens if some time later, we need to know exactly what site template are we using? For example, if you want to clone your site (my case).

Through SharePoint UI, doesn’t exist a way to find out what site template we are using. So, after a search, I have found exactly what I was looking for in this post (http://praveenbattula.blogspot.com/2010/08/know-site-template-used-for-sharepoint.html). After reading it, i have thought that maybe a better option would be to make a very simple script in PowerShell that returns the Id of the site template, and its internal name. Here is:

protected override void OnLoad(EventArgs e)

{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPWeb thisWeb = this.Web)
{
lblWebTempalte.Text = thisWeb.WebTemplate;
lblWebTemplateID.Text = thisWeb.WebTemplateId.ToString();
}
});
}

Also I leave the list of equivalence between the ID and the corresponding name of the site template (taken from the post commented before)

Site template ID to Name mapping:
0 – GLOBAL (SetupPath=global) – "Global template"
1 – STS – "windows SharePoint Services Site", "Team Site", "Blank Site", "Document Workspace"
2 – MPS – "Basic Meeting Workspace", "Blank Meeting Workspace", "Decision Meeting Workspace", "Social Meeting Workspace", "Multipage Meeting Workspace"
3 – CENTRALADMIN – "Central Admin Site"
4 – WIKI – "Wiki Site"
7 – BDR – "Document Center"
9 – BLOG – "Blog"
20 – SPS (OBSOLETE) – "SharePoint Portal Server Site"
21 – SPSPERS – "SharePoint Portal Server Personal Space"
22 – SPSMSITE – "Personalization Site"
30 – SPSTOC (OBSOLETE) – "Contents area Template"
31 – SPSTOPIC (OBSOLETE) – "Topic area template"
32 – SPSNEWS (OBSOLETE) – "News area template"
33 – SPSNHOME (SubWebOnly) – "News Home template"
34 – SPSSITES – "Site Directory area template"
36 – SPSCOMMU (OBSOLETE) – "Community area template"
38 – SPSREPORTCENTER – "Report Center Site"
39 – CMSPUBLISHING (SetupPath=SiteTemplates\PUBLISHING) – "Publishing and Team Collaboration Site"
40 – OSRV (SetupPath=SiteTemplates\OSRV) – "Shared Services Administration Site"
47 – SPSPORTAL – "Corporate Intranet Site"
50 – SRCHCEN – "Search Center"
51 – PROFILES – "Profiles"
52 – BLANKINTERNETCONTAINER – "Internet Presence Web Site"
53 – BLANKINTERNET – "Publishing Site", "Press Releases Site", "Publishing Site"
54 – SPSMSITEHOST – "My Site Host"
90 – SRCHCENTERLITE (SetupPath=SiteTemplates\SRCHCENTERLITE) – "Search Center Lite"
6221 – PWA (SetupPath=SiteTemplates\PWA) – "Project Web Access Site"
6215 – PWS (SetupPath=SiteTemplates\PWS) – "Project Workspace"
14483 – OFFILE – "Records Repository", "Records Repository"

Advertisements

Reference : http://www.bizsupportonline.net/infopath2007/calculate-date-difference-infopath-rules-formulas.htm

Use rules, conditions, and the number(), floor(), and substring() functions in formulas to calculate the difference between two date picker controls in InfoPath.

Problem

You have an InfoPath form template with two date picker controls and you would like to calculate the difference between the two date picker controls without writing code.

Solution

Use rules, conditions, and the number(), floor(), and substring() functions in formulas to calculate the difference between two date picker controls in InfoPath.

Discussion

You can accomplish this functionality as follows:

  1. Design an InfoPath form template as shown in figure 1 with two Date Picker controls named startDate and endDate, and one Text Box control named difference.

    Figure 1. InfoPath form template in Design mode.

    The Main data source of the InfoPath form template should resemble the following figure:

    Figure 2. The Main data source of the InfoPath form template.

  2. Add the following Rule to the startDate field:
    Action: Set a field’s value
    Field: difference
    Value:

(number(substring(../my:endDate, 9, 2)) + floor((153 * (number(substring(../my:endDate, 6, 2)) + 12 * (floor((14 – number(substring(../my:endDate, 6, 2))) div 12)) – 3) + 2) div 5) + (number(substring(../my:endDate, 1, 4)) + 4800 – (floor((14 – number(substring(../my:endDate, 6, 2))) div 12))) * 365 + floor((number(substring(../my:endDate, 1, 4)) + 4800 – (floor((14 – number(substring(../my:endDate, 6, 2))) div 12))) div 4) – floor((number(substring(../my:endDate, 1, 4)) + 4800 – (floor((14 – number(substring(../my:endDate, 6, 2))) div 12))) div 100) + floor((number(substring(../my:endDate, 1, 4)) + 4800 – (floor((14 – number(substring(../my:endDate, 6, 2))) div 12))) div 400) – 32045) – (number(substring(., 9, 2)) + floor((153 * (number(substring(., 6, 2)) + 12 * (floor((14 – number(substring(., 6, 2))) div 12)) – 3) + 2) div 5) + (number(substring(., 1, 4)) + 4800 – (floor((14 – number(substring(., 6, 2))) div 12))) * 365 + floor((number(substring(., 1, 4)) + 4800 – (floor((14 – number(substring(., 6, 2))) div 12))) div 4) – floor((number(substring(., 1, 4)) + 4800 – (floor((14 – number(substring(., 6, 2))) div 12))) div 100) + floor((number(substring(., 1, 4)) + 4800 – (floor((14 – number(substring(., 6, 2))) div 12))) div 400) – 32045)

with the following Conditions on the Rule:
startDate is not blank and
endDate is not blank

  1. Add a second Rule to the startDate field with the following settings:
    Action: Set a field’s value
    Field: difference
    Value: 0

    with the following Conditions on the Rule:
    startDate is blank or
    endDate is blank

  2. Add the following Rule to the endDate field:
    Action: Set a field’s value
    Field: difference
    Value:

(number(substring(., 9, 2)) + floor((153 * (number(substring(., 6, 2)) + 12 * (floor((14 – number(substring(., 6, 2))) div 12)) – 3) + 2) div 5) + (number(substring(., 1, 4)) + 4800 – (floor((14 – number(substring(., 6, 2))) div 12))) * 365 + floor((number(substring(., 1, 4)) + 4800 – (floor((14 – number(substring(., 6, 2))) div 12))) div 4) – floor((number(substring(., 1, 4)) + 4800 – (floor((14 – number(substring(., 6, 2))) div 12))) div 100) + floor((number(substring(., 1, 4)) + 4800 – (floor((14 – number(substring(., 6, 2))) div 12))) div 400) – 32045) – (number(substring(../my:startDate, 9, 2)) + floor((153 * (number(substring(../my:startDate, 6, 2)) + 12 * (floor((14 – number(substring(../my:startDate, 6, 2))) div 12)) – 3) + 2) div 5) + (number(substring(../my:startDate, 1, 4)) + 4800 – (floor((14 – number(substring(../my:startDate, 6, 2))) div 12))) * 365 + floor((number(substring(../my:startDate, 1, 4)) + 4800 – (floor((14 – number(substring(../my:startDate, 6, 2))) div 12))) div 4) – floor((number(substring(../my:startDate, 1, 4)) + 4800 – (floor((14 – number(substring(../my:startDate, 6, 2))) div 12))) div 100) + floor((number(substring(../my:startDate, 1, 4)) + 4800 – (floor((14 – number(substring(../my:startDate, 6, 2))) div 12))) div 400) – 32045)

with the following Conditions on the Rule:
startDate is not blank and
endDate is not blank

  1. Add a second Rule to the endDate field with the following settings:
    Action: Set a field’s value
    Field: difference
    Value: 0

    with the following Conditions on the Rule:
    startDate is blank or
    endDate is blank

  2. Add the following Rule to the difference field:
    Action: Set a field’s value
    Field: .
    Value: 0

    with the following Condition on the Rule:
    difference does not match pattern Custom Pattern: -{0,1}d+

You should now have a fully functional InfoPath form that will calculate the difference between the dates soon after you have entered valid dates. This solution also works for InfoPath 2003 form templates and InfoPath 2007 browser-enabled form templates.

InfoPath forms can be deployed to a SharePoint document library, and assuming that the form template has been developed to be browser compatible, the form can be opened in a browser client (either when the user’s machine doesn’t have the InfoPath client or when the SharePoint document library is configured to open forms by browser only).

Such form templates can usually be published directly to a SharePoint document library without Administrator intervention, however, when the form template contains managed code the form cannot be published directly to the SharePoint document library, but has to be first Approved by the SharePoint Administrator.

The Administrator has to approve the template, upload it and then activate it against 1 or more site collections.

The process begins be publishing the form template as usual, at the screen shown below, select “Enable this form to be filled out using a Browser” and select “Administrator Approved form template”

Continue the publish procedure as normal, except that you will be publishing to a network share (or other location) accessible to the Sharepoint Administrator who can then review the form template and approve it.

The Sharepoint Administrator must then;

  1. Upload the template to SharePoint
  2. Activate it against site collection(s)
  3. Associate the form template with a form library

To Upload the template;

  1. Go to Central Administration for your farm
  2. Select Application Management, from there select InfoPath Forms Services, and then choose Manage Form Templates.
  3. The Form Template library is opened, which is where administrator approved templates for the farm are stored.
  4. Select “Upload Form Template”. Locate and select the saved template file and click the Verify button. You will be shown any errors or warnings related to your template (review them if necessary), and click OK.
  5. Locate your form template again. The Upgrade options exist for you to choose how to upgrade the form template if it already exists.
  6. Click the Upload button to perform the form template upload. It is now available as a Feature to be activated against any site collection in the farm.

To Activate the form template on a Site Collection;

  1. You can activate the form template feature from the Manage Form Templates page of Central Administration, the same page where we just uploaded the template. From the templates context menu, choose Activate to a Site Collection.
  2. In the Location section of the page, choose the relevant Site Collection and click the OK button.

Note, that you may have to change the Web Application location in order to find the right site collection.

To Associate the Form Template with a Form Library;

  1. Create a new form library or use an existing one
  2. Select the library’s advanced settings page and configure the library to allow content-type management
  3. Optionally, you might want to select the “Display as Web-Page” setting
  4. Click OK
  5. From the Content Types section, select “Add from existing site content types”, from the list box displayed locate your form template, click Add then click OK.

If you return to your form library and select New from the library menu, you should see an option there for your form template. If you choose this new option, the form template should be opened in the browser.