locked
Checking the status of an import job on a custom ISV Page. RRS feed

  • Question

  • Hi all,

    I'm trying to use a custom ISV page to perform a data import and I've got it all working except once the import has completed I can't check whether all the records in the import have actually been imported.

    I can query the status of the import, however it seems regardless of how many records get imported, the import job still succeeds.

    I do this by:

    	 ColumnSet cols = new ColumnSet();
       cols.Attributes.Add("statuscode");
    
       QueryExpression importQuery = new QueryExpression();
    
       ConditionExpression checkSystemJob = new ConditionExpression();
       checkSystemJob.AttributeName = "name";
       checkSystemJob.Operator = ConditionOperator.Equal;
       checkSystemJob.Values = new object[] { importName };
    
       FilterExpression filter = new FilterExpression();
       filter.FilterOperator = LogicalOperator.And;
       filter.Conditions.Add(checkSystemJob);
    
       importQuery.EntityName = "import";
       importQuery.ColumnSet = cols;
       importQuery.Criteria = filter;
    
       RetrieveMultipleRequest iRequest = new RetrieveMultipleRequest();
       iRequest.Query = importQuery;
       iRequest.ReturnDynamicEntities = true;
    
       BusinessEntityCollection importCollection = ((RetrieveMultipleResponse)service.Execute(iRequest)).BusinessEntityCollection;
    
    
       /*if (importCollection.BusinessEntities.Count == 1)
       {
       foreach (DynamicEntity importJob in importCollection.BusinessEntities)
       {
        Status status = (Status)importJob.Properties["statuscode"];
        if (status.Value.ToString() == "Completed") result = "Import Successful.";
        else result = "Import failed, please check CRM Import Job for more information or contact your system administrator.";
       }
    
       }
    
       result = "Import successful.";
    
    

     

    Is there a way to check the number of records I was trying to import and the number of records actually imported so I could give more meaningful information?

    Wednesday, September 29, 2010 11:10 PM

Answers