Wednesday 29 May 2013

SharePoint List with Data

Create a new SharePoint Farm Project

Add a new List Definition and call it JobTitles_LD

Give the List Definition the following Properties
Name: Job Titles
Type: Custom List
Add List Instance: False || True (it's your call)

Add a new list instance and call it JobTitles_LI

Give the list the following properties
  • Name: Job Titles
  • List Type: Job Titles
  • Description: Available Job Titles
  • List URL: Lists/JobTitles
  • Quick Launch: False


Rename feature1 as NewEmployee_WebScoped

Open up the feature manifest
  • Give your feature a title and description
  • Set the scope to web
  • Make sure that your list instance and definitions are in the elements manifest; that it is in the right hand column.


Open up the elements file of your list instance, by default it should look something like this:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <ListInstance Title="Job Titles"
                OnQuickLaunch="TRUE"
                TemplateType="10000"
                Url="Lists/JobTitles"
                Description="Available Job Titles">
  </ListInstance>
</Elements>
What you’re going to do is add data to it like so
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <ListInstance Title="Job Titles"
                OnQuickLaunch="TRUE"
                TemplateType="10000"
                Url="Lists/JobTitles"
                Description="Available Job Titles">
    <Data>
      <Rows>
        <Row>
          <Field Name="Title">Application Programmer</Field>
        </Row>
        <Row>
          <Field Name="Title">Business Analyst</Field>
        </Row>
        <Row>
          <Field Name="Title">Software Developer</Field>
        </Row>
        <Row>
          <Field Name="Title">Software Architect</Field>
        </Row>
        <Row>
          <Field Name="Title">Information Architect</Field>
        </Row>
        <Row>
          <Field Name="Title">Information Wizard</Field>
        </Row>
      </Rows>
    </Data>
  </ListInstance>
</Elements>
And that’s it you’re done, deploy your project and you should have a list with your specified data.

Monday 27 May 2013

Create Data Connection Library


Prerequisites: the Data connection Library is only available for the Enterprise Version of SharePoint

First go to site setting -> Manage Site Feature

Next activate the SharePoint Server Enterprise Site Features
and now when you go to create a new document library, the Data Connection Library is available.

so lets go ahead and create our library.
Our list Library url should be: http://yoursite:portnumber/Data Connections/

now all that being said you could instead activate it using a feature receiver like so

// Uncomment the method below to handle the event raised after a feature has been activated.
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
    using (SPWeb web = properties.Feature.Parent as SPWeb)
    {
        //SharePoint Server Enterprise Site features guid
        Guid spServerEnterpriseSiteFeatures = new Guid("0806d127-06e6-447a-980e-2e90b03101b8");
 
        if (web.Features[spServerEnterpriseSiteFeatures] == null)
        {
            web.AllowUnsafeUpdates = true;
            web.Features.Add(spServerEnterpriseSiteFeatures, true);
            web.AllowUnsafeUpdates = false;
        }
 
        CreateList(web, "Data Connections"SPListTemplateType.DataConnectionLibrary);
    }
}
 
private void CreateList(SPWeb web, string listName, SPListTemplateType listType)
{
    string description = string.Format("{0} created programatically", listType.ToString());
 
    if (web.Lists.TryGetList(listName) == null)
    {
        web.AllowUnsafeUpdates = true;
        web.Lists.Add(listName, description, listType);
        web.AllowUnsafeUpdates = false;
    }
}

Thursday 23 May 2013

Publish Form: Network Location

To wrap up my final post in this series, I'm going to publish my form to a Network location, this is useful if you are a crazy person such as myself who insists on having very compartmentalized packages. My live installation method should not include InfoPath designer or SharePoint destroyer.

so navigate to your file tab and select the Publish Option

Hit the browse button and pick the network location you wish to publish your form to.

Next make sure to clear out the access path and hit next

you should see something along the lines of

and that`s it your done.

Wednesday 15 May 2013

InfoPath Submit via Rules

For the sake of completion I`m going to continue on from my much more interesting previous post and create a submit button using rules. Go to the Home Tab, and click the manage rules button; to save yourself a step have the Button on your form in focus.

This will bring up the rules Pane, if you haven`t already bring your form button into focus (click on it). With your future submit button selected click the New drop down list and pick Action.

Rename Rule1 to Submit or SubmitRule or whatever you find more descriptive. Hit the add dropdown list and select Submit data.

With the Rule Details box open click the Add button, this will start the data connection wizard.

Leave the first window of the wizard in its default state and hit next

In the second window select your the fourth option `To the hosting environment  such as an ASP.NET page or a hosting application.` then hit next.

Leave the third window in its default state if you`d like.

this will bring you back to the Rule Details page from before, just hit OK.

and there you go, your submit button now posts back to your hosting environment. Now it`s time to give your submit button a more descriptive display text then Button, to do this just right click on the button and select button properties. Change the Label textbox from Button to Submit or whatever else your heart desires.
the final step is to publish your form to a network location and make it SharePoint ready, I`ll do that in my next post.

Tuesday 14 May 2013

InfoPath Dropdown Site Groups

To get started open up InfoPath, create a Blank Form, add one drop down list and a button; below is more or less what it should look like.

In the fields menu on the right rename myFields to “Association Fields” and field1 to “SelectedGroup”. You can do this by right clicking on each of the default names, and selecting properties. Give the field a new name and hit save. If the Fields pane is not available go to the Data menu and click the show fields button.

Next let`s set up our SOAP service, to pull this off go to your Data Menu, hit the From Web Service button and select From SOAP Web Service.

Next enter in the url of your SOAP service http://yoursite:portNumber/_vti_bin/UserGroup.asmx?WSDL

On a side note if you want to view all the web services available go to
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI or check out
SharePoint Foundation 2010 Web Services.

Select the SOAP function you want in our case it`s GetGroupCollectionFromSite

Leave it unchecked, if you`re curious read it.

Leave the default name.

Next you`re going to have to publish the source files, hit the File menu, click the publish tab and click the export source files button

Put your source files somewhere where you`ll remember.

once saved Make sure to close InfopPath and navigate to the file folder where you saved the source files.

This next part is the magic, it was shown to me by a consultant that I worked with, not sure where she got it from but wow I`d have never come up with this, so kudos to her.

Your Main concern is going to be with the GetGroupCollectionFromSite1.xsd file. Open that sucker up in some sort of XML viewing software.
Now the third line from the top should be

<s:import namespace="http://www.w3.org/2001/XMLSchema"></s:import>

Directly after it add the following XML

<s:complexType name="GetGroupsFromSiteType">
  <s:sequence>
    <s:element minOccurs="0" maxOccurs="1" name="Groups">
      <s:complexType>
        <s:sequence>
          <s:element maxOccurs="unbounded" name="Group">
            <s:complexType>
              <s:attribute name="ID" type="s:unsignedShort"></s:attribute>
              <s:attribute name="Name" type="s:string"></s:attribute>
              <s:attribute name="Description" type="s:string"></s:attribute>
              <s:attribute name="OwnerID" type="s:unsignedByte"></s:attribute>
              <s:attribute name="OwnerIsUser" type="s:string"></s:attribute>
            </s:complexType>
          </s:element>
        </s:sequence>
      </s:complexType>
    </s:element>
  </s:sequence>
</s:complexType>

Keep in mind that the ID, Description, OwnerID, OwnerIsUser fields are optional for this example, you don`t use them in the form, but hey you might. Next search for the text "GetGroupCollectionFromSite" it should be around line 340, just before or right after and look like:

<s:element name="GetGroupCollectionFromSite">
  <s:complexType></s:complexType>
</s:element>

now replace it with

<s:element name="GetGroupCollectionFromSite" type="tns:GetGroupsFromSiteType"/>

save the file up and close it

next open up InfoPath once again and open the source files manifest file through Infopath, don`t just double click on the file.

After you`ve opened up your source files, right click on the drop down list-box and hit the properties

Next you should see the Drop-Down List Box Properties Form, under List Box Choices pick the third option “Get choices from an external data source”

Click the entries button and select the group

do the same for the value and display name fields, make sure to pick the Name property

next you may have some permission issues, if that`s the case then set your form security to full trust. It`s your form so I don`t see why that would be a problem.

You should be able to hit the preview button now and your drop down list should be populated with all of the site groups.

There`s still the matter of setting up the submit button, but that`s fairly trivial and for my next post cause this one is far too long in my opinion.

Thursday 9 May 2013

Infopath form Id

If you`ve read any SharePoint workflow book or blog about deploying infopath forms with a visual studio workflow you`ve no doubt come across the method of adding your infopath form to your workflow, changing the deployment type to `element file`; deploying your solution, going into central admin, under General Application Settings, then under the infopath section clicking manage form templates, picking your form out of the list, checking it`s properties and finally getting the ID.


Wow that`s a lot of clicks, when instead all you had to do was go to the file Menu in Infopath and click Form Template properties.




Is this going to change your life? Not really, but hopefully make it marginally better 9 to 5.