Activity Forums Salesforce® Discussions What is Safe Navigation Operator in Salesforce ?

  • Kirandeep

    Member
    September 3, 2020 at 2:52 pm

    Safe Navigation Operator is introduced in Salesforce Apex Winter Release 21 to Avoid Null Pointer Exceptions.
    Example :-
    For example :-
    String profileUrl = null;
    if (user.getProfileUrl() != null) {
    profileUrl = user.getProfileUrl().toExternalForm();
    }
    / New code using the safe navigation operator
    <b role="presentation" style="font-family: inherit; font-size: inherit;">
    String profileUrl = user.getProfileUrl()?.toExternalForm();

  • Shweta

    Member
    September 3, 2020 at 6:26 pm

    Safe Navigation Operator: It is very useful for Salesforce Developers, and it will make their lives easy. By using this operator we can avoid null pointer exceptions.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos