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
gorky2gorky2 

Classic ASP: Error Updating records

It seems I have followed the instructions I found in the forum, but sforce returns me an error when I call the update method. My code is this one:

'begin code

Set SforceApi = server.CreateObject("SForceOfficeToolkit.SForceSession")

if SforceApi.Login(login,password,false) then

             strSQL="Select AccountNumber, Description, Id, Name from Account where Id='fakedid'"

             set queryResults = SforceApi.Query(strSQL, False)

             for each sobj in queryResults

                sobj.Item("Description").Value = "testing"

                Response.Write sobj.Item("Id").Value &","&sobj.Item("Name").Value &","&sobj.Item("AccountNumber").Value &","& sobj.Item("Description").Value

               SforceApi.Update queryResults,false      'here fails

            next

end if

'end code

the error I get is this one:

               error '800706be'

it works properly, retrieving a record, accessing its properties, changing them (in memory) but fails when I try to upload that record on salesforce.

 

Can anyone help me?

 

thanx

foghornfoghorn
Couple of problems.

Your query is trying to find an account with id = "fakedid" which should not return results, but apparently it is?

Then your trying to update the queryresults object. The method takes an array of objects....

You might want to msgbox the errormessage, is most times more useful.
Ron HessRon Hess
as foghorn points out, the query result set is an Enumeration, NOT an Array,
you must use the enumeration to construct an array before passing to Update.

You can see the data types using the Object Browser in most microsoft languages.

so a function like this may help convert a query result set into an array of sobjects which can then be passed to Update()

Public Function SObjectArray(ByVal qr As QueryResultSet3) As Object
Dim sa() As SObject3
ReDim sa(2000)

For Each s In qr
Set sa(x) = s
x = x + 1
Next s

ReDim Preserve sa(x - 1)
SObjectArray= sa
end function


this is VBA, but should work in basic also