Hi all,
Ive got a webservice which takes two inputs, one string and one int. It queries a sharepoint list and performs a mathematical calculation then returns a decimal value.
Ive set up an infopath form with domain trust to connect to the webservice, I then enter the values into infopath and query from the webservice. The webservice runs fine from the local machine however infopath returns the following error:
The query cannot be run for the following DataObject: SalesTransactConversion
InfoPath cannot run the specified query.
Does anyone have any ideas? It does not give any specific details so I am unable to track what is causing the problem.
Code for the webservice is below:
[WebMethod]
public decimal SalesTransactConversion(string fromCurrency, int SalesValueTransact)
{
//Create a new SPsite (SharePoint Site)
SPSite site = new SPSite("http://ukhqsptest002:45697/");
//Open the Root Web
SPWeb web = site.OpenWeb();
//Declare our Conversion Custom List
SPList conversionlist = web.Lists["Conversion"];
//Create an SPQuery that we will use to query the list
SPQuery query = new SPQuery();
query.Query = "<Where><And><And><Eq><FieldRef Name='Title' /><Value Type='Text'>EUR</Value></Eq>" +
"<Leq><FieldRef Name='Effective_x0020_From' /><Value Type='DateTime'>2008-07-25T00:00:00Z</Value>" +
"</Leq></And><Geq><FieldRef Name='Effective_x0020_To' /><Value Type='DateTime'>2008-07-25T00:00:00Z</Value>" +
"</Geq></And></Where>";
//Get all items in the list matching our query and put them into a collection
SPListItemCollection items = conversionlist.GetItems(query);
//Declare our Conversion Rate and Round Amount Variables
string convertratestring;
string roundvaluestring;
//Set it to a Sample Value
convertratestring = "Something";
roundvaluestring = "Something";
//Iterate through the items in the collection and set our string to the Convert Rate of the item and our Round Amount
foreach (SPListItem item in items)
{
convertratestring = item["Convert Rate"].ToString();
roundvaluestring = item["Round Value"].ToString();
}
//Convert the Conversion Rate from string to decimal
decimal convertratedecimal;
convertratedecimal = Convert.ToDecimal(convertratestring);
//Convert the Round Value from string to integer
int roundvalue;
roundvalue = Convert.ToInt16(roundvaluestring);
//Convert our Sales Value Transaction amount into a decimal
decimal SalesValueTransactdec;
SalesValueTransactdec = Convert.ToDecimal(SalesValueTransact);
//Create a decimal in which to store our Sales Value Base amount
decimal SalesValueBasedec;
//Multiple the Sales Transaction amount by the Convert Rate and return the Sales Value Base Amount
SalesValueBasedec = decimal.Multiply(SalesValueTransactdec, convertratedecimal);
//Round the Sales Value Base Amount to the Required Round Value
SalesValueBasedec = decimal.Round(SalesValueBasedec, roundvalue);
//Return the Sales Value Base Amount
return SalesValueBasedec;