SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

FetchXML Parameter Cannot be compared to a Guid

FetchXML Parameter Cannot be compared to a Guid

SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)

Group: General Forum Members
Points: 2650 Visits: 1225
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 ?



You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum