Skip to main content

Notifications

Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Query Builder Error salesorderdetail customView

Posted on by 68
I have a lookup on the entity salesorderdetail and use addCustomView for a special filter. But I always getting the error mentioned in subject.
On deeper search I recognized why and don't understand why crm this is doing that.
I opened the developer tools and network and saw a 400 bad Request. Detailed error:
'SalesOrderDetail' entity doesn't contain attribute with Name = 'name'
But my fetchXml does not contain this attribute.
A closer look at this: this attribute is added by crm automatically.
I compared it with a customView for quotedetails, and saw that there is also added an attribute, but in this case:
<attribute name="quotedetailname"/>
and this is correct.
But on salesorderdetail it should be 
<attribute name="salesorderdetailname"/>
Why does M$-CRM add this name-attribute to my fetchxml?
Can anyone reproduce this problem and has anybody a solution for it?
thx
©a-x-i
 
Categories:
  • Suggested answer
    Amit Katariya007 Profile Picture
    Amit Katariya007 8,179 Super User 2024 Season 1 on at
    Query Builder Error salesorderdetail customView
    No problem mate 🙂. Happy to help you out.
     
    If you have resolved your issue, you can mark it as verified, as it can help other Users in future.
  • Axi Bachlechner Profile Picture
    Axi Bachlechner 68 on at
    Query Builder Error salesorderdetail customView
    Yeah.... thanks. That's it....
    I couldn't see the forest for the trees. I always took a look at the fetchxml and forgot about the rest of the code.
    But never the less: the fact, that MS-CRM is adding an additional attribute and showing up an error which guides me to the wrong direction, is really strange.
    Thank you guy for your patience with me 🙏
     
    ©a-x-i
  • Verified answer
    Amit Katariya007 Profile Picture
    Amit Katariya007 8,179 Super User 2024 Season 1 on at
    Query Builder Error salesorderdetail customView
    1. Verify the Grid Layout XML Ensure that the gridLayout XML used in the addCustomView method includes the salesorderdetailname attribute as a column in the view.
     
    Example of gridLayout:
     
    <grid name="resultset" object="1" jump="salesorderdetailid" select="1" icon="1" preview="1">
      <row name="result" id="salesorderdetailid">
        <cell name="salesorderdetailname" width="150" />
        <cell name="productid" width="150" />
        <cell name="productdescription" width="150" />
      </row>
    </grid>
     
     
    2. Correct the Entity Name in the addCustomView Method Ensure that the entity name you pass in addCustomView matches the logical name of the entity used in your FetchXML (salesorderdetail) rather than product.
     
    Example:
     
    formContext.getControl("wdps_base_salesorderdetail").addCustomView(
      viewId,
      "salesorderdetail", // Use the logical name of the entity
      "Basisprodukt",
      fetchXml,
      gridLayout,
      true
    );
     
    From your reply I can see u have not passed correct entity name. It should be "salesorderdetailname" rather than "product"
     
  • Axi Bachlechner Profile Picture
    Axi Bachlechner 68 on at
    Query Builder Error salesorderdetail customView
    @Amit Katariya007 Did you read my post from top to bottom? Did you see my fetchxml? Did you see any attribute with name 'name' in my fetchXml?
    I don't add this attribute to my fetchXml, this attribute is added by crm itself and I don't know why.
    If you like to help me, try to reproduce my problem.
    Add a lookup to salesorderdetail on any form you want. Add js-code and do addCustomView on the lookup on the form. 
    You always write the same answer and do not understand my problem :(
     
    ©a-x-i
  • Suggested answer
    Amit Katariya007 Profile Picture
    Amit Katariya007 8,179 Super User 2024 Season 1 on at
    Query Builder Error salesorderdetail customView
    I have shared you developers guide for sales order details Entity and you can see we don't have any logical field named as "name". 
     
    We have a field which is having logical name as "salesorderdetailname", please use this field instead of "name
  • Axi Bachlechner Profile Picture
    Axi Bachlechner 68 on at
    Query Builder Error salesorderdetail customView
    okay, the customer needs a special solution so i put a lookup to the entity "salesorderdetail" on the entity "salesorderdetail" (base salesorderdetail).
    But I need to add a customView because I only want to show salesorderdetail-entities which are already added on the salesorder and where the product has a special attribute set to true. So in short
    myFetchXML (shortened)
    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
      <entity name="salesorderdetail">
        <attribute name="salesorderdetailname"/>
        <attribute name="productid" />
        <attribute name="productdescription" />
        <filter type="and">
          <condition attribute="salesorderid" operator="eq" uitype="salesorder" value="##SALESORDERID##" />
        </filter>
        <link-entity name="product" from="productid" to="productid" link-type="inner" alias="ac">                           
          <filter type="and">
            <condition attribute="special_attribute" operator="eq" value="1" />
          </filter>
        </link-entity>
      </entity>
    </fetch>
     
    and the call in js (ts):
    formContext.getControl("wdps_base_salesorderdetail")).addCustomView(viewId, "product", "Basisprodukt", fetchXml, gridLayout, true);
    in the network-tab I get a 400 with the error: "message": "'SalesOrderDetail' entity doesn't contain attribute with Name = 'name' and NameMapping = 'Logical'. And in the screenshot you can see, that this attribute is sent but I don't have it on my fetch.
     
     
    I hope it's clear now.
    thx again
    ©a-x-i
  • Suggested answer
    Amit Katariya007 Profile Picture
    Amit Katariya007 8,179 Super User 2024 Season 1 on at
    Query Builder Error salesorderdetail customView
    Bro if it is a OOB lookup then check "lookup view" of Sales order details Entity.
     
    If it is a custom view filter then remove that attribute.​​​​​​
     
  • Axi Bachlechner Profile Picture
    Axi Bachlechner 68 on at
    Query Builder Error salesorderdetail customView
    @Amit Katariya007 
    you don't understand my problem. I don't use the attribute 'name' in my fetchXML. The attribute is added by the crm itself.
    My fetchXML:
    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
                              <entity name="salesorderdetail">
                                <attribute name="productid" />
                                <attribute name="productdescription" />
                                <attribute name="priceperunit" />.....
     
    the fetchXML which is send to the server:
     
    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
                              <entity name="salesorderdetail">
                                <attribute name="name" />
                                <attribute name="productid" />
                                <attribute name="productdescription" />
                                <attribute name="priceperunit" />....
     
    So I think: bug in MS-CRM 🤷‍♂️
    ©a-x-i
  • Suggested answer
    Amit Katariya007 Profile Picture
    Amit Katariya007 8,179 Super User 2024 Season 1 on at
    Query Builder Error salesorderdetail customView
    If you are using addCustomView for that lookup. Then replace name with the salesorderdetailname.
    Also are you talking about this issue for any OOB components also?
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,134 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,928 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans