I am trying to create a view that will display data from an order. There is a one to many relationship from the order to the payments for an order. The payments will display on the order form. The problem I'm having is that the information from the payment does not display when you run the query. Here is the XML from the view.
<?xml version="1.0"?>
-<fetch distinct="false" mapping="logical" output-format="xml-platform" version="1.0">
-<entity name="salesorder"><attribute name="name"/>
<attribute name="customerid"/>
<attribute name="totalamount"/>
<attribute name="salesorderid"/>
<order descending="false" attribute="name"/>
-<filter type="and"><condition attribute="totalamountlessfreight" value="0"
operator="gt"/>
<condition attribute="ree_orderdate" operator="this-month"/>
</filter>
-<link-entity name="ree_salesorderpayment" alias="a_eaddfe488ba0e2118a9d78e3b508542d" link- type="outer" visible="false" to="ree_payment" from="ree_salesorderpaymentid">
<attribute name="ree_paymentdate"/>
<attribute name="ree_paymentamount"/>
</link-entity>
</entity></fetch>
Is this possible?
Thanks,
Gary
The Stunnware Tools app is old but still good for FetchXML. One thing I've noticed before ref strange behaviour with queries is that if there are currency fields behaving oddly, then adding the transactioncurrencyid field to the columns can help.
Did you create this XML? One cool new thing is the Advanced Find you can download the FecthXml. And in Advanced Find you can change the filters and see where your query is failing.
EDIT: In Advanced find you can set all query you want, make filters (just add columns and apply the operators AND and OR) and you can make joins when you want filter a related entity. After that you can download the FetchXML, so we have sure that FetchXML is well formatted. If don't get any records the problem is in your data and not in FetchXML, so i advised you remove the filters to know where are the problems.
I don't know which login you are but if you aren't using an administrator it's possible you catch something about security permissions.
You can try change the entities, make the query to ree_salesorderpayment entity and after make a join with salesorder.
Related
I had a datatype defined as follows in items.xml:
<attribute qualifier="daysOfWeek" type="java.lang.String">
<persistence type="property" />
</attribute>
To modify the data type to enumeration,I redefined it as follows:
<enumtype code="DaysOfWeek" autocreate="true" generate="true">
<value code="Monday" />
<value code="Tuesday" />
</enumtype>
<attribute qualifier="daysOfWeek" type="DaysOfWeek">
<persistence type="property" />
</attribute>
After updating the extension,I am getting SQLException.Is there anything wrong with this approach?
hybris doesn't support updates like this in a "running" system.
The reason is that hybris won't drop any db columns and recreate them as any data contained in there would be lost (plus its probably difficult to write this logic for multiple supported databases).
If you are in a development phase of your project, the easiest way to fix this is to initialize your system from scratch (i.e. it will drop the database and recreate it).
If you have a live system / production system, you would have to take another approach:
You would define a new attribute (different name!) with your enumeration type.
You would then probably update any code to use the new field.
You would also have to take care of data migration, i.e. write some scripts that transfer the old data (e.g. the String "Monday" to the new respective enum value).
Hope this helps!
I have an entity called as medicalcase
Each medical case has a subgrid, N:N relationship with an entity called as mcfamily
Each mcfamily has Father, Mother, Child fields which are lookups to contact field
Now if I make a webapi call
http://serverurl/api/data/v8.0/new_medicalcase(caseid)?$expand=new_medcase_mcfamily
I get the new_father_value, but I want to expand the Father lookup and get the contact name. How can I do it?
I tried
http://serverurl/api/data/v8.0/new_medicalcase(caseid)?$expand=new_medcase_mcfamily($expand=new_father($select=fullname))
But it said
navigation property can't be expanded. Multiple levels of expansion
aren't supported.
You'll have to manually expand by making a second request for the father contact.
If you make the request using a FetchXml query, you should be able to double-expand with one call. Here's an example of how to send a fetch query via the WebAPI (too long to copy here).
Update in response to your comment
Here's a fetch query that would retrieve all of your father names in one call. It assumes the following logical names:
medicalcase entity: new_medicalcase
mcfamily entity: new_mcfamily
lookup to father contact: new_fatherid
N:N entity: new_medicalcase_new_mcfamily
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
<entity name="contact" >
<attribute name="fullname" />
<link-entity name="new_mcfamily" from="new_fatherid" to="contactid">
<link-entity name="new_medicalcase_new_mcfamily" from="new_mcfamilyid" to="new_mcfamilyid" intersect="true">
<link-entity name="new_medicalcase" from="new_medicalcaseid" to="new_medicalcaseid">
<filter>
<condition attribute="new_medicalcaseid" operator="eq" value="FAEEE5D8-D67C-E511-80E6-3863BB3CA578" />
</filter>
</link-entity>
</link-entity>
</link-entity>
</entity>
</fetch>
To get the query working right, use the FetchXml Tester tool that comes with the XrmToolbox. After you get it working correctly, reference the link from earlier in my answer to execute the fetch query using the WebAPI.
I am using a service that gets data from CRM ONLINE and transfers it to SQL database for reporting purposes. I am using the following Fetch XML query to query CRM
string fetchXml = string.Format(#"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
<entity name='new_studentinformation' enableprefiltering ='1' prefilterparametername='CRM_Filterednew_studentinformation'>
<attribute name='new_studentid' />
<attribute name='new_primaryhomeroom' />
<attribute name='new_lastname' />
<attribute name='new_firstname' />
<attribute name='new_busnumber' />
<attribute name='new_schoolname' />
<attribute name='new_gradecode' />
<attribute name='modifiedon' />
<attribute name='new_studentinformationid' />
<filter type='and'>
<condition attribute='modifiedon' value='{0}' operator='on-or-after'/>
</filter>
<order attribute='modifiedon' descending='true' />
<link-entity name='annotation' from='objectid' to='new_studentinformationid' alias='Notes' link-type='outer'>
<attribute name='documentbody'/>
<filter type='and'>
<condition attribute='createdon' value='{0}' operator='on-or-after'/>
</filter>
<order attribute='createdon' descending='true' />
</link-entity>
</entity>
</fetch>"
Every record has more than one image attached to it in Notes entity, however I want to transfer the latest picture ONLY. I have tried using the createdon in the order attribute but it keep bringing the images with the record till the oldest one. I only want it to bring the latest image and stop it there and move to the next record.
How can I limit it to querying only the latest image attached with the record?
Unfortunately <link-entity> doesn't allow it.
If you want a quick cheat around this limitation, you could do this (we do it all the time when specs go nuts):
Add a lookup to annotation to your new_studentinformation entity (keep it out of forms)
Register a plugin on new_studentinformation (Pre-Op, Sync, both for Retrieve and RetrieveMultiple) in which you fill the new attribute with the reference to the record you want in the report. I expect this to take 15 minutes tops.
Now switch the from attribute in the link-entity to the new one
BONUS: If your plugin is designed correctly, the reference in the custom attribute (and consequently your report) will automagically update itself.
I have a simple solution for your problem which will save you time and effort which you will put in making a plugin.
You should make a javascript resource , add a hidden field on your form.
Run that javascript on OnSave event. Store that document body in a text view.
Just query the document body text area while you are retrieving the image.
It may sound a hack! but it will increase the efficiency of your code.
I have two (related) questions:
I am having a puzzling problem with the Advanced Find function. I set up the fields I require, both in the criteria and display section and then hit 'Download Fetchxml'. What I end up with is fields that I never asked for. For example, in my advanced find I asked for All Activities. I changed the results to show me only the Date Created, Activity Type, Subject and Regarding fields. The (truncated) generated fetchXML looks like this:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="activitypointer">
<attribute name="activitytypecode" />
<attribute name="subject" />
<attribute name="activityid" />
<attribute name="instancetypecode" />
<attribute name="community" />
<attribute name="createdon" />
<attribute name="regardingobjectid" />
<order attribute="subject" descending="false" />
Why have those extra columns been included? I didn't ask for the 'community' attribute anywhere, for example.
Second question:
What determines the output order of the fields? I ran the above fetchXML through Fetch Tester 3000 (saved my life - thank you!) and the output table bears no relation to the order of the attributes in the xml. This is true also when I use the fetchXML elsewhere.
Thanks in advance for your comments
The FetchXML returned by the button Download Fetch XML is generated internally and in some scenarios it returns extra columns (as you found), for example the primary key field of the entity is always added.
If you remove the additional attributes the FetchXML is still valid and can be executed.
Regarding the order, the tool you used (Fetch Tester 3000) display the fields inside the Table View ordered by their logicalname, inside Dynamics CRM the order of the attributes (subgrids and advanced find results) is defined using another XML definition known as LayoutXML
Is it possible to find all accounts who has not modified any activity in last one month in CRM. I have tried one but i am not sure whether it is correct or not. can anybody please help me. I am not sure whether it is possible or not.
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
<entity name="account">
<attribute name="name" />
<attribute name="primarycontactid" />
<attribute name="telephone1" />
<attribute name="accountid" />
<order attribute="name" descending="false" />
<link-entity name="activitypointer" from="regardingobjectid" to="accountid" alias="au" link-type="outer">
<filter type="and">
<condition attribute="modifiedon" operator="olderthan-x-months" value="1" />
</filter>
</link-entity>
I think the best way to do this without making multiple queries is to create a custom field on the account entity and then have a plugin that populates that field whenever an activity related to the account is updated. That will make your query a lot easier and work in CRM.
I'm afraid that it is not possible to get such kind of fetch xml. You will have to implement your logic in 2 steps:
Retrieve all accounts.
Remove all the accounts that have activities that were modified during last month.
I guess your problem here is that you will only get Accounts that have an associated activity. While your query also needs to return accounts that have no associated activities as well.
What you need is a Left Outer Join. This is only available in 2013 so, if you are upgrading any time soon, you will be able to add the following condition to your query to get the required results.
<condition entityname='account' attribute='regardingobjectid' operator='null'/>