Chain wire methods together in Lightning Web Components The Next CEO of Stack Overflow2019 Community Moderator ElectionDatabase.query not working with RecordTypeIdWhat are Lightning Web ComponentsWhat are these '@' symbol things in Web components [api, wire]?Change handler equivalent in Lightning Web ComponentsIs there a way to load every label data and every SObject description data in Lightning Web Component using only Javascript without any Apex?Import ES modules in LWCLWC: Picklist without knowing recordTypeIdWhen do @wire methods run (LWC)?Unable to upload a managed package with a generic errorUsing third-party Web Components with Lightning Web Components

How do I align (1) and (2)?

What did we know about the Kessel run before the prologues?

Received an invoice from my ex-employer billing me for training; how to handle?

WOW air has ceased operation, can I get my tickets refunded?

What happened in Rome, when the western empire "fell"?

What was the first Unix version to run on a microcomputer?

Why the difference in type-inference over the as-pattern in two similar function definitions?

Inappropriate reference requests from Journal reviewers

Would this house-rule that treats advantage as a +1 to the roll instead (and disadvantage as -1) and allows them to stack be balanced?

Domestic-to-international connection at Orlando (MCO)

How to place nodes around a circle from some initial angle?

Unreliable Magic - Is it worth it?

Why do airplanes bank sharply to the right after air-to-air refueling?

Won the lottery - how do I keep the money?

Why is the US ranked as #45 in Press Freedom ratings, despite its extremely permissive free speech laws?

Plot of histogram similar to output from @risk

Is it possible to replace duplicates of a character with one character using tr

Example of a Mathematician/Physicist whose Other Publications during their PhD eclipsed their PhD Thesis

What is the difference between 翼 and 翅膀?

Measuring resistivity of dielectric liquid

No sign flipping while figuring out the emf of voltaic cell?

How to get from Geneva Airport to Metabief?

What flight has the highest ratio of time difference to flight time?

Why does standard notation not preserve intervals (visually)



Chain wire methods together in Lightning Web Components



The Next CEO of Stack Overflow
2019 Community Moderator ElectionDatabase.query not working with RecordTypeIdWhat are Lightning Web ComponentsWhat are these '@' symbol things in Web components [api, wire]?Change handler equivalent in Lightning Web ComponentsIs there a way to load every label data and every SObject description data in Lightning Web Component using only Javascript without any Apex?Import ES modules in LWCLWC: Picklist without knowing recordTypeIdWhen do @wire methods run (LWC)?Unable to upload a managed package with a generic errorUsing third-party Web Components with Lightning Web Components










2















According to the documentation here in order to retrieve a list of picklist values for an object we need to pass in a Record Type Id which can be retrieved using the getObjectInfo method.



The issue is that these are both wire functions and I cannot figure out how to chain these methods.



If I try code like the following:



getObjectInfo( objectApiName: ACCOUNT_OBJECT )
.then(result =>
return getPicklistValues(recordTypeId: result.defaultRecordTypeId, fieldApiName: TYPE_FIELD);
)
.then(result =>
this.picklistValues = result.data
)
.catch(error =>
this.error = error;
);


I get an error




render threw an error in 'c:getpicklistexample' [Imperative use is not
supported. Use @wire(getObjectInfo).]




If I try something like



@track rtId;

@wire(getObjectInfo, objectApiName: ACCOUNT_OBJECT )
handleResult(error, data)
if(data)
this.rtId = data.defaultRecordTypeId;



@wire(getPicklistValues, recordTypeId: this.rtId,fieldApiName: TYPE_FIELD)
picklistValues;


Then it throws an internal server error. Anybody have an idea as to how I could retrieve the record type Id and then call to get the pick list values like the documentation suggests?



FYI my imports are:



import LightningElement, wire, track from 'lwc';
import getPicklistValues, getObjectInfo from 'lightning/uiObjectInfoApi';
import TYPE_FIELD from '@salesforce/schema/Account.Type';
import ACCOUNT_OBJECT from '@salesforce/schema/Account';









share|improve this question






















  • FYI, aware I could probably do this with apex but the docs suggest that I should be able to do this otherwise.

    – pbattisson
    4 hours ago















2















According to the documentation here in order to retrieve a list of picklist values for an object we need to pass in a Record Type Id which can be retrieved using the getObjectInfo method.



The issue is that these are both wire functions and I cannot figure out how to chain these methods.



If I try code like the following:



getObjectInfo( objectApiName: ACCOUNT_OBJECT )
.then(result =>
return getPicklistValues(recordTypeId: result.defaultRecordTypeId, fieldApiName: TYPE_FIELD);
)
.then(result =>
this.picklistValues = result.data
)
.catch(error =>
this.error = error;
);


I get an error




render threw an error in 'c:getpicklistexample' [Imperative use is not
supported. Use @wire(getObjectInfo).]




If I try something like



@track rtId;

@wire(getObjectInfo, objectApiName: ACCOUNT_OBJECT )
handleResult(error, data)
if(data)
this.rtId = data.defaultRecordTypeId;



@wire(getPicklistValues, recordTypeId: this.rtId,fieldApiName: TYPE_FIELD)
picklistValues;


Then it throws an internal server error. Anybody have an idea as to how I could retrieve the record type Id and then call to get the pick list values like the documentation suggests?



FYI my imports are:



import LightningElement, wire, track from 'lwc';
import getPicklistValues, getObjectInfo from 'lightning/uiObjectInfoApi';
import TYPE_FIELD from '@salesforce/schema/Account.Type';
import ACCOUNT_OBJECT from '@salesforce/schema/Account';









share|improve this question






















  • FYI, aware I could probably do this with apex but the docs suggest that I should be able to do this otherwise.

    – pbattisson
    4 hours ago













2












2








2








According to the documentation here in order to retrieve a list of picklist values for an object we need to pass in a Record Type Id which can be retrieved using the getObjectInfo method.



The issue is that these are both wire functions and I cannot figure out how to chain these methods.



If I try code like the following:



getObjectInfo( objectApiName: ACCOUNT_OBJECT )
.then(result =>
return getPicklistValues(recordTypeId: result.defaultRecordTypeId, fieldApiName: TYPE_FIELD);
)
.then(result =>
this.picklistValues = result.data
)
.catch(error =>
this.error = error;
);


I get an error




render threw an error in 'c:getpicklistexample' [Imperative use is not
supported. Use @wire(getObjectInfo).]




If I try something like



@track rtId;

@wire(getObjectInfo, objectApiName: ACCOUNT_OBJECT )
handleResult(error, data)
if(data)
this.rtId = data.defaultRecordTypeId;



@wire(getPicklistValues, recordTypeId: this.rtId,fieldApiName: TYPE_FIELD)
picklistValues;


Then it throws an internal server error. Anybody have an idea as to how I could retrieve the record type Id and then call to get the pick list values like the documentation suggests?



FYI my imports are:



import LightningElement, wire, track from 'lwc';
import getPicklistValues, getObjectInfo from 'lightning/uiObjectInfoApi';
import TYPE_FIELD from '@salesforce/schema/Account.Type';
import ACCOUNT_OBJECT from '@salesforce/schema/Account';









share|improve this question














According to the documentation here in order to retrieve a list of picklist values for an object we need to pass in a Record Type Id which can be retrieved using the getObjectInfo method.



The issue is that these are both wire functions and I cannot figure out how to chain these methods.



If I try code like the following:



getObjectInfo( objectApiName: ACCOUNT_OBJECT )
.then(result =>
return getPicklistValues(recordTypeId: result.defaultRecordTypeId, fieldApiName: TYPE_FIELD);
)
.then(result =>
this.picklistValues = result.data
)
.catch(error =>
this.error = error;
);


I get an error




render threw an error in 'c:getpicklistexample' [Imperative use is not
supported. Use @wire(getObjectInfo).]




If I try something like



@track rtId;

@wire(getObjectInfo, objectApiName: ACCOUNT_OBJECT )
handleResult(error, data)
if(data)
this.rtId = data.defaultRecordTypeId;



@wire(getPicklistValues, recordTypeId: this.rtId,fieldApiName: TYPE_FIELD)
picklistValues;


Then it throws an internal server error. Anybody have an idea as to how I could retrieve the record type Id and then call to get the pick list values like the documentation suggests?



FYI my imports are:



import LightningElement, wire, track from 'lwc';
import getPicklistValues, getObjectInfo from 'lightning/uiObjectInfoApi';
import TYPE_FIELD from '@salesforce/schema/Account.Type';
import ACCOUNT_OBJECT from '@salesforce/schema/Account';






lightning lightning-web-components






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 4 hours ago









pbattissonpbattisson

2,6601619




2,6601619












  • FYI, aware I could probably do this with apex but the docs suggest that I should be able to do this otherwise.

    – pbattisson
    4 hours ago

















  • FYI, aware I could probably do this with apex but the docs suggest that I should be able to do this otherwise.

    – pbattisson
    4 hours ago
















FYI, aware I could probably do this with apex but the docs suggest that I should be able to do this otherwise.

– pbattisson
4 hours ago





FYI, aware I could probably do this with apex but the docs suggest that I should be able to do this otherwise.

– pbattisson
4 hours ago










1 Answer
1






active

oldest

votes


















3














You have to use dynamic binding:



@wire(getPicklistValues, recordTypeId: "$rtId", fieldApiName: TYPE_FIELD)
picklistValues;


This is mentioned in Use the Wire Service to Get Data.



I wrote a mockup that demonstrates this. You should be able to copy-paste this code directly.




<template>
<template if:true=hasPicklistValues>
<select>
<template for:each=picklistValues.data.values for:item="entry">
<option key=entry.value value=entry.label>entry.label</option>
</template>
</select>
</template>
</template>



import LightningElement, wire, track from 'lwc';
import getPicklistValues, getObjectInfo from 'lightning/uiObjectInfoApi';
import TYPE_FIELD from '@salesforce/schema/Account.Type';
import ACCOUNT_OBJECT from '@salesforce/schema/Account';


export default class Democomponent extends LightningElement
@track rtId;
@track error;

@wire(getObjectInfo, objectApiName: ACCOUNT_OBJECT )
handleResult(error, data)
if(data)
this.rtId = data.defaultRecordTypeId;
else
this.error = error;



@wire(getPicklistValues, recordTypeId: "$rtId", fieldApiName: TYPE_FIELD)
picklistValues;

get hasPicklistValues()
return this.picklistValues && this.picklistValues.data && this.picklistValues.data.values;







share|improve this answer




















  • 1





    This is also how I would approach this (been writing LWC since it ga-ed). One trick for @wire is that it's reactive off value change and null to value is a perfectly valid reaction. My suspicion is that under the hood, it's a hash check on the property value.

    – tsalb
    3 hours ago











  • @tsalb Thanks for confirming. I ended up writing up a mock for this anyways, it wasn't terribly bad.

    – sfdcfox
    2 hours ago











  • Such is the speed of implementation when using ui*API and LWC ;)

    – tsalb
    2 hours ago











  • And there is the thing I was missing. Thanks @sfdcfox for the answer.

    – pbattisson
    11 mins ago












Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "459"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f255958%2fchain-wire-methods-together-in-lightning-web-components%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














You have to use dynamic binding:



@wire(getPicklistValues, recordTypeId: "$rtId", fieldApiName: TYPE_FIELD)
picklistValues;


This is mentioned in Use the Wire Service to Get Data.



I wrote a mockup that demonstrates this. You should be able to copy-paste this code directly.




<template>
<template if:true=hasPicklistValues>
<select>
<template for:each=picklistValues.data.values for:item="entry">
<option key=entry.value value=entry.label>entry.label</option>
</template>
</select>
</template>
</template>



import LightningElement, wire, track from 'lwc';
import getPicklistValues, getObjectInfo from 'lightning/uiObjectInfoApi';
import TYPE_FIELD from '@salesforce/schema/Account.Type';
import ACCOUNT_OBJECT from '@salesforce/schema/Account';


export default class Democomponent extends LightningElement
@track rtId;
@track error;

@wire(getObjectInfo, objectApiName: ACCOUNT_OBJECT )
handleResult(error, data)
if(data)
this.rtId = data.defaultRecordTypeId;
else
this.error = error;



@wire(getPicklistValues, recordTypeId: "$rtId", fieldApiName: TYPE_FIELD)
picklistValues;

get hasPicklistValues()
return this.picklistValues && this.picklistValues.data && this.picklistValues.data.values;







share|improve this answer




















  • 1





    This is also how I would approach this (been writing LWC since it ga-ed). One trick for @wire is that it's reactive off value change and null to value is a perfectly valid reaction. My suspicion is that under the hood, it's a hash check on the property value.

    – tsalb
    3 hours ago











  • @tsalb Thanks for confirming. I ended up writing up a mock for this anyways, it wasn't terribly bad.

    – sfdcfox
    2 hours ago











  • Such is the speed of implementation when using ui*API and LWC ;)

    – tsalb
    2 hours ago











  • And there is the thing I was missing. Thanks @sfdcfox for the answer.

    – pbattisson
    11 mins ago
















3














You have to use dynamic binding:



@wire(getPicklistValues, recordTypeId: "$rtId", fieldApiName: TYPE_FIELD)
picklistValues;


This is mentioned in Use the Wire Service to Get Data.



I wrote a mockup that demonstrates this. You should be able to copy-paste this code directly.




<template>
<template if:true=hasPicklistValues>
<select>
<template for:each=picklistValues.data.values for:item="entry">
<option key=entry.value value=entry.label>entry.label</option>
</template>
</select>
</template>
</template>



import LightningElement, wire, track from 'lwc';
import getPicklistValues, getObjectInfo from 'lightning/uiObjectInfoApi';
import TYPE_FIELD from '@salesforce/schema/Account.Type';
import ACCOUNT_OBJECT from '@salesforce/schema/Account';


export default class Democomponent extends LightningElement
@track rtId;
@track error;

@wire(getObjectInfo, objectApiName: ACCOUNT_OBJECT )
handleResult(error, data)
if(data)
this.rtId = data.defaultRecordTypeId;
else
this.error = error;



@wire(getPicklistValues, recordTypeId: "$rtId", fieldApiName: TYPE_FIELD)
picklistValues;

get hasPicklistValues()
return this.picklistValues && this.picklistValues.data && this.picklistValues.data.values;







share|improve this answer




















  • 1





    This is also how I would approach this (been writing LWC since it ga-ed). One trick for @wire is that it's reactive off value change and null to value is a perfectly valid reaction. My suspicion is that under the hood, it's a hash check on the property value.

    – tsalb
    3 hours ago











  • @tsalb Thanks for confirming. I ended up writing up a mock for this anyways, it wasn't terribly bad.

    – sfdcfox
    2 hours ago











  • Such is the speed of implementation when using ui*API and LWC ;)

    – tsalb
    2 hours ago











  • And there is the thing I was missing. Thanks @sfdcfox for the answer.

    – pbattisson
    11 mins ago














3












3








3







You have to use dynamic binding:



@wire(getPicklistValues, recordTypeId: "$rtId", fieldApiName: TYPE_FIELD)
picklistValues;


This is mentioned in Use the Wire Service to Get Data.



I wrote a mockup that demonstrates this. You should be able to copy-paste this code directly.




<template>
<template if:true=hasPicklistValues>
<select>
<template for:each=picklistValues.data.values for:item="entry">
<option key=entry.value value=entry.label>entry.label</option>
</template>
</select>
</template>
</template>



import LightningElement, wire, track from 'lwc';
import getPicklistValues, getObjectInfo from 'lightning/uiObjectInfoApi';
import TYPE_FIELD from '@salesforce/schema/Account.Type';
import ACCOUNT_OBJECT from '@salesforce/schema/Account';


export default class Democomponent extends LightningElement
@track rtId;
@track error;

@wire(getObjectInfo, objectApiName: ACCOUNT_OBJECT )
handleResult(error, data)
if(data)
this.rtId = data.defaultRecordTypeId;
else
this.error = error;



@wire(getPicklistValues, recordTypeId: "$rtId", fieldApiName: TYPE_FIELD)
picklistValues;

get hasPicklistValues()
return this.picklistValues && this.picklistValues.data && this.picklistValues.data.values;







share|improve this answer















You have to use dynamic binding:



@wire(getPicklistValues, recordTypeId: "$rtId", fieldApiName: TYPE_FIELD)
picklistValues;


This is mentioned in Use the Wire Service to Get Data.



I wrote a mockup that demonstrates this. You should be able to copy-paste this code directly.




<template>
<template if:true=hasPicklistValues>
<select>
<template for:each=picklistValues.data.values for:item="entry">
<option key=entry.value value=entry.label>entry.label</option>
</template>
</select>
</template>
</template>



import LightningElement, wire, track from 'lwc';
import getPicklistValues, getObjectInfo from 'lightning/uiObjectInfoApi';
import TYPE_FIELD from '@salesforce/schema/Account.Type';
import ACCOUNT_OBJECT from '@salesforce/schema/Account';


export default class Democomponent extends LightningElement
@track rtId;
@track error;

@wire(getObjectInfo, objectApiName: ACCOUNT_OBJECT )
handleResult(error, data)
if(data)
this.rtId = data.defaultRecordTypeId;
else
this.error = error;



@wire(getPicklistValues, recordTypeId: "$rtId", fieldApiName: TYPE_FIELD)
picklistValues;

get hasPicklistValues()
return this.picklistValues && this.picklistValues.data && this.picklistValues.data.values;








share|improve this answer














share|improve this answer



share|improve this answer








edited 2 hours ago

























answered 3 hours ago









sfdcfoxsfdcfox

262k12209454




262k12209454







  • 1





    This is also how I would approach this (been writing LWC since it ga-ed). One trick for @wire is that it's reactive off value change and null to value is a perfectly valid reaction. My suspicion is that under the hood, it's a hash check on the property value.

    – tsalb
    3 hours ago











  • @tsalb Thanks for confirming. I ended up writing up a mock for this anyways, it wasn't terribly bad.

    – sfdcfox
    2 hours ago











  • Such is the speed of implementation when using ui*API and LWC ;)

    – tsalb
    2 hours ago











  • And there is the thing I was missing. Thanks @sfdcfox for the answer.

    – pbattisson
    11 mins ago













  • 1





    This is also how I would approach this (been writing LWC since it ga-ed). One trick for @wire is that it's reactive off value change and null to value is a perfectly valid reaction. My suspicion is that under the hood, it's a hash check on the property value.

    – tsalb
    3 hours ago











  • @tsalb Thanks for confirming. I ended up writing up a mock for this anyways, it wasn't terribly bad.

    – sfdcfox
    2 hours ago











  • Such is the speed of implementation when using ui*API and LWC ;)

    – tsalb
    2 hours ago











  • And there is the thing I was missing. Thanks @sfdcfox for the answer.

    – pbattisson
    11 mins ago








1




1





This is also how I would approach this (been writing LWC since it ga-ed). One trick for @wire is that it's reactive off value change and null to value is a perfectly valid reaction. My suspicion is that under the hood, it's a hash check on the property value.

– tsalb
3 hours ago





This is also how I would approach this (been writing LWC since it ga-ed). One trick for @wire is that it's reactive off value change and null to value is a perfectly valid reaction. My suspicion is that under the hood, it's a hash check on the property value.

– tsalb
3 hours ago













@tsalb Thanks for confirming. I ended up writing up a mock for this anyways, it wasn't terribly bad.

– sfdcfox
2 hours ago





@tsalb Thanks for confirming. I ended up writing up a mock for this anyways, it wasn't terribly bad.

– sfdcfox
2 hours ago













Such is the speed of implementation when using ui*API and LWC ;)

– tsalb
2 hours ago





Such is the speed of implementation when using ui*API and LWC ;)

– tsalb
2 hours ago













And there is the thing I was missing. Thanks @sfdcfox for the answer.

– pbattisson
11 mins ago






And there is the thing I was missing. Thanks @sfdcfox for the answer.

– pbattisson
11 mins ago


















draft saved

draft discarded
















































Thanks for contributing an answer to Salesforce Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f255958%2fchain-wire-methods-together-in-lightning-web-components%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Best approach to update all entries in a list that is paginated?Best way to add items to a paginated listChoose Your Country: Best Usability approachUpdate list when a user is viewing the list without annoying themWhen would the best day to update your webpage be?What should happen when I add a Row to a paginated, sorted listShould I adopt infinite scrolling or classical pagination?How to show user that page objects automatically updateWhat is the best location to locate the comments section in a list pageBest way to combine filtering and selecting items in a listWhen one of two inputs must be updated to satisfy a consistency criteria, which should you update (if at all)?

Вунгтау (аеропорт) Загальні відомості | Див. також | Посилання | Навігаційне меню10°22′00″ пн. ш. 107°05′00″ сх. д. / 10.36667° пн. ш. 107.08333° сх. д. / 10.36667; 107.0833310°22′00″ пн. ш. 107°05′00″ сх. д. / 10.36667° пн. ш. 107.08333° сх. д. / 10.36667; 107.083337731608Vinh AirportVinh airport facelift improves serviceвиправивши або дописавши їївиправивши або дописавши їїр

Тонконіг бульбистий Зміст Опис | Поширення | Екологія | Господарське значення | Примітки | Див. також | Література | Джерела | Посилання | Навігаційне меню1114601320038-241116202404kew-435458Poa bulbosaЭлектронный каталог сосудистых растений Азиатской России [Електронний каталог судинних рослин Азіатської Росії]Малышев Л. Л. Дикие родичи культурных растений. Poa bulbosa L. - Мятлик луковичный. [Малишев Л. Л. Дикі родичи культурних рослин. Poa bulbosa L. - Тонконіг бульбистий.]Мятлик (POA) Сем. Злаки (Мятликовые) [Тонконіг (POA) Род. Злаки (Тонконогові)]Poa bulbosa Linnaeus, Sp. Pl. 1: 70. 1753. 鳞茎早熟禾 lin jing zao shu he (Description from Flora of China) [Poa bulbosa Linnaeus, Sp. Pl. 1: 70. 1753. 鳞茎早熟禾 lin jing zao shu he (Опис від Флора Китаю)]Poa bulbosa L. – lipnice cibulkatá / lipnica cibulkatáPoa bulbosa в базі даних Poa bulbosa на сайті Poa bulbosa в базі даних «Global Biodiversity Information Facility» (GBIF)Poa bulbosa в базі даних «Euro + Med PlantBase» — інформаційному ресурсі для Євро-середземноморського розмаїття рослинPoa bulbosa L. на сайті «Плантариум»