问题
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?
回答1:
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
来源:https://stackoverflow.com/questions/55536422/loading-data-from-dynamics-crm-to-sql-server