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
phoadesymcphoadesymc 

Problems changing record types on custom objects via S-Control

I am trying to use an S-Control (see below) to change the record type on a custom object. reusing code that has worked in the passed for standard objects. updated to beta 3.3 but am getting the error 'uncaught exception: The property RecortTypeID is not a valid field'in Firefox debug window

Is updating record types on custom objects now supported?

Thanks
Paul

var currentRecordType = "{!Rebates_Approval_RecordType_ID}";

var newRecordType = "";
alert(currentRecordType);
// Switch record type from read/write to read only
if (currentRecordType == "012300000004nqS") {
newRecordType = "012300000004nqSAAQ";
}
sforceClient.init("{!API_Session_ID}", "{!API_Partner_Server_URL_60}");

var myObj = new Sforce.Dynabean("Rebates_Approval__c");
myObj.set("Id", "{!Rebates_Approval_ID}");
myObj.set("Justification__c", "yyyyyyyyy");
myObj.set("Status__c", "Submitted");
myObj.set("RecordTypeId", newRecordType);

var saveResults = sforceClient.Update([myObj]);

if (Sforce.Util.dltypeof(saveResults) != "array") {
alert ("Update Returned: " + saveResults.toString());
return false;
}
else
return true;
}
devNut!devNut!
Hello,

I am experiencing the same issue...

Has a solution been found for this problem? 

 

 

Thanks.

SteveBowerSteveBower
I'm using the 7.0 endpoint and the 3.3 beta of the Ajax toolkit, and yes, I can change record types to my hearts content with no troubles.  -Steve.

devNut!devNut!

Hi Steve,

I believe I am using the same...


<script src="https://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js" type="text/javascript"></script>

with

sforceClient.init("{!API_Session_ID}", "{!API_Partner_Server_URL_70}");
 

Would you mind posting a snippit of code to where you issue an update for the "record type" of a record?

Thanks..

Message Edited by devNut! on 05-11-2006 05:39 AM

SteveBowerSteveBower
Sure DevNut, hope this helps... Steve.

Code:
// In this example:
// The name of the record type I'm trying to set is "order" and 
// it's defined as one of the opportunity record types.

// Find the id of the specified record type from the recordtype table.
var q = "select id, name, sobjecttype from recordtype where sobjecttype = 'opportunity' and Name ='order'";
var rectype = sforceClient.Query(q);
if (Sforce.Util.dltypeof(rectype) != "QueryResult" || 
                                 rectype.size <= 0 || 
                                 rectype.records.length <= 0) {
    err("Error getting ID for 'Order' record type.\nresult = " + rectype);
} else {
    // Presuming I found it, use it to set the RecordTypeID in 
    // oppRec  (Which came from an earlier: oppRec = new Sforce.Dynabean("Opportunity");)
    try {
        // Note that rectype has records which is an array of the
        // records returned from the query.  This should only be one
        // record if you did the query correctly, so just use the first
        // element to get the Id.
 oppRec.set("RecordTypeId",rectype.records[0].get("Id"));
    } catch (e) {
        err("Exception setting Record Type of opportunity.\n" + e);
    }
}