0

I am trying to show stage picklist values of opportunity object through lwc but iit shows error Invalid reference Opportunity.Stage of type sobjectField in file lwcPicklistOppor.js

here is my code

<template>
    <div class="side-box">
        <template if:true={StageValues.data}>
           
            <lightning-combobox value={value} label="Opportunity Stage" onchange={handleChange} options={stageValues.data.values}
                name="progress"> </lightning-combobox>
            </template>

    </div>

    
</template>

import { LightningElement,wire } from 'lwc';
import OPPORTUNITY_OBJECT from '@salesforce/schema/Opportunity';
import { getPicklistValues } from 'lightning/uiObjectInfoapi';
import Stage from '@salesforce/schema/Opportunity.Stage';
import { getObjectInfo } from 'lightning/uiObjectInfoapi';

export default class LwcPicklistOppor extends LightningElement {
    @wire(getObjectInfo, { objectApiName : Opportunity_OBJECT})
    opportunityinfo;
    @wire(getPicklistValues,
        {
            recordTypeId: '$opportunityinfo.data.defaultRecordTypeId',
            fieldApiName: Stage
        }
    )
    StageValues;

}

1 Answer 1

0

The Opportunity Stage field is actually called StageName:

import Stage from '@salesforce/schema/Opportunity.StageName';

You can, and should, check the documentation (e.g. Opportunity) and/or Setup in your org to find a field's name.

4
  • Thank You ...it removes the error but now when i deploy this to org it gives unknown Exception Commented Apr 20, 2021 at 11:18
  • @ShivaniTanwar Not sure what to say about that. You may need to use a reactive variable that gets set by the getObjectInfo call.
    – sfdcfox
    Commented Apr 20, 2021 at 11:53
  • Could you please show me how can i do this? Commented Apr 20, 2021 at 12:23
  • @ShivaniTanwar salesforce.stackexchange.com/a/255959/2984
    – sfdcfox
    Commented Apr 20, 2021 at 12:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .