Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

FetchXML Parameter Cannot be compared to a Guid Expand / Collapse
Posted Thursday, September 26, 2013 8:53 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Yesterday @ 8:03 AM
Points: 377, Visits: 1,199
Visual Studio 2008 BIDS

In a CRM report, there is a drop-down to select a given account from the CRM database. For the account selected by the user, the report is to give the list of all contracts tied to that specific account.

In Visual Studio I created a report with a Fetch XML connection. This is the definition of the dataset:

.    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="contract" enableprefiltering="true"
<attribute name="contractnumber"/>
<attribute name="title"/>
<attribute name="customerid"/>
<attribute name="totaldiscount"/>
<attribute name="netprice"/>
<attribute name="statecode"/>
<attribute name="activeon"/>
<attribute name="expireson"/>
<attribute name="duration"/>
<attribute name="transactioncurrencyid"/>
<filter type="and">
<condition attribute="customerid" operator="eq" value= "Parameters!CRM_Filteredcontract.Value" />
<order attribute="activeon" descending="true" />

The parameter is obtained by selecting one item in the list generated by this second dataset:

    <version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="account">
<attribute name="accountnumber"/>
<attribute name="name"/>
<attribute name="accountid"/>
<order attribute="name" descending="false" />

The parameter data type is defined as text -- a GUID is not listed in the data type picklist. In Available values: the field chosen for Value is "accountid" example: 4e85889a-89e5-e211-bdd0-005056af2e0f and the field chosen for Label is "name" example: My First Company.

Running the query yields this error message:

An exception System.FormatException was thrown while trying to convert input value 'Parameters!CRM_Filteredcontract.Value}' to attribute 'contract.customerid'. Expected type of attribute value: System.Guid. Exception raised: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).

The "accountid" 4e85889a-89e5-e211-bdd0-005056af2e0f LOOKS like a GUID and so do the field "customerid" and the parameter when printed (after disabling the <condition attribute="customerid").

All examples I have found are unsatisfactory because it is a hard-coded constant that is used for the filter value, such as

<condition attribute=statecode operator=eq value=1" />

I have tried adding curly braces around the Parameter!...Value, I have tried casting the Parameter as System.Guid, I have tried changing the Parameter data type in the report xml code view, I have tried using expressions. VS rejects all such attempts.

So how can this be made to work ?
Post #1498896
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse