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
Garry LindsayGarry Lindsay 

Cannot delete Lead record

Here is the code

  soql = "Select ikap_applicant_id__c from Lead Where ikap_applicant_id__c = '489852'"

  Set qrs = p_sfdc.Query(soql, False)
  
  strError = "There is no sForce field that exists with Key Field : " & strSForceKeyField
  
  If p_sfdc.Error = NO_SF_ERROR Then
   For Each sobj In qrs
    Response.Write("Deleting <b> " & strFullName & "</b>, applicantID : <b>" & applicantID & "</b> record in SalesForce...<br>")
    Response.Flush 
    
    sobj.Delete >>>>>>>>>>>>> line 362
    sobj.Refresh
    
    bRet = TRUE
   Next
  Else
   strError = "There was an error during the query operation." & vbCrLf & vbCrLf & p_sfdc.ErrorMessage
   bRet = FALSE
  End If

Here is the result

Communicating with SalesForce Web Service. This may take a 1 to 10 minutes... Please wait...

Deleting Elizabeth Jones, applicantID : 489852 record in SalesForce...

SForceOfficeToolkit.SObject.1 error '80004005'

org.xml.sax.SAXParseException: XML document structures must start and end within the same entity.

/appsynthesis/backendmanager/includes/classes/sForce/clssForceHelper.asp, line 362

 

 Any ideas?

Cheers

Garry

ScotScot

Garry,

I'm not sure HOW to use sobj.delete - that is, the delete method on an Sobject - though the way you're trying it seems reasonable to me.

The approach I've seen used sucessfully is closer to p_sfdc.delete - that is, the delete method on an SforceSession object, with an array of Sobjects as an argument ... as in the following code adapted from the Excel Connector:
       (where sfApi is a SforceSession)

   Dim sa() As SObject  ' build array of sobjects from the query
     ReDim sa(2000)
     x = 0
     For Each s In qrs
     Set sa(x) = s
          x = x + 1
     Next s
     ReDim Preserve sa(x - 1)
    
    sfApi.Delete sa, False  ' delete them
   
    If sfApi.Error > 0 Then
        DoDelete = False
    Else
        DoDelete = True    
    sfApi.Refresh sa, False

Scot

Garry LindsayGarry Lindsay

Thanks, I allready tried this method first and it failes, here is that code :-

  Set qrs = p_sfdc.Query(soql, False)
  
 
  If p_sfdc.Error = NO_SF_ERROR Then
   Dim sa()  ' build array of sobjects from the query
   ReDim sa(2000)
   x = 0
   For Each s In qrs
    Set sa(x) = s
    x = x + 1
   Next
   ReDim Preserve sa(x - 1)
     
      Response.Write "x = " & x & "<br>"
     
      If x > 0 THEN
    p_sfdc.Delete sa, False  ' delete them >>>>>>>>>>>>>>> line 386
      
    If p_sfdc.Error = NO_SF_ERROR Then
     Response.Write("Deleting <b> " & strFullName & "</b>, applicantID : <b>" & applicantID & "</b> record in SalesForce...<br>")
     Response.Flush 
     
     bRet = TRUE
    Else
     strError = "There was an error during the query operation." & vbCrLf & vbCrLf & p_sfdc.ErrorMessage
     bRet = FALSE
    End If  
    sfApi.Refresh sa, False
   Else
    strError = "There is no sForce field that exists with Key Field : " & strSForceKeyField
   End If
  Else
   strError = "There was an error during the query operation." & vbCrLf & vbCrLf & p_sfdc.ErrorMessage
   bRet = FALSE
  End If  

And here is the error

Communicating with SalesForce Web Service. This may take a 1 to 10 minutes... Please wait...

x = 1

SForceOfficeToolkit.SForceSession.1 error '80004005'

Failed to build query CSForceSession:oCreateUpdateRefreshDelete

/appsynthesis/backendmanager/includes/classes/sForce/clssForceHelper.asp, line 386

ScotScot

Bummer.  I'm out of ideas ... I think you'll need someone else to help you ...

    sforce guys?

foghornfoghorn

Seems to be a problem with the sql parsing....

For now, just use select *.   We have a patch release going out today, I'll see if I can get qa to let me fix it.

Sorry!

 

foghornfoghorn

Really what is happening is that if you give a list of select fields and don't include id it breaks.

So, until I fix it, either use select * or include id.

Garry LindsayGarry Lindsay

Which field is the ID for the Lead object?

 

Cheers

Garry

Garry LindsayGarry Lindsay

OK, let me know when the patch DLL is available.

Select * from Lead where field = "value" seems to fail? I get a malformed query error!

Cheers

Garry

foghornfoghorn

Humm.  Are you doing something like this?

set qr = session.Query("select id,Lead_String__c from lead where Lead_String__c='abc'",false)

or this?

set qr = session.Query("select * from lead where Lead_String__c='abc'",false)

 

Garry LindsayGarry Lindsay

I got this too work

set qr = session.Query("SELECT ID, ikap_applicant_id__c FROM Lead WHERE ikap_applicant_id__c = '489868'", false)

for about 3 days, then suddenly I got this error today

SForceOfficeToolkit.SQueryResults.1 error '80004005'

sObject type 'CT' is not supported.

I rebooted the server and still got the error!

Any ideas?

Garry

DevAngelDevAngel
Hi Garry,

Try using a lowercase from.