Activity Forums Salesforce® Discussions How can you update Salesforce record using Apex, when you don’t know Object API name, but you know record Id?

  • shariq

    Member
    September 22, 2018 at 6:02 PM

    Using Dynamic Apex we can achieve this :

    //Lets assume this is record Id
    Id recId = 'a0P9000000ESXcV';
    Schema.SObjectType token = recId.getSObjectType();
    Sobject s = token.newSobject();
    s.put('Id',recId );
    s.put('Name', 'om');
    update s;

Log In to reply.

Popular Salesforce Blogs

Top Salesforce Career Paths to Watch in 2026

Blog in

The Salesforce ecosystem continues to evolve rapidly, driven by advancements in AI, automation, data intelligence, and industry-specific cloud solutions. As businesses increasingly rely on Salesforce…

Popular Salesforce Videos