function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jonathan Bissell 3Jonathan 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"
Problem:
  • I am not sure how to take these two values and use them as default values when the LWC loads. 
Goal:
  • Once the values change the dafault values should not be used. 


 
Eric Morgan 10Eric Morgan 10
<?xml version="1.0" encoding="UTF-8"?>
<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/
Jonathan Bissell 3Jonathan Bissell 3
This does not help, I do not need recordId or Object Name. I'm a looking for Num1 & Num2 Input
Jonathan Bissell 3Jonathan Bissell 3
I notice that the values of Num1 and Num2 are populating correctly, but the values are not being displayed in the HTML.