Category Archives: July 2007

MUSCUS: Iterando per consuetudinem gestorum percolantur et reversus notitia InfoPath

Negotium Missionem:

Provideat ratio, quod permittit users intrare accurate emptio citius require.

Negotium problema:

Client commercium plures centum concionatorum.

Vendors are "type" specificas. Hoc intelligitur quod velit computatrum vendit venditor (e.g. Dell) vel officium commeatus (e.g. Stapellis).

How do we enable end users who create purchase requisitions select a valid vendor?

Negotium Solutio:

Differentiate vendors in the system via "type".

Enable users to select the "type" of product and then provide a filtered set of appropriate vendors.

Solutio technica:

An InfoPath form has been designed that enables users to enter online purchase requisitions.

Two InfoPath selection lists control vendor selection. Primum, the user selects a "purchase type". This limits a second selection list to contain only vendors that sell for that purchase type. This is a classic cascading drop-down.

Vendors are stored in a MOSS custom list with custom columns for vendor attributes such as name, address and especially "type".

Implement a web service for an InfoPath client to consume that iterates through the custom vendor list, returning only vendors matching a supplied "type".

Invoke the web service via the InfoPath form.

Lectiones didicit:

  • Primum, it seems necessary to go this route. I would have preferred to do the filtering entirely within InfoPath and not create any web service functionality here. Autem, forms server does not provide the required filtering capability. We can put a rule onto a the "type" selection list in the form to sort of re-open the vendor query, but we can’t get it to work properly. Therefore, it was necessary to implement the web service.
  • This is a classic "cascading selection list" problem in the InfoPath forms server world and there are many good examples out there that explain how to solve this.
  • A blank value for a column in the vendor list does not return an empty string when referenced like this: initItem["Vendor Name"]. Pro, it returns a null.

Some other Notes:

  • I return an array[] of vendors because I had some difficulty returning an ArrayList. InfoPath was complaining about it and I didn’t have the time or the inclination to fight over it. Hoc, utique, puts an artificial limit on the total number of vendors. It also compelled me to implement a trim() method on the array because I hate the idea of returning back 100’s of null vendors. InfoPath doesn’t care, but it nagged at me. (Iterum, this was easier than fighting InfoPath over ArrayLists).
  • I implemented a GetSpecificVendorByName() function as well, which may be instructive.

Codicem:

usura System;
usura System.Web;
usura System.Web.Services;
usura System.Web.Services.Protocols;
usura Microsoft.SharePoint;
usura System.Configuration;

