+ Start a Discussion
SnowMoreSnowMore 

Delete fails with no error message

When a user has insufficient privileges to delete a record -- say, an opportunity owned by someone else -- the delete fails but there's no error message. The following code is straight out of the Office Tolkit VB code sample:

 

          On Error GoTo handleError
          Dim MyOppObject(1) As SObject3
          Set MyOppObject(0) = g_sfApi.CreateObject("opportunity")
          MyOppObject(0)("id") = MyID

          g_sfApi.Delete MyOppObject, False

 

 

But no error is triggered when the delete fails due to insufficient privileges.

 

Any ideas  on how to trap this condition?

SuperfellSuperfell
You have to look at the error related properties on myOppObject.
SnowMoreSnowMore

That's not the answer.  the following lines of code:

 

          MsgBox MyOppObject(0).Error
          MsgBox MyOppObject(0).ErrorMessage

 

return error code 0 and an empty string for error message, regardless of whether the object was successfully deleted or not.

 

 

The on-line documentation says the following: 

Deleting objects involves the following basic steps:

  1. Determine the ID of each object that you want to delete. For example, you might call query() to retrieve a set of records that you want to delete based on specific criteria.
  2. Construct an ID[] array and populate it with the IDs of each object that you want to delete. You can specify the IDs of different objects. For example, you could specify the ID for an individual Account and an individual Contact in the same array. For information on IDs, see ID Field Type.
  3. Call delete(), passing in the ID[] array.
  4. Process the results in the DeleteResult[] to verify whether the objects have been successfully deleted.

It's step 4 that I can't figure out.  There's sample code for Java and C#, but nothing for VB.  And there's no mention at all of DeleteResult in the Office Toolkit documentation.

SuperfellSuperfell
You should probably move your question to the office & vb board, where the officetoolkit folks hang out.