locked
CRM4: fetchXML against money field throwing a transactionCurrencyId error RRS feed

  • Question

  •  

    Hi all,

     

    In getting ready for our upcoming upgrade to CRM4, I'm converting all my CRM3 apps. One app of mine that worked just fine in CRM3 is now throwing an error when I try to use fetchXML to retrieve some data against CRM4:

     

    0x80040216 transactionCurrencyId needs to be supplied to format a transaction money field. Platform

     

    The only field I am going after that is type money is contractdetail.price. I'm using the simple line of code to get it:

     

    <link-entity name="contractdetail" from="contractid" to="contractid" alias="contractline">

    <attribute name="price" />

    </link-entity>

     

    I assume I need to put another attribute in there to specify the currency, only I don't know what it is, and searches online have proved fruitless. So, my question: how do I specify currency within a fetchXML document so that it won't throw this error?

     

    TIA for any advice any of you can offer.

    Monday, October 20, 2008 9:05 PM

Answers

  • Hi,

     

    If you are not using multi currency or you don't mind to retrieve the price using the default currency of your organisation you could retrieve the attribute price_base instead of price, or [field_name]_base for any other money field.

     

    Otherwise, you need to add the attribute transactioncurrencyid from the same entity that you are retrieving a money field. This is due to CRM enforces you to retrieve the transaction currency information to ensure the proper formatting as the money fields can be in any of the different currencies available at the organisation.

     

    In your case adding this would do the work.

     

     

    Code Snippet
         <link-entity name="contractdetail" from="contractid" to="contractid" alias="detail">
             <attribute name="price" />
             <attribute name="transactioncurrencyid" />
          </link-entity>

     

     

     

    Hope it helps,

    Marco

    Tuesday, October 21, 2008 12:20 AM
    Moderator

All replies

  • Hi,

     

    If you are not using multi currency or you don't mind to retrieve the price using the default currency of your organisation you could retrieve the attribute price_base instead of price, or [field_name]_base for any other money field.

     

    Otherwise, you need to add the attribute transactioncurrencyid from the same entity that you are retrieving a money field. This is due to CRM enforces you to retrieve the transaction currency information to ensure the proper formatting as the money fields can be in any of the different currencies available at the organisation.

     

    In your case adding this would do the work.

     

     

    Code Snippet
         <link-entity name="contractdetail" from="contractid" to="contractid" alias="detail">
             <attribute name="price" />
             <attribute name="transactioncurrencyid" />
          </link-entity>

     

     

     

    Hope it helps,

    Marco

    Tuesday, October 21, 2008 12:20 AM
    Moderator
  •  

    Just what the doctor ordered! Thank you very much!
    Tuesday, October 21, 2008 8:00 PM