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

Popular Salesforce Videos