/// <Summary>
///
Vendor Service: Provides vendor related services which today are consumed by an infopath client form.
///
/// History:
/// ——–
/// 07/24/07: Initial coding, Paul J. Gavin of Conchango.
///
/// </Summary>
[WebService(Namespace = "Http://www.conchango.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
publica genus VendorService : System.Web.Services.WebService
{

/// <Summary>
/// Represents a vendor from a custom sharepoint list maintained by MSUSA.
/// </Summary>
publica genus Vendor
{
publica Vendor() { }

publica Vendor(SPItem initItem)
{
si (! (initItem["Vendor Name"] == nihilo)) VendorName = initItem["Vendor Name"].ToString();
si (! (initItem["Address 1"] == nihilo)) VendorAddress1 = initItem["Address 1"].ToString();
si (! (initItem["Address 2"] == nihilo)) VendorAddress2 = initItem["Address 2"].ToString();
si (! (initItem["City"] == nihilo)) VendorCity = initItem["City"].ToString();
si (! (initItem["VendorPhone"] == nihilo)) VendorPhone = initItem["VendorPhone"].ToString();
si (! (initItem["PurchaseType"] == nihilo)) VendorType = initItem["PurchaseType"].ToString();
si (! (initItem["State"] == nihilo)) VendorState = initItem["State"].ToString();
si (! (initItem["Zip"] == nihilo)) VendorZip = initItem["Zip"].ToString();
si (!(initItem["Fax"] == nihilo)) VendorFax = initItem["Fax"].ToString();
si (!(initItem["SalesRepName"] == nihilo)) VendorSalesRepName = initItem["SalesRepName"].ToString();

VendorItemId = initItem.ID; // Unique ID maintained via MOSS.
}

publica int VendorItemId;
publica filum VendorName;
publica filum VendorAddress1;
publica filum VendorAddress2;
publica filum VendorCity;
publica filum VendorState;
publica filum VendorZip;
publica filum VendorPhone;
publica filum VendorType;
publica filum VendorSalesRepName;
publica filum VendorFax;
}

publica VendorService () {

//Uncomment the following line if using designed components
//InitializeComponent();
}

privatis Vendor[] GenerateTestVendors()
{
Vendor[] resultList;
resultList = novum Vendor[100];

Vendor v;
v = novum Vendor();
v.VendorAddress1 = "v1_address1";
v.VendorAddress2 = "v1_address2";
v.VendorCity = "v1_city";
v.VendorName = "v1_vendorname";
v.VendorPhone = "v1_vendorphone";
v.VendorState = "v1_st";
v.VendorType = "v1_type";
v.VendorZip = "v1_zip";

resultList[0] = v;

v = novum Vendor();

v.VendorAddress1 = "v2_address1";
v.VendorAddress2 = "v2_address2";
v.VendorCity = "v2_city";
v.VendorName = "v2_vendorname";
v.VendorPhone = "v2_vendorphone";
v.VendorState = "v2_st";
v.VendorType = "v2_type";
v.VendorZip = "v2_zip";

resultList[1] = v;

v = novum Vendor();
v.VendorAddress1 = "v3_address1";
v.VendorAddress2 = "v3_address2";
v.VendorCity = "v3_city";
v.VendorName = "v3_vendorname";
v.VendorPhone = "v3_vendorphone";
v.VendorState = "v3_st";
v.VendorType = "v3_type";
v.VendorZip = "v3_zip";

resultList[2] = v;

revertetur resultList;

}

[WebMethod]
publica Vendor GetSpecificVendorById(int vendorId)
{
filum SpVendorSiteName; // Name of the actual MOSS site that hosts the vendor custom list.
filum SpVendorListName; // Name of the actual MOSS list containing vendors.

SpVendorSiteName = ConfigurationSettings.AppSettings["VendorListHostingSite"].ToString();
SpVendorListName = ConfigurationSettings.AppSettings["VendorList"].ToString();

usura (SPSite site = novum SPSite(SpVendorSiteName))
{

usura (SPWeb web = site.OpenWeb())
{

SPList currentList = web.Lists[SpVendorListName];

SPItem specificItem = currentList.Items[vendorId];

revertetur novum Vendor(specificItem);

} // using spweb web = site.openweb()
} // using spsite site = new spsite("Http://localhost/mizuho")

}

[WebMethod]
// Assumes that the vendor name is unique, from a business perspective
publica Vendor GetSpecificVendorByVendorName(filum vendorName)
{
filum SpVendorSiteName; // Name of the actual MOSS site that hosts the vendor custom list.
filum SpVendorListName; // Name of the actual MOSS list containing vendors.

SpVendorSiteName = ConfigurationSettings.AppSettings["VendorListHostingSite"].ToString();
SpVendorListName = ConfigurationSettings.AppSettings["VendorList"].ToString();

usura (SPSite site = novum SPSite(SpVendorSiteName))
{
usura (SPWeb web = site.OpenWeb())
{

SPList currentList = web.Lists[SpVendorListName];

foreach (SPItem vendorItem in currentList.Items)
{
si (vendorItem["Vendor Name"] == nihilo) perseverant;

si (vendorItem["Vendor Name"].ToString().Pares(vendorName))
revertetur novum Vendor(vendorItem);
}

Vendor v = novum Vendor();
v.VendorPhone = "not found: " + vendorName;

revertetur v;

revertetur nihilo;

} // using spweb web = site.openweb()
} // using spsite site = new spsite("Http://localhost/mizuho")

} // methodo

[WebMethod]
publica Vendor[] GetVendorsOfType (filum filterType)
{

filum SpVendorSiteName; // Name of the actual MOSS site that hosts t
he vendor custom list.
filum SpVendorListName; // Name of the actual MOSS list containing vendors.

SpVendorSiteName = ConfigurationSettings.AppSettings["VendorListHostingSite"].ToString();
SpVendorListName = ConfigurationSettings.AppSettings["VendorList"].ToString();

Vendor[] resultList;
int vendorIndex = 0;
resultList = novum Vendor[1000];

// Initialize the list with a default friendly message.
Vendor v = novum Vendor();
v.VendorName = "Select a vendor type to populate this list.";
resultList[0] = v;

// Convert the filter to lower case for easier string comparison later.
filterType = filterType.ToLower();

// If the filter type passed is "test", generate some simple data.
#regionem Filter type = "test"
si (filterType.Equals("test"))
revertetur GenerateTestVendors();
#endregion

si (verum)
{
usura (SPSite site = novum SPSite(SpVendorSiteName))
{
usura (SPWeb web = site.OpenWeb())
{

v = nihilo;

SPList currentList = web.Lists[SpVendorListName];

// Iterate through all the items in the vendor list.
foreach (SPItem vendorItem in currentList.Items)
{

filum lowerVendorType;

lowerVendorType = vendorItem["PurchaseType"].ToString().ToLower();
lowerVendorType = lowerVendorType.Substring(3);

si (lowerVendorType.Equals(filterType))
{
resultList[vendorIndex ] = novum Vendor(vendorItem);
}
} // iterating thru all the vendors in the list


revertetur TrimVendorArray(vendorIndex, resultList);
// return resultList;

} // using spweb web = site.openweb()
} // using spsite site = new spsite("Http://localhost/mizuho")

} // if true

revertetur nihilo;
}

privatis Vendor[] TrimVendorArray(int newsize, Vendor[] originalVendorArray)
{
Vendor[] trimmedArray;

si (newsize == 0) newsize = 1;
trimmedArray = novum Vendor[newsize];

int currentCounter = 0;

nam (currentCounter = 0; currentCounter < newsize; currentCounter )
{
trimmedArray[currentCounter] = originalVendorArray[currentCounter];
}

revertetur trimmedArray;

}
}

MUSCUS: Observationes InfoPath debugging

InfoPath server formam erroris nuntius sunt errans;.

Proventu per formam InfoPath, Ego stipes eam formam obvius servo MUSCUS. Forma igitur esset committitur ad oneratis et generare plenissima erroris nuntius demonstrato me ad fenestras vicis stipes pro retineo. In facto, no message was written to the windows event log. Rather, the message was sent to the MOSS ascii diagnostic log. You can track that down via central services administration.

You need to be quick on your feet. MOSS likes to write to the log file, frequently and verbosely. This can be trimmed but the default log writing behavior is "everything as quickly as possible".

MUSCUS: Adaequationis consuetudo album

Sunt multa bona exempla adaequationis consuetudinem gestorum per SDK. Hic est alius.

Negotium problema: InfoPath forma cuius ope fuerit disposuerat users intrare online emptio require. PO exigeret numeros esse traditum sequence dicentur valores integri et ratione automatically.

Negotium Solutio: Partum a consuetudine MUSCUS album continens duas columnas: "ControlField" and "ControlValue". Valor proxime columna continet numerum imperat empta. Note that the generic "control" conventionem nominando potestate futurum prospicit arva potest adhiberi ut indigebat.

Solutio technica: Partum a textus muneris accessed per client InfoPath. Textus muneris redeat retro proxima pressos emptio plures updates et pretium album.

Lectiones didicit:

  • Cum addito telam servicium quod notitia radix ad formam InfoPath, Necesse habui ad convertam ad udc reponunt in notitia nexu bibliotheca.
  • Ego inveni necessarium ut crucis scripting per centralis dominico administratione muneris // administratione application // forma server configuration.
  • Primum forma conatus obvius varius muneris, paulum nonnumquam capit, esset ex tempore. Ego fiddled fundis in forma server configurationem ad expand ad auxilium uidebatur et quod occasus timeout.

Codicem:

usura System;
usura System.Web;
usura System.Web.Services;
usura System.Web.Services.Protocols;
usura Microsoft.SharePoint;
usura System.Configuration;

[WebService(Namespace = "Http://www.conchango.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
publica genus PoService : System.Web.Services.WebService
{
publica PoService () {

//Uncomment the following line if using designed components
//InitializeComponent();
}

/// <Summary>
/// Obtain the next PO number from the sharepoint po number control list.
/// Increment the PO number in that list.
/// </Summary>
/// <Redit></Redit>
[WebMethod]
publica filum GetNextPoNumber()
{
filum SpPoControlSiteName; // Name of the actual MOSS site that hosts the PO Control list.
filum SpPoControlListName; // Name of the actual MOSS list containing the Po control.

SpPoControlSiteName = ConfigurationSettings.AppSettings["PoControlListHostingSite"].ToString();
SpPoControlListName = ConfigurationSettings.AppSettings["PoControlList"].ToString();

filum nextPoReqNumber = "Xyzzy";

usura (SPSite site = novum SPSite(SpPoControlSiteName))
{
usura (SPWeb web = site.OpenWeb())
{

SPList currentList = web.Lists[SpPoControlListName];

foreach (SPItem controlItem in currentList.Items)
{

si (((filum)controlItem["ControlField"]).Pares("NextPoNumber"))
{
nextPoReqNumber = (filum)controlItem["ControlValue"];

int int_nextPoReqNumber;
int_nextPoReqNumber = Convoco.ToInt32(nextPoReqNumber);

int_nextPoReqNumber ;

controlItem["ControlValue"] = int_nextPoReqNumber;
controlItem.Update();
}

} // Locating, reading and updating the PO number in the list.


} // using spweb web = site.openweb()
} // using spsite site = new spsite("Http://localhost/mizuho")

revertetur nextPoReqNumber;

}
}