You are here:
Extending a Template to Create a Custom LWC Card State Template (Managed Package)
For the managed package runtime, extend an existing template to create a custom LWC card state template. For example, use the CardActiveState LWC template to overwrite methods and HTML templates.
Before extending a template:
This information is for Omnistudio for Managed Packages. For Omnistudio on standard runtime, see Omnistudio Help.
- See Set Up Lightning Web Components (Managed Package).
- Create a component in your local development environment. See Create Lightning Web Components.
Update the JS File
To see what methods can be overwritten for your extended component, view its ReadMe file.
- In the JS file, import the LWC template you want to extend from your Vlocity namespace. See Viewing the Namespace and Package Version of Omnistudio for Managed Packages (Managed Package).
- Import your custom HTML template.
-
To overwrite the HTML template of the extended LWC template, use the
render()method to return your custom HTML template. -
Confirm that your class declaration has the
extendskeyword.
This example overwrites the render() method that
returns the HTML template, and the trackInteraction() method that tracks interactions.
import { LightningElement,track } from "lwc";
import cardActiveState from "vlocity_ins/cardActiveState";
import temp from "./customCardActiveState.html";
export default class customCardActiveState extends cardActiveState{
// your properties and methods here
render() {
return temp;
}
trackInteraction(event) {
let element = event.target;
// custom code
}
}
Create the HTML Template
This example shows a basic card that extends the CardActiveState LWC template. The template shows how to reference Vlocity base components, such as Icon LWC.
<template>
<div if:true={selectedState} class="slds-p-top_small">
<div class="slds-card via-slds-card--active slds-m-bottom--small">
<table class="slds-card__body slds-p-around-small slds-wrap slds-theme--default slds-p-around--medium">
<tr key={field.name} class="slds-tile slds-p-bottom--medium" for:each={state.fields} for:item="field"
for:index="index" onmouseleave={resetIcon}>
<td key={field.name} class="slds-col slds-truncate slds-text-heading--label slds-p-right_large"
title={field.label}>
{field.label}
</td>
<td key={field.label} class="slds-col slds-tile__detail slds-text-heading--small">
<vlocity_ins-output-field record={obj} field-name={field.name} type={field.type}>
</vlocity_ins-output-field>
</td>
<td class="slds-col slds-tile__detail slds-text-heading--small">
<vlocity_ins-icon data-fieldindex={index} onclick={trackInteraction} icon-name="utility:preview"
class="trackIcon" size="small"></vlocity_ins-icon>
</td>
</tr>
</table>
</div>
</div>
</template>
Update the Metadata XML File
This example shows an LWC configured for visibility on a record page, app page, and home page.
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>46.0</apiVersion>
<isExposed>true</isExposed>
<masterLabel>customCardActiveState</masterLabel>
<runtimeNamespace>vlocity_ins</runtimeNamespace>
</LightningComponentBundle>

