function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
DMDM 

Unable to delete records from a custom object

Hi,

I am currently unable to delete records from a custom object created in both the enterprise and developer editions. I can login successfully and insert records.

 As of last week, the code that I hade to delete records from this custom object worked but today for some reason I am getting errors.

Any help would be appreciated.

The custom object is called cognos. The Java 1.4 code I created is based on the Java API 2.5 samples.

queryIds() retrieves an array of ID which is used by deleteCognos()

I can successfully retrieve an array of record IDs but when the API delete operation is called inside deleteCognos() I get errors. I retrieve the user ID as a way, for me, to diferentiate between each record. Its not used by deleteCognos().

This is some sample output:

Record 0: a00300000000IVEAA2 User Id: alan.brothers@aliant.ca
Record 1: a00300000000IVFAA2 User Id: alden.parker@aliant.ca
Record 2: a00300000000IVGAA2 User Id: andrew.bourque@aliant.ca
Record 3: a00300000000IVJAA2 User Id: alan.brothers@aliant.ca
Record 4: a00300000000IVKAA2 User Id: alden.parker@aliant.ca
Record 5: a00300000000IVLAA2 User Id: andrew.bourque@aliant.ca

ErrorStatus Code: INVALID_ID_FIELD
Error message invalid record id for this type

ErrorStatus Code: INVALID_ID_FIELD
Error message invalid record id for this type

ErrorStatus Code: INVALID_ID_FIELD
Error message invalid record id for this type

ErrorStatus Code: INVALID_ID_FIELD
Error message invalid record id for this type

ErrorStatus Code: INVALID_ID_FIELD
Error message invalid record id for this type

ErrorStatus Code: INVALID_ID_FIELD
Error message invalid record id for this type

When I ran my code today it stopped after 6 records but there are 92 in the object.

I downloaded the latest enterprise wsdl and recompiled it but that didn't help.

 private ID[] queryIds(){

  QueryResult qr = null;
  _QueryOptions qo = new _QueryOptions();
  qo.setBatchSize(new Integer(40));
  binding.setHeader("SoapService", "QueryOptions", qo);
  ID[] cog_ids = null;
  

  try
  {
   qr = binding.query("select id, user_id__c from cognos__c");

   if (qr.getSize() != 0)
   {
    boolean bContinue = true;
    int loopCount = 0;
    
    
    
    while (bContinue)
    {
        for (int j=0; j        {
          
     //System.out.println("Record " + loopCount + " id " + (qr.getRecords()[j]).getId().getValue());

     //save the cognos ids in a class array
     // resize array as needed
     if(loopCount == 0)
     {
        cog_ids = new ID[]{(qr.getRecords()[0]).getId()};
        System.out.println("Record " + loopCount + ": " + (cog_ids[0].getValue()) +" User Id: "+ ((Cognos__c)qr.getRecords()[0]).getUser_ID__c()); 
     }else{
        ID[] tempCog_ids = null;
        tempCog_ids = new ID[cog_ids.length + 1];
        for (int i = 0; i < cog_ids.length; i++)
      tempCog_ids[i] = cog_ids[i];
     
         tempCog_ids[cog_ids.length] = (qr.getRecords()[j]).getId();
         cog_ids  = tempCog_ids;
         System.out.println("Record " + loopCount +": " + (cog_ids[loopCount].getValue())+" User Id: "+ ((Cognos__c)qr.getRecords()[j]).getUser_ID__c());
     }  
     loopCount++;
     
     
         } 
     if (qr.isDone())
     {
      bContinue = false;
      //System.out.println("Stop");
            }else{
            qr = binding.queryMore(qr.getQueryLocator());
            //System.out.println("Query More");
     }    
          }
    
   }else{
    System.out.println("\nThere are no Cognos records stored.");
    getUserInput("\nHit return to continue..."); 
   }


       // System.out.println("\nQuery succesfully executed.");
     //   getUserInput("\nHit return to continue...");
           
                      } catch (UnexpectedErrorFault uef) {
                              System.out.println(uef.getExceptionMessage());
                      } catch (Exception ex)
  {
   System.out.println("\nFailed to execute query succesfully, error message was: \n"
        + ex.getMessage());
   ex.printStackTrace();
   getUserInput("\nHit return to continue...");
  }
       return cog_ids;

}
    

private void deleteCognos() {
if (!loggedIn) {
  if (!login())
 return;
}
  
try { 
 ID[] cognos_ids = queryIds();
 DeleteResult[] deleteResults = binding.delete(cognos_ids);
    // Process the results
    for (int i=0;i       DeleteResult deleteResult = deleteResults[i];
       // Determine whether delete succeeded or had errors
       if (deleteResult.isSuccess()) {
          // Get the id of the deleted record
          System.out.println("Successfully deleted " +deleteResult.getId());
        }else {
        
         Error[] errors = deleteResult.getErrors();
         for(int k = 0; k < errors.length; k++){
    System.out.println("\nErrorStatus Code: " + errors[k].getStatusCode().toString()); 
    System.out.println("Error message " + errors[k].getMessage());

 

 }
  
      }
   }

} catch (UnexpectedErrorFault uef) {
         System.out.println(uef.getExceptionMessage()); 


}catch (RemoteException ex) {
 System.out.println("\nFailed to succesfully delete Cognos records, error message was: \n" + ex.getMessage());
 getUserInput("\nHit return to continue...");
   }  


}

Message Edited by DM on 04-12-2004 11:59 AM

DevAngelDevAngel

Hi DM,

Thanks for you post.  We have identified the problem and are working on a fix.  I anticipate the issue to be resolved by the end of the day tomorrow (April 13th).