Different navigations possible in LWC components

We know that we want to move from one page to other page in the web, and why not we could do that within the Salesforce Lightning web components a.k.a LWCs.
Below are the actions that we can perform to navigate from LWC components.

  1. Navigate to a web page like “https://sunilkhuwal.wordpress.com“, I like to give this url Meh. 😊😊
  2. Navigate to Object Home page like Account home page
  3. Navigate to Record Detail page like Account record Detail page(In your case it could any other object’s record page.
  4. Navigate to the Object List page, like Account List View page
  5. Navigate to file Preview
  6. While I am writing Salesforce might have introduced new mode of navigation in LWC.

We will discuss the code pattern individually for each of these styles. But before that just one thing that you need to do in the js file part. Keep note of the “LightningElement” should be encapsulated inside of the NavigationMixin like NavigationMixin(LightningElement) while exporting the default class

import { LightningElement } from "lwc";
import { NavigationMixin } from "lightning/navigation";
export default class NavigationServiceExample extends NavigationMixin(
  LightningElement
) {
   //Navigations method
}

Navigate to a web page like “https://sunilkhuwal.wordpress.com

I am keeping a one time html file to show how that would be called from. For rest of the examples only javascript should be enough, if you still have any issues you can comment here and I’ll respond to that.

<template>
  <lightning-card title="Navigation Examples">
    <div class="slds-p-around_medium">
      <lightning-button
        label="Open Sunil Web"
        onclick={openWebHandler}
      ></lightning-button>
    </div>
</lightning-card>
</template>
openWebHandler() {
    this[NavigationMixin.Navigate]({
      type: "standard__webPage",
      attributes: {
        url: "https://sunilkhuwal.wordpress.com"
      }
    });
  }

Navigate to Object Home page like Account home page

openAccountHandler() {
    this[NavigationMixin.Navigate]({
      type: "standard__objectPage",
      attributes: {
        objectApiName: "Account",
        actionName: "home"
      }
    });
  }

Navigate to Record Detail page like Account record Detail page

openAccountRecordHandler() {
    this[NavigationMixin.Navigate]({
      type: "standard__recordPage",
      attributes: {
        objectApiName: "Account",
        actionName: "view",
        recordId: "$recordId"
      }
    });
  }

Navigate to the Object List page, like Account List View page

openAccountListHandler() {
    this[NavigationMixin.Navigate]({
      type: "standard__objectPage",
      attributes: {
        objectApiName: "Account",
        actionName: "list"
      }
    });
  }

Navigate to file Preview

openFilePreviewHandler() {
    this[NavigationMixin.Navigate]({
      type: "standard__namedPage",
      attributes: {
        pageName: "filePreview"
      },
      state: {
        //The file record id has to be passed in here
        recordIds: "$fileId1,$fileId2",
        selectedRecordId: "$fileId1"
      }
    });
  }


Config file navigationExamples.js-meta.xml

<?xml version="1.0" encoding="UTF-8" ?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>51.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__RecordPage</target>
        <target>lightning__AppPage</target>
        <target>lightning__HomePage</target>
    </targets>
</LightningComponentBundle>

If you know any other type of navigations pls fill in the comments, so that we can update this post to help more people.


Peace 🤘

How to add lightning map marker and route in Salesforce

Those who wishes to create a lightning web component (LWC), to show case the google map and markers for showing the address. In this demo, I will show the map details taken automatically from account record detail page. The below code snippet and image picture will help in creating the map and route that can be integrated(route will be shown on Google map in a separate tab).

Map Marker with Driving directions that will open the route in a new tab.


The map is driven by three properties:
map-markers, zoom-level, center.

map-markers : We can use address or geo locations. In our example I will take the address field as very few times we know the exact geo location.

zoom-level: Show the level of zooming the map. Currently, Google Maps API supports zoom levels from 1 to 22 in desktop browsers, and from 1 to 20 on mobile devices.
center: Contains the marker address that will be centered while the map is shown with zoom-level

This is the mapMarker.html source code.

<template>
  <template if:true={mapMarkers}>
    <article class="slds-card">
      <div class="slds-card__body slds-card__body_inner">
        <template if:true={isAddressFound}>
          <lightning-map
            map-markers={mapMarkers}
            zoom-level={zoomLevel}
            center={centerLocation}
          >
          </lightning-map>
        </template>
        <template if:false={isAddressFound}>
          <lightning-map map-markers={mapMarkers} zoom-level={zoomLevel}>
          </lightning-map>
        </template>
      </div>
      <footer class="slds-card__footer">
        <lightning-button
          class="slds-m-top_medium slds-p-around_medium slds-p-top_medium"
          onclick={navigateToMap}
          label={drivingDirectionsLabel}
          disabled={isButtonDisabled}
          icon-name="utility:new_window"
          icon-position="right"
        ></lightning-button>
      </footer>
    </article>
  </template>
  <template if:false={mapMarkers}> Loading .... </template>
</template>

This is the mapMarker.js code:

import { LightningElement, wire, track, api } from "lwc";
import Id from "@salesforce/user/Id";
import getCurrentUser from "@salesforce/apex/AccountController.getCurrentUser";
import { NavigationMixin } from "lightning/navigation";
import { getRecord } from "lightning/uiRecordApi";

const fieldsArray = [
  "Account.Name",
  "Account.BillingStreet",
  "Account.BillingCity",
  "Account.BillingState",
  "Account.BillingPostalCode",
  "Account.BillingCountry"
];

export default class AccountMap extends NavigationMixin(LightningElement) {
  userLocation;
  accountLocation;
  accountAddressFound = false;
  userId = Id;
  zoomLevel = 16;
  billingStreet;
  billingCity;
  billingPostalCode;
  billingState;
  accountName;
  @track center;
  @api recordId;
  @track mapMarkers = [];
  @wire(getRecord, { recordId: "$recordId", fields: fieldsArray })
  wiredAccount({ error, data }) {
    if (data) {
      this.billingStreet = data.fields.BillingStreet.value;
      this.billingCity = data.fields.BillingCity.value;
      this.billingPostalCode = data.fields.BillingPostalCode.value;
      this.billingState = data.fields.BillingState.value;
      this.accountName = data.fields.Name.value;

      if (
        this.billingStreet ||
        this.billingCity ||
        this.billingPostalCode ||
        this.billingState
      ) {
        this.accountAddressFound = true;
      }

      //account information is stored here
      this.accountLocation = {
        location: {
          Street: this.billingStreet !== null ? this.billingStreet : "",
          City: this.billingCity !== null ? this.billingCity : "",
          PostalCode:
            this.billingPostalCod !== null ? this.billingPostalCod : "",
          State: this.billingState !== null ? this.billingState : "",
          Country: this.billingCountry !== null ? this.billingCountry : ""
        },
        title: this.accountName !== null ? this.accountName : ""
      };

      this.mapMarkers = [this.accountLocation];

      this.center = {
        location: {
          Street: this.billingStreet !== null ? this.billingStreet : "",
          PostalCode:
            this.billingPostalCod !== null ? this.billingPostalCod : ""
        }
      };
      this.error = undefined;
    } else if (error) {
      this.error = error;
      this.mapMarkers = undefined;
      console.error("ERROR => ", error);
    }
  }

  @wire(getCurrentUser, { userId: "$userId" }) currentUserDetail({
    data,
    error
  }) {
    if (data) {
      const mapMarkerLocation = {
        location: {
          Street: data.Street,
          City: data.City,
          PostalCode: data.PostalCode,
          State: data.State,
          Country: data.Country
        },
        title: data.Name,
        description: data.Name
      };

      //user location assigning
      this.userLocation = mapMarkerLocation;
      this.error = undefined;
    } else if (error) {
      this.error = error;
      this.mapMarkers = undefined;
      console.error("ERROR => ", error);
    }
  }

  navigateToMap(event) {
    event.stopPropagation();
    let routeMapUrl;
    const userLocationSet = new Set();
    const accountLocationSet = new Set();

    if (this.userLocation && this.userLocation.location) {
      try {
        if (this.userLocation.location.Street) {
          userLocationSet.add(this.userLocation.location.Street);
        }

        if (this.userLocation.location.City) {
          userLocationSet.add(this.userLocation.location.City);
        }

        if (this.userLocation.location.PostalCode) {
          userLocationSet.add(this.userLocation.location.PostalCode);
        }

        if (this.userLocation.location.State) {
          userLocationSet.add(this.userLocation.location.State);
        }

        if (this.userLocation.location.Country) {
          userLocationSet.add(this.userLocation.location.Country);
        }

        //Add account Location into Set
        if (this.accountLocation && this.accountLocation.location) {
          if (this.accountLocation.location.Street) {
            accountLocationSet.add(this.accountLocation.location.Street);
          }

          if (this.accountLocation.location.City) {
            accountLocationSet.add(this.accountLocation.location.City);
          }

          if (this.accountLocation.location.PostalCode) {
            accountLocationSet.add(this.accountLocation.location.PostalCode);
          }

          if (this.accountLocation.location.State) {
            accountLocationSet.add(this.accountLocation.location.State);
          }

          if (this.accountLocation.location.Country) {
            accountLocationSet.add(this.accountLocation.location.Country);
          }
        }
      } catch (e) {
        console.log("ERRR==>", e);
      }
    }

    if (
      userLocationSet &&
      userLocationSet.size > 0 &&
      accountLocationSet &&
      accountLocationSet.size > 0
    ) {
      routeMapUrl =
        "https://www.google.com/maps/dir/" +
        Array.from(userLocationSet).join("+") +
        "/" +
        Array.from(accountLocationSet).join("+");
    } else {
      //Error Toast to be shown
      routeMapUrl = "https://www.google.com/maps";
    }

    this[NavigationMixin.Navigate]({
      type: "standard__webPage",
      attributes: {
        url: routeMapUrl
      }
    });
  }

  get drivingDirectionsLabel() {
    let buttonLabel = "";
    if (this.accountAddressFound) {
      buttonLabel = "Driving Directions";
    } else {
      buttonLabel = "No Account Address Found";
      this.center = null;
    }
    return buttonLabel;
  }

  get centerLocation() {
    return this.center;
  }

  get isAddressFound() {
    return this.accountAddressFound === "Driving Directions" ? true : false;
  }

  get isButtonDisabled() {
    return !this.accountAddressFound;
  }
}

This is the code snippet of apex class

public with sharing class AccountController {
  //Get Current user details
  @AuraEnabled(cacheable=true)
  public static User getCurrentUser(String userId) {
    return [
      SELECT Id, Name, Street, City, State, PostalCode, Country
      FROM User
      WHERE Id = :userId
      WITH SECURITY_ENFORCED
    ];
  }
}

Health cloud – Medtech

Medtech Lifecycle

There are two types of Medtech devices

  • Diagnostic products, like an MRI scanner or a COVID-19 test kit, detect diseases or conditions.
  • Therapeutic products, like a knee replacement implant or an insulin pump, treat a condition or provide some form of therapy to patients

Also, there could be possibility that a medtech device can be combination of both Diagnostic and Therapeutic. For example Sugar monitor device that not only montiors the Sugar but also incase of the Sugar spikes it inserts the doses to suppress the sudden rise of Sugar.

Medtech concerns about following items

  • Safety and efficacy: Devices must be safe to use and‌ do what they claim. No company wants a recall or safety scandal, which is bad for patients and business. So quality is king.
  • Innovation and speed-to-market: The industry is a hotbed of innovation. Companies compete to launch better, more advanced devices faster than their rivals.
  • Cost-effectiveness: Healthcare systems and payers are very cost-conscious. A new gadget won’t be widely adopted if it’s excedingly high priced and doesn’t clearly improve care.
  • Market access and reimbursement: Even a brilliant device can flop if nobody will pay for it. Before launching a product, companies must ensure that payers will reimburse for it. This often means gathering solid clinical evidence that the device improves outcomes or is superior to existing solutions.
  • Global reach with local compliance: MedTech is a global business. A company in California might sell to hospitals across the world. This means navigating international regulations and varying healthcare systems. A successful MedTech company keeps an eye on global opportunities but also tailors strategies to local market needs and rules.

Medtech Products Category

  1. Implantable Devices
  2. Surgical Instruments
  3. Diagnostic and Imaging Systems
  4. Monitoring and Wearable Devices
  5. Durable Medical Equipment (DME)
  6. Medical Software and Health IT Systems

Device Classifications

  1. Class1 – Low risks (devices don’t require lengthy approval processes. Manufacturers might just register them and follow basic quality standards.)
  2. Class2 – Moderate Risks (Regulators usually require evidence that these devices are safe and work as intended, but often through a streamlined process.)
  3. Class 3 – High risks (these devices typically need rigorous premarket approval, which involves detailed review of clinical trial data and manufacturing processes. Regulators leave no stone unturned here because patient safety is on the line)

Regulatory Bodies: UnitedStates

Food and Drug Administration (FDA)

  • Class I devices are often exempt.
  • Class II typically requires 510(k) clearance (showing similarity to existing devices).
  • Class III demands full Premarket Approval (PMA) with clinical trials.
  • FDA offers fast-track programs for breakthrough devices.

Regulatory Bodies: Europe

EU Medical Device Regulation (MDR) with notified bodies (NBs)

  • Manufacturers work with accredited NBs to obtain a CE Mark for approval across EU member countries.
  • MDR enforces strict evidence and post-market surveillance requirements.
  • There’s no single EU equivalent to the FDA; instead, multiple entities oversee device reviews.

Regulatory Bodies: China

National Medical Products Administration (NMPA)

  • NMPA uses a risk-based system similar to both US and EU.
  • Class II and III devices require approval and often local testing or trials.
  • Timelines can be longer.
  • Local agents are required.
  • Alignment with international standards is increasing.

Regulatory Bodies: Others

  • Most use a risk-based approach.
  • Japan has improved speed via global harmonization.
  • Some countries recognize FDA/CE Mark approvals.
  • Global collaboration via The International Medical Device Regulators Forum (IMDRF) aims to align standards.

Peace ✌️

Health Cloud – Payer

The payers’ mission is to pay for care used by their members, and they do this by growing their membership numbers. More members equals more premiums collected, creating a larger pool of money to cover the cost of care. Payers also carefully manage medical costs and risks for their members.

Here are some of the activities a Payer does:

  1. Design medical insurance plans.
  2. Build networks of healthcare providers.
  3. Manage insurance benefits.
  4. Enroll groups and members in insurance plans.
  5. Process insurance claims.
  6. Process insurance premium payments.
  7. Engage members in wellness and care management programs.

The three things payers care about most are:

  • Affordability of care
  • Accessibility of care
  • Quality of care

Payer Products and Services

  1. Medical
  2. Dental
  3. Vision
  4. Pharmacy

Payer Customers

  1. Individuals: People who pay for their insurance out of their own pockets
  2. Government: Recipients of government-funded insurance such as Medicare, Medicaid, or military health systems
  3. Employers: Companies that provide benefits for their employees
  4. Labor Groups: Purchasing entities such as labor unions and retiree organizations

Peace ✌️

Salesforce Health Cloud Platform

Health Cloud verticals

  1. Provider
  2. Payer
  3. Medtech
  4. Pharmaceuticals
  5. Public Health
  1. Provider
    • Coordinates care and elevates patient experiences by connecting clinical data, social determinants, preferences, and more
    • Expands patient access in the home, online, or in-person with digital self-service tools on a secure platform
    • Strengthens provider relationships by improving collaboration with unified provider records
  2. Payer
    • Builds trust on a unified platform, including enrollment, service, care management, and beyond
    • Access to interventions with health data, utilization management, and customized care plans
    • Allows provider network management from one system, including recruitment, onboarding, and relationship management
  3. Medtech
    • Improve contract adherence and reduce revenue leakage through Sales Agreements and Advanced Account Forecasting
    • Improve field sales representative’s efficiency by reducing product expirations, accurately managing trunk and warehouse stock, and forecasting upcoming surgical case visits
    • Optimize the surgical case visit process to reduce the time needed to prepare and execute a case using standardized workflows
  4. Pharmaceuticals
    • Scales support programs to reduce operational costs and get more patients on therapy faster
    • Breaks down data silos to accelerate innovation and ensure compliance
    • Identifies patient and healthcare partners (HCP) insights with built-in analytics for personalized experiences
  5. Public Health
    • Transforms contact center and self-service interactions with a single source of truth for quicker resolutions and build trust
    • Optimizes team efficiency and agility with configurable workflows and digital collaboration tools across partners and programs
    • Provides actionable, data-driven insights by unifying health data across disparate systems and clinical data models and gives proactive, AI-driven recommendations

Developer Documentation link

https://developer.salesforce.com/docs/atlas.en-us.health_cloud_object_reference.meta/health_cloud_object_reference/object_ref_overview.htm

Platform Developer I Certification Maintenance Winter 26

Now as part of Winter 26, we can Unify Your Test Execution, both Apex tests and Flow tests can be seen in one single window

For completion please do following actions.

Login to Salesforce org and Click on All tabs and Select “Install a Package”

It would open like this below

Install for Admin only using the package id “04tNS000000EQYv”

Your screen would look like this

Now create a record Triggered flow in the org.

Triggering mechanism should be clearly specified like the below screenshot.

Flow should look like this and Label the flow name like “Account Update” and activate it.

Click on “View Tests” button as shown in below screen:

Then Set the Test Details, Trigger and path and Set Initial Triggering Record

Set assertions and click in Save Button:

Now Go to developer console and open Execute Anonymous window and execute the following command

RunTestsUsingToolingAPI.runAsynchronousTestsWithToolingAPI();

Now go to the setup section of the Salesforce and search for the “Application Test Execution”
This is the place where we can execute Tests related to Apex class and Flow in once single place

Note: If you see error in completing the challenge, then go to the Resource section within the Flow and update it to Plain Text and Save the flow as new version and activate it.

The idea here is that all the test should pass.

then Rerun the test either from Developer Console using “RunTestsUsingToolingAPI.runAsynchronousTestsWithToolingAPI();” or go to “Application Test Execution” section in the Salesforce Setup area.

and now you can check and complete your Challenge in the trailhead.

Happy to see your screen like this. Peace ✌️

Peace ✌️

Platform Developer Certification Maintenance (Winter ’26) – Part 1

Here are some new features added by Salesforce as part of the Winter 26

Handle Large External Service Callouts and Payloads Without Hitting Apex Heap Limits: Now you can make large api callouts that involves more data retrieval like pdf, images. Now with API version 65, you can upload or download binary files up to 16 MB without blowing through heap limits. This process uses ContentDocument as the storage mechanism. Therefore, the files remain accessible within Salesforce for auditing or reprocessing.

Elevate Third-Party Scripts with LWS Trusted Mode: With Trusted Mode now useful for integrating analytics libraries, advanced visualization frameworks, or other scripts that need direct access to the browser’s global context.

New Modules in LWC:

  1. lightning/graphql
    • Supports optional fields and dynamic query construction.
    • Recommended for all new GraphQL-based data fetching.
  2. lightning/omnistudioPubsub
    • Ideal for embedding OmniStudio wrapper components and enabling seamless interaction between components.
  3. Use LWC Components for Local Actions in Screen Flows
    • No need to make server calls and make the faster flows where we don’t explicitly require data to be fetched from Salesforce.

Some questions that might interests you.

  1. What is the key benefit of using pointers to ContentDocument object IDs for large callouts?
    • It avoids loading large payloads onto the Apex heap, preventing heap limit errors
  2. What access modifiers are supported for abstract and override methods in API version 65.0 and later?
    • Protected, Public, Global
  3. When should you enable LWS Trusted Mode for a Lightning web component?
    • Only for vetted third-party scripts that require global context access
  4. What advantage does the lightning/graphql module offer over lightning/uiGraphQLApi?
    • It supports optional fields and dynamic query construction
  5. Why use LWC local actions in screen flows?
    • They enable browser-based actions without consuming server resources

Peace ✌️

Different types of Prompt Builders Templates in SF

Here, we are going to see different types of Prompt Builders in SFDC.

  1. Case Details
  2. Field Generation
  3. Flex
  4. Global Standard
  5. Record Summary
  6. Sales Email
    • Requires “Einstein for Sales” to be enabled.
    • Permission set “Einstein Sales Emails” to be assigned
  7. Security Risk Analysis
  8. Slack Channel Summarizer

Note: When you need to use the prompt builder, you need to enable the Einstein from the setup, Here’s the below screenshot for reference.

  1. Case Details
  2. Field Generation
    • This prompt builder is used for adding the summary of multiple records of single object.
  3. Flex
    • This can be clubbed with the Flows, which means this can be used in the flows

I’ll add the details as progressed on the different prompt builders

Peace ✌️

How to classify the level of information assets?

Broadly we can classify

  1. General Business
  2. Restricted
  3. Highly Restricted
  1. General Business
    • Any data that, if disclosed to unauthorized individuals, could have a moderate detrimental impact on the company like
      • Company Policies
      • Business Card information (name, email, designation, phone number)
      • Employee id
    • As usual doesn’t require encryption
  2. Restricted
    • Any data that, if disclosed to unauthorized individuals, could have serious detrimental impact on the company as follows
      • Business continuity Plans
      • HR information: Performance reviews, succession planning, career information and organization charts
      • Audit reports
      • Sensitive personal information(Age, birth date, gender)
    • This data should be encrypted when shared or stored outside company network
  3. Highly Restrictive
    • Any data that , if disclosed to unauthorized individual, could have a severed detrimental impact on the company like
      • Intellectual property regarding the development of new business solutions,
      • Sensitive information regarding acquisitions or diversifications
      • Very sensitive persona information like race, religion etc.
    • This data should always be encrypted

Peace ✌️

What are different Types of Phishing Attacks?

Do you know how many types of Phishing Attacks are there in general. Lets get clarified here.

  1. Vishing
    • Vishing is a type of fraud that uses Phone systems to obtain private data from Organisations
    • Note: Vishing attacks are 3 times more effective than a classic phishing mechanism
  2. Smishing
    • Smishing is a type of phishing attack carried out over mobile text messagin
    • Many people are not as aware of smishing. Therefore, they may be more vulnerable to falling prey over text than email.
  3. Social Media Phishing
    • Social Media Phishing is an attack executed through platforms like facebook, Instagram, Snapchat or LinkedIn.
    • In 2021, 75% of organizations were targeted by Social media phishing attacks.
  4. Spear Phishing
    • Spear Phishing focuses on WHO is being phished(a specific indivual, organization or busines) and can occur across any phishing type(smishing or vishing etc)
    • Spear phising email recipients are 10 times more likely to select the link than genral phishing email recipients.

Social Engineering

When you post about your work -related content on Social media then you may expose the work related critical information which is easier of the cyber criminals to target you on retrieving the information about you to personalize and better target their hacking attempts

LinkedIn

When you get a request from someone, check

  1. The user has genuine profile picture
  2. Check in your internal emails that this connection is working in your company or not.
  3. Check if the number of connections is oddly low.
  4. Check that they have posts.
  5. Check that their profile has enough information about the current and previous experiences and their interactions of the previous employees.

Peace ✌️