Hi,
I am trying to import data from a csv file programmatically.
For that, I am using crmserviceclient to connect to my application and creating 'Import' entity like this:
CrmServiceClient crmSvc = new CrmServiceClient(ConfigurationManager.ConnectionStrings["MyDynamicsWebJobCon"].ConnectionString);
IOrganizationService service;
service = (IOrganizationService)crmSvc.OrganizationWebProxyClient != null ? (IOrganizationService)crmSvc.OrganizationWebProxyClient : (IOrganizationService)crmSvc.OrganizationServiceProxy;
OrganizationServiceContext orgContext = new OrganizationServiceContext(service);
// Create the Import
Entity import = new Entity("import");
import.Attributes.Add("modecode", new OptionSetValue(0));
import.Attributes.Add("name", "CustomEntityDataImport");
import.Attributes.Add("sendnotification", false);
import.Id = service.Create(import);
Console.WriteLine(import.Id);
Console.ReadLine();
Not sure why am I not seeing this created import record in my application. When I debug, I do see the guid of the created import record but I can't find it in the application.
I am working on Dynamics 365 Online. Can somebody please guide me in finding this missing record? I can't 'advanced find' it either.
Thanks for any help!
Please use the entity imports
../api/data/v9.1/imports
Best Regards
PG
To create a data import, you need to create an importfile record as well as an import record. The Imports section of the application is actually a list of importfile records that are linked to an import record.
Note that I think you'll also need to set the isimport attribute on the import record that you create.
For reference, the following fetchxml is the query used to display 'My Imports' in the application
<fetch version="1.0" output-format="xml-platform" mapping="logical">
<entity name="importfile">
<attribute name="name" /><attribute name="statuscode" /><attribute name="createdon" /><attribute name="createdby" /><attribute name="importfileid" /><attribute name="successcount" /><attribute name="partialfailurecount" /><attribute name="failurecount" /><attribute name="totalcount" />
<order attribute="createdon" descending="true" />
<link-entity name="import" from="importid" to="importid" alias="isimport" visible="false"><filter type="and"><condition attribute="isimport" operator="eq" value="1" /></filter></link-entity>
<filter type="and"><condition attribute="ownerid" operator="eq-userid" /><condition attribute="filetypecode" operator="neq" value="2" /></filter>
</entity>
</fetch>
Thanks Pankaj.
Yes, I have tested other code with the same connection string. It is working fine.
I looked at web api query, i didn't find any record. What entity should I be querying for to get the newly created import record? I see only 3 import entities(importdataset, importfiles, importmaps).
Hello Meenoo,
Verify if you are connecting to the Correct Dynamics 365 instance.
Use the Web API query and see if you get the record.
https://<<yourcrm>>/api/data/v9.0/entitynames(guid)
Best Regards
PG
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156