Hesham

See also: Other Geeks@INDC
SQL Queries in compatible info path forms
Introduction
Using SQL queries to (Add, Edit & Delete) data from DB via Info Path forms programmatically.

Steps
A) Creating the Database:
  • Open SQL Server Enterprise Manager through : (Start > All Programs > Microsoft SQL Server > Enterprise Manager), then in Console Root folder expand the Microsoft SQL Servers then expand the SQL Server Group then expand your instance then at the Databases folder right click on it and create a new database called “QueryDB” then expand the QueryDB database and right click on Tables to create a new table called “Resource” this table holds two columns: (ResourceID – ResourceName) as shown in this figure:

Click to enlarge 

Also , add a stored procedure called “UpdateResourceName” in order to update the ResourceName as shown in the figure:

Click to enlarge 

B) Creating the Web Service:

  • Open MS- visual studio .net 2005 then click File menu > New > Web Site > ASP.Net Web Service : Then in the App_Code folder open Service.cs file then add these namespaces: Using System. Data; Using System.Data.SqlClient; Then, add this web method to get all of the resource names from Resource table in the QueryDB database: 

[WebMethod]

    public DataSet GetResourceNames()

    {

        SqlConnection con = new SqlConnection("Data Source=(local);Integrated Security=SSPI;Initial Catalog=QueryDB");

        SqlDataAdapter da = new SqlDataAdapter("SELECT Resource.ResourceName FROM Resource", con);

        DataSet ds = new DataSet();

        con.Open();

        da.Fill(ds, "Resource");

        con.Close();

        con = null;

        da = null;

        return ds;

 

    }

Then , add this web method to insert a new resource name:

[WebMethod]

    public DataSet SetResourceNames(string strInputResourceName)

    {

        SqlConnection con = new SqlConnection("Data Source=(local);Integrated Security=SSPI;Initial Catalog=QueryDB");

        SqlCommand com = con.CreateCommand();

        com.Parameters.AddWithValue("@InputResourceName", strInputResourceName);

        com.CommandText = "INSERT INTO Resource (Resource.ResourceName) VALUES (@InputResourceName)";

        strInputResourceName = strInputResourceName.Replace("'", "''");

        SqlDataAdapter daa = new SqlDataAdapter();

        daa.SelectCommand = com;

        DataSet Ds = new DataSet();

        con.Open();

        daa.Fill(Ds, "Resource");

        con.Close();

        con = null;

        daa = null;

        return Ds;

 

    }

  Then , add this web method to delete a certain selected resource name:

[WebMethod]

    public DataSet DeleteResourceNames(string strDeleteResourceName)

    {

        SqlConnection con = new SqlConnection("Data Source=(local);Integrated Security=SSPI;Initial Catalog=QueryDB");

        SqlCommand com = con.CreateCommand();

        com.Parameters.AddWithValue("@DeleteResourceName", strDeleteResourceName);

        com.CommandText = "DELETE FROM Resource WHERE Resource.ResourceName = @DeleteResourceName";

        strDeleteResourceName = strDeleteResourceName.Replace("'", "''");

        SqlDataAdapter daa = new SqlDataAdapter();

        daa.SelectCommand = com;

        DataSet Ds = new DataSet();

        con.Open();

        daa.Fill(Ds, "Resource");

        con.Close();

        con = null;

        daa = null;

        return Ds;

 

    }

 

Then , add this web method to update a selected resource name :

[WebMethod]

    public DataSet UpdateResourceNames(string strOldResourceName, string strNewResourceName)

    {

        SqlConnection con = new SqlConnection("Data Source=(local);Integrated Security=SSPI;Initial Catalog=QueryDB");

        SqlCommand com = con.CreateCommand();

        SqlDataAdapter daa = new SqlDataAdapter("UpdateResourceName", con);

        daa.SelectCommand.CommandType = CommandType.StoredProcedure;

        daa.SelectCommand.Parameters.AddWithValue("@OldResourceName", strOldResourceName);

        daa.SelectCommand.Parameters.AddWithValue("@NewResourceName ", strNewResourceName);

        strOldResourceName = strOldResourceName.Replace("'", "''");

        strNewResourceName = strNewResourceName.Replace("'", "''");

        DataSet ds = new DataSet();

        con.Open();

        daa.Fill(ds);

        con.Close();

        con = null;

        daa = null;

        return ds;

 

    }

 

Which shown in this figure:

Click to enlarge 

Click to enlarge 

Then, run this service as shown in this figure :

Click to enlarge 

Then click on the GetDomainNames link , then invoke the webmethod as shown in the figure:

Click to enlarge

Then after invoking the webmethod , it should return All of the resource names as shown in the figure:

Click to enlarge 

 C) Creating the Compatible InfoPath form & Publishing:

  • Open Microsoft Office InfoPath 2007 then design a new blank form template which explained before in the previous articles ,then add a table with title layout and add a list box control , txt box control and three buttons controls ( Add , Update & Delete ) , as shown in the figure:

Click to enlarge 

Then from Tools menu > Data Connections, as shown in the figure:

Click to enlarge 

 

Then select receive data in order to receive data via the web service as shown in the figure:

Click to enlarge 

Then select the resource of your data as a web service as shown in the figure:

Click to enlarge 

Then write the URL of the location of the web service you want to use as your data connection as shown in the figure:

Click to enlarge 

Then you’ll find the web methods which wrote in the web service which called “GetResourceName”, “SetResourceNames”, and “DeleteResourceName” & ‘UpdateResourceNames” as shown in the figure:

Click to enlarge 

Then store a copy of the data in the form template as shown in the figure:

Click to enlarge 

Then check on the automatically retrieve data when form is opened as shown in the figure:

Click to enlarge 

Then you’ll get the data connection source for the form template as shown in the figure:

Click to enlarge

Then repeat these steps again but this time for “SetResourceNames” web method as shown in this figures: (But this time for submit data not receive)

Click to enlarge 

Then Click on Next, as shown in the figure:

Click to enlarge 

Then, Click on Finish button, as shown in the figure:

Click to enlarge 

Then, Click on Close button, as shown in the figure:

Click to enlarge 

Then repeat these steps again but this time for “DeleteResourceNames” web method as shown in this figures: (But this time for submit data not receive)

Click to enlarge 

Then, click on Next button, as shown in the figure:

Click to enlarge 

Then, Click on Finish button, as shown on the figure:

Click to enlarge 

Then, Click on Close button, as shown in the figure:

Click to enlarge 

Then repeat these steps again but this time for “UpdateResourceNames” web method as shown in this figures: (But this time for submit data not receive)

Click to enlarge

Then, Click on Next button, as shown in the figure:

Click to enlarge 

Then, Click on Finish button, as shown in the figure:

Click to enlarge 

Then, Click on Close button, as shown in the figure:

Click to enlarge 

Then right click on the list box and click on drop down list box properties as shown in the figure:

Click to enlarge 

Then at the list box entries select look-up values from an external data source as shown in the figure:

Click to enlarge 

Then click on the entries button as shown in the figure:

Click to enlarge 

Then expand the data fields till reach to the ResourceName data filed as shown in the figure:

Click to enlarge 

Then you’ll find the X-path to the ResourceName data field in the entries textbox as shown in the figure:

Click to enlarge 

Then right click on the text box and click on text box properties as shown in the figure:

Click to enlarge 

Then at Default value set the value to the value of the selected list box item as shown in the figure:

Click to enlarge 

Then right click on the Add button to show its properties as shown in the figure:

Click to enlarge 

Then add these rules as shown in the figure:

Click to enlarge 

Also repeat these steps for the Edit button as shown in the figure but with another rules:

Click to enlarge 

Also repeat these steps for the Delete button as shown in these figures but also with another rules:

Click to enlarge

Then, click on Ok button, as shown in the figure:

Click to enlarge 

Then from the preview tab click on form item to run the form as shown in the figure:

Click to enlarge 

Here’s the result after running the form:

Click to enlarge 

Then, you can add data using Add button, as shown in the figure:

Click to enlarge 

Here’s the added data, as shown in the figure:

Click to enlarge 

Then, you can delete data using Delete button, as shown in the figure:

Click to enlarge 

Then, you can also edit your data using Edit button, as shown in the figure:

Click to enlarge 

Here’s the result of the edited data, as shown in the figure:

Click to enlarge
 

Then close the preview as shown in the figure:

Click to enlarge 

Then from Tools menu > Form options >: At the security and trust category > security level > set full trust (the form has access to files and settings on the computer, then at the form template signature > check on the sign this form template, as shown in the figure :

Click to enlarge 

Then, click on File menu > Publish, as shown in the figure:

Click to enlarge 

Then select to a network location, as shown in the figure:

Click to enlarge 

Then write the path and the file name for the published form template, as shown in the figure:

Click to enlarge 

Then remove the path from this textbox, as shown in the figure:

Click to enlarge 

Then click on Publish button, as shown in the figure:

Click to enlarge 

Then click on close button, as shown in the figure:

Click to enlarge 

Then open the central administration which explained before in the previous articles and click on the Application Management tab > InfoPath forms services > Manage form templates, as shown in the figure:

Click to enlarge 

Then click on upload form templates, as shown in the figure:

Click to enlarge 

Then click on the browse button to upload the published form template, as shown in the figure:

Click to enlarge 

Then click on upload button as shown in the figure:

Click to enlarge 

Then click on Ok button, as shown in the figure:

Click to enlarge 

Then right click on the new published form template > Activate to a site collection, as shown in the figure:

Click to enlarge 

Then at the activation location section, right click on the site collection drop-down list and select change site collection, as shown in the figure:

Click to enlarge 

Then right click on the web application drop-down list and select change web application, as shown in the figure:

Click to enlarge 

Then click on the sharepoint-80 link, as shown in the figure:

Click to enlarge 

Then from the URL section select your site link, as shown in the figure:

Click to enlarge 

Then click ok button, as shown in the figure:

Click to enlarge 

D) Creating the Sharepoint Site Document-Library:

  • Use the same steps that were explained before in the previous articles in order to create a sharepoint site and a document library so , here I created another document library called “QueryDocLib” in order to publish the published form template to it as a content type , as shown in the figure :

Click to enlarge 

Then click on Settings tab > Document library settings, as shown in the figure:

Click to enlarge 

Then, at the content types section click on add from existing site content type’s link, as shown in the figure:

Click to enlarge 

Then from the available site content types, select the published content type “Newtemp4” and add it, as shown in the figure:

Click to enlarge 

Then go back to the QueryDocLib page and click on New tab , then click on the Newtemp4 item , as shown in the figure:

Click to enlarge 

Then, the result will be like this:

Click to enlarge 

Then you can save the document as shown in the figure:

Click to enlarge 

Then you can go back to the QueryDocLib page and see the saved document as shown in the figure:

Click to enlarge 

 

 

 

 Copyright © 2006 Innovation-Hut. All Rights Reserved. |  Terms of Use  |    Privacy Statement   |   FAQ <Hesham Saad Aly>
var sc_project=2000388; var sc_invisible=1; var sc_partition=18; var sc_security="1901aa3d";
Share this post: | | | |
Integration between MOSS 2007 & MS Popfly via compatible info path forms and RSS feeds

Introduction
Inserting a compatible Info Path form as a document into a sharepoint document library which enables RSS feeds then integrates with MS-Popfly.

Steps
A) Creating a sharepoint document library:

  • Open a sharepoint site and create a new document library called “PopFlyDocLib” as shown in these figures:

 

Click to enlarge 

 

Click to enlarge 

B) Creating a compatible info path form:

  • We’ll create a compatible info path form that connects to the sharepoint document library that we created before and check it’s RSS feeds : Open Ms Info path 2007 > Design a form template … > Blank (Enable browser –compatiable features only) , as shown in the figure:

Click to enlarge 

Then from Design Tasks pane , insert TableWithTitle page layout and insert inside it a rich text box control and a button , as shown in the figure: 

Click to enlarge 

Then right click on the button > click on Button properties >then press on Rules button , as shown in the figure:

Click to enlarge 

Then click on Add button in order to add a rule then press on Add Action button then select Submit using a data connection from the Action drop down list then click Add button , as shown in the figure:

Click to enlarge

Then select submit data from the create a new connection to , as shown in the figure:

Click to enlarge 

 Then select To a document library on a sharepoint site , as shown in the figure:

Click to enlarge 

Then at the document library write the URL for the new created document library then press the next button as shown in the figure:

Click to enlarge 

 

Then enter a name for this data connection as “PopDoc” as shown in the figure:

Click to enlarge 

Then from the preview tab > select Form , or press ctrl+shift + B , directly , as shown in the figure:

Click to enlarge 

Then ,fill the rich text box control with data then press the submit button then conenct to the sharepoint site , as shown in these figures:

Click to enlarge 

Click to enlarge 

Then close the preview , as shown in the figure:

Click to enlarge 

Then switch back to the created “PopFlyDocLib” document library , and press on the Refresh button , as shown in the figure:

Click to enlarge 

Then you’ll notice the compatiable info path form that we made was inserted as a new document in the document library as shown in the figure:

Click to enlarge

Then click on the Actions tab > View RSS Feed , in order to check that the RSS feed for this document library works well, as shown in the figure:

Click to enlarge 

Then the RSS Feed for this document library will be shown like this figure:

Click to enlarge 

C) Integration between sharepoint site document library RSS Feed and MS-Popfly:

  • First, open your browser and then write this link (http://www.popfly.ms) in the URL , as shown in the figure:

Click to enlarge 

Then click on create a mash up as shown in the figure:

Click to enlarge 

Then, start building the mash up by clicking or dragging a block on the left blocks box as shown in the figure:

Click to enlarge 

Then from News & RSS blocks > add RSS block as shown in the figure:

Click to enlarge 

Then also add News Reader, as shown in the figure:

Click to enlarge 

Then click on the winch icon to adjust the properties for the RSS block and then enter the URL for the RSS Feed, as shown in the figure:

Click to enlarge 

Then link (combine) between the two blocks, as shown in the figure:

Click to enlarge

Then click on the preview, and here’s the result of the feed:

Click to enlarge 

Also you can explore the RSS feed itself by clicking on the Read More > Link.

Then you can save the project from save as link, as shown in the figure:

Click to enlarge 

Then from My Stuff (Menu) > Projects, as shown in the figure:

Click to enlarge 

Then press on Share link at your project > MashOut > Embed it, as shown in the figure:

Click to enlarge 

Then copy the HTML code as shown in the figure:

Click to enlarge 

Then now, you can paste this code in a content page web part in the sharepoint site to display it.

Share this post: | | | |
Cascading compatible Info Path form controls
Introduction
Cascading info path list controls as drop down list and list box controls programmatically at which the value displayed of the second control depends according to the selected value in the first control.

Steps
A) Creating the Database:
  • Open SQL Server Enterprise Manager through : (Start > All Programs > Microsoft SQL Server > Enterprise Manager), then in Console Root folder expand the Microsoft SQL Servers then expand the SQL Server Group then expand your instance then at the Databases folder right click on it and create a new database called “CascadDB” then expand the CascadDB database and right click on Tables to create a new table called “Domain” this table holds two columns: (DomainID – DomainName) and another table called “Vendor” this table holds three columns : (VendorID – DomainID - VendorName) as shown in this figure:

Click to enlarge 

B) Creating the Web Service:

  • Open MS- visual studio .net 2005 then click File menu > New > Web Site > ASP.Net Web Service : Then in the App_Code folder open Service.cs file then add these namespaces: Using System. Data; Using System.Data.SqlClient; Then, add this web method to get all of the domain names from Domain table in the CascadDB database:

[WebMethod]

   

    public DataSet GetDomainNames()

    {

        SqlConnection con = new SqlConnection("Data Source=(local);Integrated Security=SSPI;Initial Catalog=CascadDB");

        SqlDataAdapter da = new SqlDataAdapter("SELECT Domain.DomainName FROM Domain", con);

        DataSet ds = new DataSet();

        con.Open();

        da.Fill(ds, "Domain");

        con.Close();

        con = null;

        da = null;

        return ds

            }

  Then , add this web method to get all vendor names according to the selected domain names :

 

[WebMethod]

    public DataSet GetVendorsForSelectedDomains(string strInputDomainName)

    {

        SqlConnection con = new SqlConnection("Data Source=(local);Integrated Security=SSPI;Initial Catalog=CascadDB");

        SqlCommand com = con.CreateCommand();

        com.Parameters.AddWithValue("@InputDomainName", strInputDomainName);

        com.CommandText = "SELECT Vendor.VendorName FROM Vendor INNER JOIN [Domain] ON Vendor.DomainID = [Domain].DomainID Where [Domain].DomainName = @InputDomainName";

        strInputDomainName = strInputDomainName.Replace("'", "''");

        SqlDataAdapter daa = new SqlDataAdapter();

        daa.SelectCommand = com;

        DataSet Ds = new DataSet();

        con.Open();

        daa.Fill(Ds, "Vendor");

        con.Close();

        con = null;

        daa = null;

        return Ds;

 

      }

Which shown in this figure:

Click to enlarge 

Then, run this service as shown in this figure :

Click to enlarge 

Then click on the GetDomainNames link , then invoke the webmethod as shown in the figure:

Click to enlarge

Then after invoking the webmethod , it should return All of the domain names as shown in the figure:

Click to enlarge 

Then click on the GetVendorsForSelectedDomains link , then invoke the webmethod as shown in the figure:

Click to enlarge 

 

Then after invoking the webmethod , it should return All of the vendor names according to the selectd domain names as shown in the figure:

Click to enlarge 

 

C) Creating the Compatible InfoPath form & Publishing:

  • Open Microsoft Office InfoPath 2007 then design a new blank form template which explained before in the previous articles ,then add a table with title layout and add two drop down list controls to it in which the first control populated with the domain names and the other one’s populated with values according to the selection of the first control from the CascadDB database via the created web service , as shown in the figure:

Click to enlarge 

Then from Tools menu > Data Connections, as shown in the figure:

Click to enlarge 

 

Then select receive data in order to receive data via the web service as shown in the figure:

Click to enlarge 

Then select the resource of your data as a web service as shown in the figure:

Click to enlarge 

Then write the URL of the location of the web service you want to use as your data connection as shown in the figure:

Click to enlarge 

Then you’ll find the web methods which wrote in the web service which called “GetDomainNames” & “GetVendorsForSelectedDomains” as shown in the figure:

Click to enlarge 

Then store a copy of the data in the form template as shown in the figure:

Click to enlarge 

Then check on the automatically retrieve data when form is opened as shown in the figure:

Click to enlarge 

Then you’ll get the data connection source for the form template as shown in the figure:

Click to enlarge

Then repeat these steps again but this time for “GetVendorsForSelectedDomains” web method as shown in this figures:

Click to enlarge 

Then Click on Next, as shown in the figure:

Click to enlarge 

Then check on save a copy of the data in the form template, as shown in the figure:

Click to enlarge 

Then, Click on Finish, as shown in the figure:

Click to enlarge 

Then, Click on close button, as shown in the figure:

Click to enlarge 

Then right click on the domain drop down list and click on drop down list box properties as shown in the figure:

Click to enlarge 

Then at the list box entries select look-up values from an external data source as shown in the figure:

Click to enlarge 

Then click on the entries button as shown in the figure:

Click to enlarge 

Then expand the data fields till reach to the DomainName data filed as shown in the figure:

Click to enlarge

Then you’ll find the X-path to the DomainName data field in the entries textbox as shown in the figure:

Click to enlarge 

Then check on the validations and rules and press on the Rules button, as shown in the figure:

Click to enlarge 

Then press Add button as shown in the figure:

Click to enlarge 

Then press on Add Action button as shown in the figure:

Click to enlarge 

Then add these rules and press ok button as shown in the figure:

Click to enlarge 

Then right click on the vendor drop down list and click on drop down list box properties as shown in the figure:

Click to enlarge 

Then at the list box entries select look-up values from an external data source as shown in the figure:

Click to enlarge 

Then click on the entries button as shown in the figure:

Click to enlarge 

Then expand the data fields till reach to the VendorName data filed as shown in the figure:

Click to enlarge 

Then you’ll find the X-path to the VendorName data field in the entries textbox as shown in the figure:

Click to enlarge 

Then check on the validations and rules and press on the Rules button, as shown in the figure:

Click to enlarge 

Then press Add button as shown in the figure:

Click to enlarge 

Then add this rule & condition and press ok button as shown in these figures:

Click to enlarge 

Then, Add Action and click on OK button, as shown in the figure:

Click to enlarge

Then from the preview tab click on form item to run the form as shown in the figure:

Click to enlarge 

Here’s the result after running the form: (selecting Domain1 and getting the corresponding vendors), as shown in the figure:

Click to enlarge 

Then close the preview as shown in the figure:

Click to enlarge 

Then from Tools menu > Form options >: At the security and trust category > security level > set full trust (the form has access to files and settings on the computer, then at the form template signature > check on the sign this form template, as shown in the figure :

Click to enlarge 

Then, click on File menu > Publish, as shown in the figure:

Click to enlarge 

Then select to a network location, as shown in the figure:

Click to enlarge 

Then write the path and the file name for the published form template, as shown in the figure:

Click to enlarge 

Then remove the path from this textbox, as shown in the figure:

Click to enlarge
 

Then click on Publish button, as shown in the figure: 

Click to enlarge 

Then click on close button, as shown in the figure:

Click to enlarge 

Then open the central administration which explained before in the previous articles and click on the Application Management tab > InfoPath forms services > Manage form templates, as shown in the figure:

Click to enlarge 

Then click on upload form templates, as shown in the figure:

Click to enlarge 

Then click on the browse button to upload the published form template, as shown in the figure:

Click to enlarge 

Then click on upload button as shown in the figure:

Click to enlarge 

Then click on Ok button, as shown in the figure:

Click to enlarge 

Then right click on the new published form template > Activate to a site collection, as shown in the figure:

Click to enlarge 

Then at the activation location section, right click on the site collection drop-down list and select change site collection, as shown in the figure:

Click to enlarge 

Then right click on the web application drop-down list and select change web application, as shown in the figure:

Click to enlarge 

Then click on the sharepoint-80 link, as shown in the figure:

Click to enlarge 

Then from the URL section select your site link, as shown in the figure:

Click to enlarge 

Then click ok button, as shown in the figure:

Click to enlarge 

D) Creating the Sharepoint Site Document-Library:

  • Use the same steps that were explained before in the previous article in order to create a sharepoint site and a document library so , here I created another document library called “CascadDocLib” in order to publish the published form template to it as a content type , as shown in the figure :

Click to enlarge 

Then click on Settings tab > Document library settings, as shown in the figure:

Click to enlarge 

Then, at the content types section click on add from existing site content type’s link, as shown in the figure:

Click to enlarge 

Then from the available site content types, select the published content type “Newtemp3” and add it, as shown in the figure:

Click to enlarge 

Then go back to the CascadDocLib page and click on New tab , then click on the Newtemp3 item , as shown in the figure:

Click to enlarge 

Then, the result will be like this:

Click to enlarge 

Then you can save the document as shown in the figure:

Click to enlarge 

Then you can go back to the CascadDocLib page and see the saved document as shown in the figure:

Click to enlarge 

 

 

 

 Copyright © 2006 Innovation-Hut. All Rights Reserved. |  Terms of Use  |    Privacy Statement   |   FAQ <Hesham Saad Aly>
var sc_project=2000388; var sc_invisible=1; var sc_partition=18; var sc_security="1901aa3d";
Share this post: | | | |
Creating Custom web page in MOSS 2007 via XmlFormView ASP.Net Control
Introduction
Creating a custom web page in MOSS 2007 to render browser –enabled, interactive info path forms via XmlFormView ASP.Net Control.

Steps
A) Creating the new web page & Adding the XmlFormView control:
  • Click , Start > Administrative Tools > Internet Information Services (IIS) Manager, Then expand the Server Name (local computer) in order to have the list of IIS services that are available on the server. Then expand the Web Sites to show the list of web sites that are managed by IIS then right click sharepoint – 80 and then click properties then on the ASP.Net tab of the sharepoint-80 properties dialog box, highlight and copy the text in the File location box without copying the web.config that appears at the end of the File Location string as shown in these figures:

 

Click to enlarge
 

 

Click to enlarge 

Then start Visual Studio.Net 2005 , File > Open > Web Site > File System , then in the folder box paste the file location path that you copied then click open , as shown in the figure:

Click to enlarge 

Then right click on the path of the web site in solution explorer and select New folder and name it “XmlFormView” then right click on the new folder and select Add new item > Web form and name it “MyCustomPage” and select place code in separate file then click add as shown in the figure: 

Click to enlarge 

Then add the XmlFormView control to the “MyCustomPage.aspx” web page , then in the Document Properties for “MyCustomPage.aspx” page click True for the EnableSessionState property as shown in the figure:

Click to enlarge 

Then at the source view , remove the default Doctype declaration tag which begins with <! DOCTYPE html PUBLIC , and modify the Body tag to contain the folowwing style atrributes : 

style="margin: 0px;overflow:auto;padding:20px"

 

 then modify the Form tag to contain the following enctype attribute :

 

enctype="multipart/form-data"
Click to enlarge

 

Then in the Design view, add XmlFormView control from the Toolbox then from its properties in the Data Binding section Paste the URL to browser – enabled form template in XsnLocation Property of the control But first let’s design a form template To be used: Open MS Office InfoPath 2007 > Design a Form Template > Form Template > Blank > Enable browser – compatible features only, as Shown in the figure:

Click to enlarge 

Then in the task pane > Controls > Add Date picker > Date Picker Properties > click the function button to the right of the value Box > then in the Insert formula box > Insert Function > Click Today function > Ok, as shown in the figure:

Click to enlarge 

Then add an optional section to the form >(Section properties) then On Data tab > Click Include the section in the form by default > in Display tab > click conditional formatting > in Conditional format Box > Add > confirm that the first drop down box contains field1 Which bound to the date picker control otherwise change it to field1 > In third box under If this condition is true > click drop down List > select use a formula > Insert formula box > click Insert Function > Click today function > Ok > in Conditional format box > Shading drop down list and select a color > Ok, as shown in these Figures:

Click to enlarge 

 

Click to enlarge 

Then repeat the previous steps again but select a different color To use when the field1 is later than today date and for when field1 Is earlier than today date, as shown in the figure:

Click to enlarge 

Then, File > Publish > to a sharepoint server with or without InfoPath forms services > Next, as shown in these figures:

Click to enlarge 

Click to enlarge 

Then, select enable this form to be filled out by using a browser > Select Document library > Next, as shown in the figure:

Click to enlarge 

Then, click creates a new document library > Next, as shown in the figure:

Click to enlarge 

Then, type a name for the new document library > Next, as shown in the figure:

Click to enlarge

Then click, Next > Publish, as shown in the figure:

Click to enlarge 

Then, click Open this form in the browser in the publishing wizard box, as shown in the figure:

Click to enlarge 

Then in the address bar in IE copy the XsnLocation portion of the URL starting after the equal sign (=) with “http” and ending with “.xsn” then close the browser , as shown in the figure:

Click to enlarge 

Then close the wizard as shown in the figure:

Click to enlarge 

Then, go back to the XmlFormView control > XsnLocation property > Paste the URL you got, as shown in the figure:

Click to enlarge 

Then, on the website menu > Start Options > Start actions section: click start URL to your custom page such as: http://ServerName/XmlFormView/MyCustomPage.aspx, as shown in these figures:

Click to enlarge 

Click to enlarge 

Then click Ok, then on File menu > click save all and give a solution a name and location. Then click, Start > All programs > Microsoft visual studio 2005 > visual studio Tools > open visual studio 2005 command prompt window, as shown in the figure:

Click to enlarge 

Then type iisreset> Enter, then close the prompt window, as shown in the figure:

Click to enlarge

Then debug the web page: Save the custom web page > press F5 to start debugging , if you receive a message that states the web.config file not being configured for debugging , click ok which automatically adds the debug flag to the web.config file , as shown in the figure:

Click to enlarge 

B) Passing a value from the template form to the web page :

    • Add these namespaces:

      Using System.Xml;

      Using System.Xml.XPath;

      Then add a Textbox control: as shown in the figure:

Click to enlarge 

Then in the Button click event, write this code:

protected void Button1_Click(object sender, EventArgs e)

    {

        XmlFormView1.DataBind();

        XPathNavigator xNavMain =

           XmlFormView1.XmlForm.MainDataSource.CreateNavigator();

        XmlNamespaceManager xNameSpace =

           new XmlNamespaceManager(new NameTable());

        xNameSpace.AddNamespace("my", XmlFormView1.XmlForm.NamespaceManager.

           LookupNamespace("my").ToString());

        TextBox1.Text = xNavMain.SelectSingleNode(

           "/my:myFields/my:field2", xNameSpace).ToString();

    }

as shown in the figure:

Click to enlarge 

C) Passing a value from the web page to the template form:

  • Add another Textbox control to both the web page and the info path browser – enabled form template rendered in the XmlFormView control , Then switch to the source view of your web page and locate the tag for the XmlFormView1 control as:
<cc1:XmlFormView ID="XmlFormView1" runat="server" Height="250px"
    Width="100%"
XsnLocation="http://ServerName/DocumentLibrary/Forms/template.xsn">

 

  Then declare the name of the Initialize event handler in the XmlFormView1 control tag, as:
<cc1:XmlFormView ID="XmlFormView1" runat="server" Height="250px"
    Width="100%"
XsnLocation="http://ServerName/DocumentLibrary/Forms/template.xsn"
OnInitialize="XmlFormView1_Initialize" />
 

Then in the Initialize event handler, write:

protected 
    void XmlFormView1_Initialize(object sender, 
   InitializeEventArgs
    e)
{
    XPathNavigator
    xNavMain = XmlFormView1.XmlForm.MainDataSource.CreateNavigator();
    XmlNamespaceManager
    xNameSpace = new XmlNamespaceManager(new
    NameTable());
    xNameSpace.AddNamespace("my", "http://schemas.microsoft.com 
/office/infopath/2003/myXSD/2006-04-20T16:26:21"
);
    XPathNavigator
    fTextBox1 = xNavMain.SelectSingleNode(
       
"my:myFields/my:field2", xNameSpace);
       
fTextBox1.SetValue(TextBox1.Text);
}

As shown in the figure:

Click to enlarge 

D) Submitting Data from the form :

  • Create a SubmitToHostAdapter data connection in the form template that is hosted in a custom web page : Open InfoPath form template in design mode > Tools menu >Data Connections > Add > Create a new connection > Submit Data > Next > Select To the hosting environment, such as an ASP.Net page or a hosting application > Next, as shown in the figure:

Click to enlarge 

Then type a name for the new data connection > Finish. Then enable the form to submit its XML data to the hosting environment: Tools menu > Submit Options > Allow Users to submit this form > then in the first drop down list > select Hosting environment > and in the second list > select the name you gave to the data connection, as shown in the figure:

Click to enlarge 

Then click Ok, and Republish the form template to the same document library on the sharepoint server or create a new document library, Then go back to the VS solution, and write this code in the Submit ToHost event handler of the XmlFormView1 control:

protected 
    void XmlFormView1_SubmitToHost(object sender, 
   SubmitToHostEventArgs
    e)
{
   // Create an XPathNavigator positioned at the root of 
   // the form's main data source.
   XPathNavigator
    xNavMain = 
      
    XmlFormView1.XmlForm.MainDataSource.CreateNavigator();
   // Create an XmlNamespaceManager and add the 
        "my" namespace
   // alias from the form's main data source.
   XmlNamespaceManager
    xNameSpace = 
      
    new XmlNamespaceManager(new
    NameTable());
   xNameSpace.AddNamespace("my", "http://schemas.microsoft.com/ 
office/infopath/2003/myXSD/2006-04-20T16:26:21"
);
   // Create an XPathNavigator positioned on the form's field2.
   XPathNavigator
    fTextBox1 = xNavMain.SelectSingleNode(
      
    "my:myFields/my:field2", xNameSpace);
   // Set TextBox1 on the page to the value in the form's field2.
   TextBox1.Text
    = xNavMain.SelectSingleNode(
      
    "/my:myFields/my:field2", xNameSpace).ToString();
}

As shown in the figure:

Click to enlarge 

 

 

 

 

 Copyright © 2006 Innovation-Hut. All Rights Reserved. |  Terms of Use  |    Privacy Statement   |   FAQ    <Hesham Saad Aly>
var sc_project=2000388; var sc_invisible=1; var sc_partition=18; var sc_security="1901aa3d";
Share this post: | | | |
MOSS 2007 & MS Office InfoPath 2007 | Part 02

Article Target 
Using SQL Server DB to retrieve data from it using a web service and export this data to an InfoPath compatible form through an external data source then publish this form to a Sharepoint site using network publishing location.

Steps
A) Creating the Database:

  • Open SQL Server Enterprise Manager through : (Start > All Programs > Microsoft SQL Server > Enterprise Manager), then in Console Root folder expand the Microsoft SQL Servers then expand the SQL Server Group then expand your instance then at the Databases folder right click on it and create a new database called “TestDB” then expand the TestDB database and right click on Tables to create a new table called “Employee” this table holds three columns: (EmployeeID – EmployeeName - EmployeeAddress) as shown in this figure: Then , you’ll find three tabs: (Home , Operations , Application Management) , So , Click on the Application Management tab as shown in the figure:

 

B) Creating the Web service:

  • Open MS- visual studio .net 2005 then click File menu > New > Web Site > ASP.Net Web Service :
    Then in the App_Code folder open Service.cs file then add these namespaces:
    Using System. Data;
    Using System.Data.SqlClient;
    Then, add this web method to get all of the employees names from Employee table in the TestDB database:

 [WebMethod]

   

    public DataSet GetEmployeeNames()

    {

        SqlConnection con = new SqlConnection("Data Source=(local);Integrated Security=SSPI;Initial Catalog=TestDB");

        SqlDataAdapter da = new SqlDataAdapter("SELECT Employee.EmployeeName FROM Employee", con);

        DataSet ds = new DataSet();

        con.Open();

        da.Fill(ds, "Employee");

        con.Close();

        con = null;

        da = null;

        return ds;

         }


Which shown in this figure:

 

Then , run this service as shown in this figure :

 

Then click on the GetEmployeeNames link , then invoke the webmethod as shown in the figure:

 

Then after invoking the webmethod , it should return All of the employees names as shown in the figure:

 

C) Creating the Compatible InfoPath form & Publishing:

  • Open Microsoft Office InfoPath 2007 then design a new blank form template which explained before in the previous article ,then add a table with title layout and add a List Box control to it in order to hold the Employees names from the TestDB database via the created web service , as shown in the figure:

 

Then from Tools menu > Data Connections, as shown in the figure:

 

Then select receive data in order to receive data via the web service as shown in the figure:

 

Then select the resource of your data as a web service as shown in the figure:

 

Then write the URL of the location of the web service you want to use as your data connection as shown in the figure:

 

Then you’ll find the web method which wrote in the web service which called “GetEmployeeNames” as shown in the figure:

 

Then store a copy of the data in the form template as shown in the figure:

 

Then check on the automatically retrieve data when form is opened as shown in the figure:

 

Then you’ll get the data connection source for the form template as shown in the figure:

 

Then right click on the list box and click on list box properties as shown in the figure:

 

Then at the list box entries select look-up values from an external data source as shown in the figure:

 

Then click on the entries button as shown in the figure:

 

Then expand the data fields till reach to the EmployeeName data filed as shown in the figure:

 

Then you’ll find the X-path to the EmployeeName data field in the entries textbox as shown in the figure:

 

Then from the preview tab click on form item to run the form as shown in the figure:

 

Here’s the result after running the form:

 

Then close the preview as shown in the figure:

 

Then from Tools menu > Form options >:
At the security and trust category > security level > set full trust (the form has access to files and settings on the computer, then at the form template signature > check on the sign this form template, as shown in the figure :

Then, click on File menu > Publish, as shown in the figure:

 

Then select to a network location, as shown in the figure:

 

Then write the path and the file name for the published form template, as shown in the figure:

 

Then remove the path from this textbox, as shown in the figure:

 

Then click on Publish button, as shown in the figure:

 

Then click on close button, as shown in the figure:

 

Then open the central administration which explained before in the previous article and click on the Application Management tab > InfoPath forms services > Manage form templates, as shown in the figure:

 

Then click on upload form templates, as shown in the figure:

 

Then click on the browse button to upload the published form template, as shown in the figure:

 

Then click on upload button as shown in the figure:

 

Then click on Ok button, as shown in the figure:

 

Then right click on the new published form template > Activate to a site collection, as shown in the figure:

 

Then at the activation location section, right click on the site collection drop-down list and select change site collection, as shown in the figure:

 

Then right click on the web application drop-down list and select change web application, as shown in the figure:

 

Then click on the sharepoint-80 link, as shown in the figure:

 

Then from the URL section select your site link, as shown in the figure:

 

Then click ok button, as shown in the figure:

 

D) Creating the Sharepoint Site Document-Library:

  • Use the same steps that were explained before in the previous article in order to create a sharepoint site and a document library so , here I created another document library called “WSDocLib” in order to publish the published form template to it as a content type , as shown in the figure :

 

 

Then click on Settings tab > Document library settings, as shown in the figure:

 

Then, at the content types section click on add from existing site content type’s link, as shown in the figure:

 

Then from the available site content types, select the published content type “NewTemplate” and add it, as shown in the figure:

 

Then go back to the WSDocLib page and click on New tab , then click on the NewTemplate item , as shown in the figure:

 

Then, the result will be like this:

 

Then you can save the document as shown in the figure:

 

Then you can go back to the WSDocLib page and see the saved document as shown in the figure:

Share this post: | | | |
MOSS 2007 & MS Office InfoPath 2007 (part1)

Introduction
MS-Office Sharepoint Server 2007 is a new server program that is part of 2007 MS office system which your organization can use it to facilitate collaboration, provide content management features, implement business processes & supply access to information that is essential to organizational goals & processes. Here, in this article we’ll show how MS office InfoPath 2007 works with office sharepoint server 2007 in designing a browser- compatible form template, publish them to an office sharepoint server 2007 site and enable them for use in a web browser.

General Objective 
How to use InfoPath forms services capababilities in office sharepoint server.

Article Target 
Using MS office InfoPath 2007 to create forms and making them compatible to display on a web page & then publish this compatible form to a document library in a sharepoint portal site.

Steps
A) Creating a sharepoint portal site:

  • Open “sharepoint 3.0 central administration” from (Start > All Programs > Microsoft Office Server > Sharepoint 3.0 Central Administration) , as shown in the figure:

Click to enlarge 

  • Then , you’ll find three tabs: (Home , Operations , Application Management) , So , Click on the Application Management tab as shown in the figure:

Click to enlarge 

  • In “Sharepoint Site Management” section , click on “Create site collection” as shown in the figure:

Click to enlarge 

  • In :

        i) Web Application:

  • You can change your web application according to the port which will be used. (Here, I’ll create my sharepoint site on 80 – port). So, click on the web Application drop-down list and select “Change web Application” as shown in the figure:

Click to enlarge

  • Then, click on: sharepoint 80 link as shown in the figure:

Click to enlarge 

  • Then, you see that your web application changed as shown in the figure:

Click to enlarge 

 

        ii) Title and Description:

  • You can type a title and description for your site where, the title will be displayed on each page in the site, as shown in the figure:

Click to enlarge 

 

        iii) Web Site Address:

  • You can specify the URL Name & URL Path to create the site or choose to create a site at a specific path so , your site can be personal or public site according to your purpose (Here, I’ll choose to be a personal site) , as shown in the figure:

Click to enlarge 

        iv) Template Selection:

  • You can select a predefined template for your site or you can design your own template and add it to this list which we’ll discuss it later in other articles, So, here I’ll select a Team Site template which is specific for a site for teams to quickly organize, author & share information which provides a document library & lists for managing announcements, calendar items, tasks & discussions, as shown in the figure: (Collaboration tab > Team Site)

Click to enlarge 

 

        v) Primary site collection Administrator:

  • You can write an administrator user names to specify the administrators for this web site collection , So , Click on the browse icon which looks an open book shape then in the Find textbox write the user name and then click search , which shown in the figure:

Click to enlarge 

        vi) Secondary site collection Administrator:

  • It’s optional to specify the secondary administrator for this web site collection (Here, I don’t need for it so, I’ll leave it blank).

        vii) Quota template:

  • You can select a predefined quota template to limit resources used for this site collection (i.e.: in order to have a storage limit for this site), or we can design our own quota template which we’ll discuss it in another articles, (Here, I’ll leave it as it is “No Quota”), as shown in the figure:

Click to enlarge 

  • Then finally click ok button, and wait while your changes are processed, then you’ll find that your top-level site successfully created and the link for your new site will be given as shown in the figure:

Click to enlarge 

  • Then click on the link to open the new portal site, then your new site will be like this:

Click to enlarge

  • Now , we’ll create a new document library in order to publish our InfoPath form to it as a compatible web page , So , Click on Site Actions menu > Create , as shown in the figure:

Click to enlarge 

  • Then in the “Libraries “section, click on “Document Library” link, as shown in the figure:

Click to enlarge 

        Then,  

         i) Name and Description:

  • You can type a new name as you want it to appear in headings & links throughout the site .Also, you can type a descriptive text in the description area that will help site visitors to use this document library.

        ii) Navigation:

  • You can specify whether a link to this document library appears in the quick launch which found in the homepage or not.

        iii) Document version history:

  • You can specify whether a version is created each time you edit a file in this document library or not.

 

        iv) Document Templates:

  • You can select a document template to determine the default for all new files created in this document library. (Here, I’ll select: Microsoft office word 97-2003 document, template)

              All shown in this figure:

Click to enlarge

  • Then click create button ,then in your new document library which is called“DocLib1” here , you’ll find four tabs (New , Upload , Actions , Settings), So , when you click on New tab there is two sub-items in it which are : New Document (Empty Document) & New Folder(Empty Folder to hold Documents) which shown in this figure:

Click to enlarge 

Also , we want to publish the compatible InfoPath form as a web page to this document library So , there are some settings for this document library needed to be done. So that, click on Settings tab > Document Library settings > General settings > Click on, Advanced Settings. Then:

i) Content types:

  • Select , Yes, in order to allow the management of content types on this document library where, each content type will appear on the new button and can have a unique set of columns, workflows and other behaviors.

ii) Browser-enabled documents:

  • Select, Display as a webpage , in order to display documents that are enabled for opening in a browser.

Then you can leave others as they are, as shown in the figure:

Click to enlarge 

Then click Ok button.

B) Creating compatible InfoPath form:

  • Start > All Programs > Microsoft office > Microsoft office InfoPath 2007 , as shown in the figure :

Click to enlarge 

  • Click on , “Design a form template ”, as shown in the figure :

Click to enlarge 

  • Select , Form Template > Blank , as shown in the figure , and click OK:

Click to enlarge 

  • Design Tasks> Tasks > Click on Layout > Table with Title , then add some controls via (Tasks>Controls) , as shown in the figure :

Click to enlarge 

  • Then to make sure that this form is compatible to web page , Tools menu > Forms options > Compatibility > Check Design a form template that can be opened in a browser or infopath, as shown in the figures:

Click to enlarge 

  • Then at the Category section > Select Compatibility, as shown in the figure:

Click to enlarge 

  • Then , it’s time now to publish this compatible InfoPath form to the document library of our sharepoint portal site : File menu > Publish > Save (template1.xsn) > To a Sharepoint server with or without infopath forms services > Next > (Enter Location of your sharepoint site link) > Next > Enable this form to be displayed out by using a browser, Site content type (Advanced), which allows this form template to be used in multiple libraries and sites > Next > Create a new content type > Next > Type name and description for this content type > Browser button, to select the created document library which called “DocLib1” , then write file name: with extension ‘.xsn’ > Next > Next (Leave it as it is) > publish, as shown in these figures:

Click to enlarge

  • Then choose a location at your file system in order to save the template, as shown in the figure:

Click to enlarge 

  • Then select, to a sharepoint server with or without InfoPath forms services, as shown in the figure:

Click to enlarge 

  • Then enter the location of your sharepoint site, as shown in the figure:

Click to enlarge 

  • Then, Enable the form to be filled out by using a browser and select site content type (advanced), as shown in the figure:

Click to enlarge 

  • Then create a new content type, as shown in the figure:

Click to enlarge 

  • Then, Type a name and description for the content type, as shown in the figure:

Click to enlarge 

  • Then, select the document library location that created before, as shown in the figure:

Click to enlarge 

  • Then, write a name for the content type, as shown in the figure:

Click to enlarge 

  • Then, click on publish button, as shown in the figure:

Click to enlarge 

  • Then, Click on close button, as shown in the figure:

Click to enlarge 

  • Then, go back to the created sharepoint site and click refresh button at the DocLib1 page and you’ll find the published form there as shown in the figure:

Click to enlarge 

  • Then, we want to add our created content type in order to appear a as a sub-item in New tab items, So that: Settings tab > Document Library settings > Content types > Add from existing site content types > Select (CT1) content type > Add > ok, as shown in the figure:

Click to enlarge 

  • Then, Select the content type that we named before and Click on Add, as shown in the figure:

Click to enlarge 

  • Then we want remove also other sub-items (Document – New Folder), so that to achieve this: Click on Settings tab > Select (Document Library Settings), as shown in the figure:

Click to enlarge

  • Then , in “Content Types” section , click on “Change new button order” and default content type , then uncheck visible check box , as shown in this figure , then click ok:

Click to enlarge 

  • Now, when click, new tab its items will be as shown in the figure:

Click to enlarge 

  • Also, to remove New Folder sub- item, so that, Settings > Document library settings > General settings > Advanced settings > Folders> No > Ok, as shown in the figure:

Click to enlarge 

  • Then, go back to the DocLib1 page then, click New > click CT1, as shown in the figure:

Click to enlarge 

  • And then , you’ll find your InfoPath compatible form in a web page where you can save , save as , close ,and print view the current page , as shown in these figures:

Click to enlarge 

  • Then, save your file and write a name for it, as shown in the figure:

Click to enlarge 

  • Finally, you’ll get your published compatible info path form in the document library, as shown in the figure:

Click to enlarge

Share this post: | | | |
Creating New Page Issue and workaround in MOSS 2007

Creating New Page Issue and workaround in MOSS 2007

- Problem :
You have a Top-Level-Site say "TestSite" which encapsulated a Sub-Site called "TestSubSite" and a Group "TestGroup" which have a user  "TestUser" who has a read access permission at the whole Top-Level -Site . Then , we break the permission at the "TestSubSite" by giving the "TestUser" a contribute access permission . So , when we logged with "TestUser" and navigate to the "TestSubSite" we'll see the Site Actions menu appears and when expanding the menu and click on the Create page item we'll redirect to the Access Denied page (Here is the Problem) although that the user "TestUser" has a contribute access permission on the "TestSubSite". Even also if the "TestUser" has a Full control access permission.
 
-N.B:
There is no problem at all if the "TestUser" was added as a site collection administrators. (But here the problem is when the user is just a registered user or any user except the site's admin ones).
 
- Workaround:
Any user creating  a new page needs to have a "Restricted Read Access" to the style library (Sometimes) & Master Page Gallery (Always) which is already automatically done for the site collection administrators so to do this we have to give a restricted read access to be granted to the Master page gallery  as follows:
 
( Site Actions > Manage Content Structure > Master Page gallery {Right Click} > Edit Properties > Permissions for this Document Library > Add User/Group {Add 'TestGroup'} , {Grant 'Restricted Read' permission} ) .
Share this post: | | | |
MOSS 2007 , MS Infopath 2007 , Groove 2007 , MS CS 2007 (Support & TroubleShoots & Work arrounds)

Today  , i'll start my rock for any subject concern my title .

=> I'll post my special articles.

=> I'll reply any question.

=> i'll be for your satisfaction.

Share this post: | | | |