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
Igor Androsov 22Igor Androsov 22 

Set Record Type on generic SObject

I want to update a Record Types on any Sobject regardless what type it is and seem not able to find correct API in APEX
Did try Describe calls that does not do it like this one
sObject sObj = Schema.getGlobalDescribe().get(ObjectName).newSObject() ;

Code below will be great if it worked, in Winter 18 has Syntax errors and methods are not found.

SObject record = Id.valueOf('a0Ci000000vd7xA').getSObjectType.newSObject();
record.put('RecordTypeId', <place ID object here>); 

Any other ideas that do work!