Activity Forums Salesforce® Discussions What is Safe Navigation Operator in Salesforce ? Reply To: 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();