in my Azure Data Factory pipeline, I have a parameter, let's call it 'pDate', and it has a default value of 2023-01-01.
But every time I run the pipeline (copy data), I want to be able to change it.
I can do that with a variable as shown below (date1 variable), but then I have to change the value of the variable.
How could I insert a parameter here instead?
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="my_attachment">
<all-attributes/>
<filter type="and">
<condition attribute="createdon" operator="on-or-after" value="#{variables('date1')}" />
</filter>
</entity>
</fetch>
Parameters are constants across the particular pipeline. So, you can't change its value within the pipeline.
A variable with static value (say 2023-01-01) is a parameter itself. Every time you execute the pipeline, the same value will be assigned to the variable making its functionality similar to parameter.
If there is a pattern for your date like created on or before 10 days (from today's date), then you can build a dynamic pipeline expression for this value. So, each time you run the pipeline, the value would be dynamic as required.
If there is no such pattern, then you have to make use of parameters. You can still change the value each time you run the pipeline.
When you try to trigger or debug the pipeline, the pipeline run tab will prompt you to enter the value for your parameter. You can simply give the required value and proceed accordingly.
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="my_attachment">
<all-attributes/>
<filter type="and">
<condition attribute="createdon" operator="on-or-after" value="#{pipeline().parameters.req_date}" />
</filter>
</entity>
</fetch>
Related
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'm doing RetrieveMultiple call with following query:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="lt_myentity">
<attribute name="lt_id" />
<attribute name="lt_changetype" />
</entity>
</fetch>
It's working fine but lt_changetype is defined as optionset so in result I'm getting IDs like 206420010. How can I get values instead?
I know about RetrieveAttributeRequest but maybe it's possible to do this without second call and matching.
IF You Want to Get the OptionSetValue You Can use FormattedValues Property After Getting the Data from FetchXML. Kindly Check this FormattedValues
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'/>
I am having a bizarre problem, and was hoping that someone could shed some light on why it is occurring. If I Query dynamics using FetchXML using the following:
<fetch mapping="logical" count="10" distinct="true" version="1.0">
<entity name="activitypointer">
<attribute name="activityid" />
<attribute name="activitytypecode" />
<attribute name="createdon" />
<attribute name="ownerid" />
<attribute name="statecode" />
<attribute name="statuscode" />
<attribute name="subject" />
<attribute name="actualend" />
<order attribute="actualend" descending="true" />
<filter type="or">
<condition attribute="regardingobjectid" operator="eq" value="66431c2f-fab6-dd11-94f2-0014221f6f5c" />
</filter>
</entity>
Then I get the following set of results:
However if I do the same query in SQL:
SELECT TOP 100 activityid, activitytypecodename, createdon, owneridname, statecodename, statuscodename, subject, actualend FROM [CRM2011_MSCRM].[dbo].[FilteredActivityPointer] WHERE regardingobjectid = '66431C2F-FAB6-DD11-94F2-0014221F6F5C' ORDER BY actualend DESC
Then I get the following results:
You can see that the results are pretty much the same, however if you look at the status code column then you can see that the results differ in the fact that one states that it has been sent while the other has been completed.
Therefore how can I filter based upon the status of the item when the two different methods seem to bring back different results for the state code?
(I am currently trying to do a report in SSRS using FetchXML I have previously tried doing it in SQL but had problems, therefore used FetchXML to solve this)
-- Edit
When I use the appointment entity then I do get the correct results:
<fetch mapping="logical" count="50" version="1.0">
<entity name="appointment">
<attribute name="activityid" />
<attribute name="activitytypecode" />
<attribute name="actualend" />
<attribute name="createdon" />
<attribute name="ownerid" />
<attribute name="statecode" />
<attribute name="statuscode" />
<attribute name="subject" />
<filter>
<condition attribute="regardingobjectid" operator="eq" value="66431c2f-fab6-dd11-94f2-0014221f6f5c" />
</filter>
</entity>
Which returns this:
The only problem with this though is I need to know the status for a whole list of different activities - thus I thought you needed to use the activity pointer (as it is the base class plus you can't join results together in SSRS.)
Well, this isn't an answer on how to solve this, perhaps, but I think I can shed some light on why it may be happening.
For the statuscode of an activitypointer, fetchXML is taking the integer value and mapping it to the activitypointer lookup table, while SQL maps it to the actual child entity's table.
For example, take your very first record, which happens to be an email. FetchXML says the status is "cancelled". Checking the activitypointer metadata (http://msdn.microsoft.com/en-us/library/gg328148.aspx) we see that "cancelled" is value "3". Now, going to the email entity metadata (http://msdn.microsoft.com/en-us/library/hh155312.aspx) we see that value "3" is actually "sent", which is what SQL says.
This goes for all the entities you have in the table. The lonely Task with no fetchXML status, for example, is actually completed according to sql. That's value "5" (http://msdn.microsoft.com/en-us/library/gg594424.aspx), which doesn't map to anything for activitypointers; their values are limited to a range of 1-4. As a result, fetchXML shows nothing.
Try getting the statuscodeValue rather than name. I expect the integer values will be identical for both fetchXML and SQL. Why they map the names differently I can't answer.