You need to sign in to do that
Don't have an account?
Jonathan Bissell 3
Prepopulating Field Values from Record to Screen Flow to LWC
<template> <lightning-input label="Sold Production" name="num1" onchange={SoldProduction} required> </lightning-input> <lightning-input label="Design Production" name="num2" onchange={DeisgnProduction} required> </lightning-input> <lightning-button label="Calculate Production Differnce" onclick={calcExpr}></lightning-button> <lightning-input label="Result" name="result" read-only="true" value={result}> </lightning-input> </template>.js
import { LightningElement, api, track } from 'lwc'; import {FlowAttributeChangeEvent,FlowNavigationNextEvent} from 'lightning/flowSupport'; export default class calculator extends LightningElement { @track num1; @track num2; @track result; @api result; @api num1; @api num2; @api required; calcExpr() { this.result = (Number(this.num1) - Number(this.num2)) / ((Number(this.num1) + Number(this.num2))/ 2); } SoldProduction(evt) { this.num1 = evt.target.value; } DeisgnProduction(evt) { this.num2 = evt.target.value; } }xml:
<?xml version="1.0" encoding="UTF-8"?> <LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata"> <apiVersion>47.0</apiVersion> <isExposed>true</isExposed> <masterLabel>Calculator</masterLabel> <description>Calculator to find percentage</description> <targets> <target>lightning__FlowScreen</target> </targets> <targetConfigs> <targetConfig targets="lightning__FlowScreen"> <property name="result" type="Integer" /> <property name="num1" type="Integer"/> <property name="num2" type="Integer"/> <property name="required" type="Boolean" default="true"/> </targetConfig> </targetConfigs> </LightningComponentBundle>Values:
- I have two numbers from a record "num1" and "num2"
- I am not sure how to take these two values and use them as default values when the LWC loads.
- Once the values change the dafault values should not be used.
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>55.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__FlowScreen</target>
</targets>
<targetConfigs>
<targetConfig targets="lightning__FlowScreen">
<property name="recordId" type="String" label="Id of the Record"></property>
<property name="objectName" type="String" label="Name of the object"></property>
</targetConfig>
</targetConfigs>
</LightningComponentBundle>
Try this i hope it's work for you.. https://www.mymorri.net/