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
Peter UchytilPeter Uchytil 

Classic ASP: Can't update RecordTypeID

First point: when I do a search on the message boards, I get results for the VB & Office development boards, but those don't seem to exist anymore so I can't access the messages. Do a search for "recordtypeid api" to see the results which reference these boards. I looked around but I must have missed the notice that these boards are no longer available. That's too bad.

My problem: when trying to update the RecordTypeID of an Opportunity record, I get the error "insufficient access rights on cross-reference id". I can update fields like the StageName, but not RecordTypeID, eventhough the login I am using has edit rights to the RecordTypeID field.

My code snippet:

Code:
 
soql = "SELECT * FROM Opportunity WHERE Id='" & Id & "'"
set qr = sfObj.query(soql,false)
If NOT qr.Error > 0 Then
    For Each v in qr
        v("RecordTypeId").value = getRecordTypeId( "MVP Prospect" )
        v.update
    Next
End if

The error occurs on the v.update line. Any suggestions? Thanks!

Pete

Peter UchytilPeter Uchytil
Just to let people know, I fixed the problem. I forgot that when querying RecordTypeID, multiple objects can have RecordTypes with the same name. Instead of just doing a query on the RecordType name, I needed to do a query on the name plus object type.
soql = "SELECT id FROM RecordTypes WHERE name='MVP Prospect' AND 
        sobjecttype='Opportunity'"

 Without specifying the sobjecttype, I was getting the RecordType for an Account and trying to assign it to an Opportunity. Oops.