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();

  • [adinserter block='9']
  • 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.