Not able to get optionset string from Dynamics CRM to SQL Server using Azure data factory.
I am using Azure data factory to move data from Dynamics CRM to SQL DB. I used fetchXML query to get the data from source (CRM). I am able to get normal string and guid type values without any issue.
But the optionset field from CRM is coming as Int32 type (ie, I am getting the value of optionset, not the string).
How can I fix this issue?
I'm going to have to sync the stringmaps entity too as I exceeded the link-entity limit for a given FetchXML query.
The following will bring in the textual value of an OptionSet selection.
<link-entity name="stringmap" from="attributevalue" to="____" visible="false" link-type="outer" alias="____">
<filter type="and">
<condition attribute="objecttypecode" operator="eq" value="___"/>
</filter>
<attribute name="value"/>
</link-entity>
to should be the name of the OptionSet column on the host/root entity
alias whatever you want to call the column in the output. I used the same value as to
value This is the object type code for your host/root entity. It is an integer value.
Probably you are using this approach to get the fetchxml resultset as Dynamics source to dumping into SQL using Azure Data factory. The problem you are facing is unable to consume the formatted text value for that picklist option.
We will do consume the formatted value using below syntax in code: Reference
//Option set
var industrycodeValue = accountDetails['industrycode'];
var industrycodeTextValue = accountDetails['industrycode#OData.Community.Display.V1.FormattedValue'];
If you cannot do such thing, then it’s better to dump another table in your SQL called stringmap which will store all the picklist options across the system.
Then you can inner join both tables to get the necessary data.
select INC.TicketNumber[Case ID],SMT.Value[Status Name], SMT.AttributeValue[Status Value]
from incident as INC inner join StringMap as SMT
on INC.StatusCode = SMT.AttributeValue
where SMT.AttributeName='statuscode' and SMT.ObjectTypeCode=112
Read more
Related
I want to retrieve records from multiple entities by matching text. Is it possible using fetchxml or web api? I want to use it by javascript.
This is certainly achievable using FetchXML. Specifically you want to use the like operator. For example the following Fetch Query searches contact name and email for a given value:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="contact">
<attribute name="fullname" />
<attribute name="contactid" />
<filter type="and">
<filter type="or">
<condition attribute="fullname" operator="like" value="%[Insert Dynamic Value]%" />
<condition attribute="emailaddress1" operator="like" value="%[Insert Dynamic Value]%" />
</filter>
</filter>
</entity>
</fetch>
Write a similar fetch query for each table you wish to search.
Is it possible to combine all entities together instead of requesting separately using fetchXml?
No, by design FetchXML does not support querying multiple unrelated records. Although you can query against related records in a single fetch expression, you are not able to enforce OR conditions across multiple tables. For example, you cannot write a FetchXML query comparable to the following SQL:
SELECT *
FROM contact
JOIN account on contact.accountid = account.accountid
WHERE contact.fullname like '%foo%'
OR account.name like '%foo%'
It appears to be possible, though unsupported, to access Relevance Search via an API: https://bguidinger.com/blog/relevance-search-api
I am using the below FetchXML
<filter type="and">
<condition attribute="emailaddress" operator="eq" value="jon#gmail.com" />
</filter>
So is there a way to ignore casing in Fetch XML?
It depends on sql server Database Settings. Default is case insensitive.
Although it’s optional, consider accepting the SQL Server default settings for Collation Designator, Sort Order, and SQL Collation. Dynamics 365 for Customer Engagement supports the following collation orders:
Case-sensitive
Case-insensitive
Accent-sensitive
Accent-insensitive
Binary sort order (such as Latin1_General_100_BIN)
https://learn.microsoft.com/en-us/dynamics365/customer-engagement/on-premises/sql-server-requirements-recommendations
I understand <link-entity> is used to do joins, but can you help me translate the following into english?
<entity name = "example">
*insert a bunch of attributes*
<link-entity name="providercertification" from="providerid" to="vendorid" alias="aa">
I understand <link-entity> is used for joins, but the join type is not specified, so that is throwing me off. How does the link-entity work if no join type is specified? Is it automatically an inner join?
Also, which column does the from part apply to? The very first entity or the one specified in the <link-entity>?
Same question for the from part.
Per documentation the below query is totally valid, which means alias, from & link-type are optional.
from always refer to same entity as link-entity node (primary key systemuserid of systemuser in this case). to refers to attribute of entity parent node (owninguser of account in this case)
<entity name='account'>
<attribute name='accountid'/>
<attribute name='name'/>
<link-entity name='systemuser' to='owninguser'>
Use a left outer join in FetchXML to query for records "not in"
So explicit link-type='outer' is required for outer join but inner join is default.
Interestingly Fetchxml is full of surprises. You can also refer FetchXML schema
I have a simple Oracle table with 3 fields: ID (int), Name (nvarchar), and configJSON (CLOB).
The configJSON field is over 10,000 characters.
I am trying to use this table in an oData web service using entity framework. I do not get an error message, but the response is simply blank. When I remember the CLOB column I see the other 2 data fields so I think the issue relates to the large CLOB field. I am not tied to that particular data type but I thought that was the best to use since my field is so large.
What is the best way to return a large data field within an oData web service?
I was able to resolve the issue by changing the field type to a LONG.
I am using FetchXml to query CRM 4.0. We have a special case that will require a composite join between CRM entites. The FetchXml schema indicates that multiple link-entity elements are allowed, and it also indicates that multiple filter/condition elements can be added to a link-entity. The problem I'm facing is that the value attribute of the condition element does not appear to permit an entity/column name. It expects an explicitly declared value.
For example, FetchXml lets you specify this:
<link-entity name='myentity' from='column1' to='column2'/>
... which does the T-SQL equivalent of this:
JOIN myentity on column1 = column2
And it lets you specify this:
<link-entity name='myentity' from='column1' to='column2'>
<filter type='and'>
<condition attribute='column3' operator='eq' value='myvalue' />
</filter>
</link>
... which is the T-SQL equivalent of this:
JOIN myentity on column1 = column2 AND column3 = 'myvalue'
FetchXml does not appear, however, to provide an equivalent of this:
JOIN myentity on column1 = column2 AND column3 = column4
Note the difference. FetchXml provides for conditions in the join, but it does appear to provide for a composite join, that is, a join across multiple columns.
Has anyone out there in cyberspace been able to perform a composite join using FetchXml in CRM 4.0? Thanks!
More information:
I'm hunting an answer that uses FetchXml to accomplish this - not SQL or the QueryExpression syntax. The SQL above is there just to explain the concept.
No, it doesn't permit this. Fetch XML is pretty limited when it comes to anything non-basic in joins. If I'm curious I usually test my query using Stunnware Tools. If it is not exposed there it probably can't be done.
Unfortunately, in situations like these these I usually end up (am forced into) taking a multiple query approach to the problem.
I know you said you're not interested in this - but I'm pretty sure QueryExpression won't handle it either. In my experience it only offers a subset of the fetchxml functionality.