Activity Forums Salesforce® Discussions How to access filed token in salesforce?

  • Nikita

    Member
    September 13, 2019 at 5:42 am

    Hi Piyush,

    To access the token for a field, use one of the following methods:

    Access the static member variable name of an sObject static type, for example, Account.Name.
    Call the getSObjectField method on a field describe result.
    The field token uses the data type Schema.SObjectField.

    In the following example, the field token is returned for the Account object's Description field:

    Schema.SObjectField fieldToken = Account.Description;
    

    In the following example, the field token is returned from the field describe result:

    // Get the describe result for the Name field on the Account object
    Schema.DescribeFieldResult dfr = Schema.sObjectType.Account.fields.Name;
    
    // Verify that the field token is the token for the Name field on an Account object
    System.assert(dfr.getSObjectField() == Account.Name);
    
    // Get the describe result from the token
    dfr = dfr.getSObjectField().getDescribe();

     

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos