0

I'm having some issues to retrieve campaign recordtype id inside the lwc

import CAMPAIGN_RECORDTYPEID from"@salesforce/schema/Campaign.RecordTypeId";

@wire(getRecord, {​​​​​​​​​​​​​ recordId:"$campId", fields: [CAMPAIGN_RECORDTYPEID] }​​​​​​​​​​​​​)
campaign;

getcurrentCampaignRecordType(){​​​​​​​​​​​​​​​​​​​​
return getFieldValue(this.campaign.data, CAMPAIGN_RECORDTYPEID);
}​​​​​​​​​​​​​​​​​​​​

This is where I'm trying to validate the record type id, sometimes it retrieves the id, sometimes retrieves "undefined"

enter image description here

Edited

5
  • how is that code in the image invoked? are you certain that wire promise resolved by then?
    – zaitsman
    Commented Sep 27, 2021 at 23:49
  • @wire(getRecord, { recordId: USER_ID, fields: [PROFILE_NAME]}) userProfile2({data,error}){ if(data){ this.record = data; this.currentUserProfName = getFieldValue(this.record, PROFILE_NAME); //aleo.cris.buiza created this variable this.makeFormReadOnly(); } else if (error){ this.error=error; } } Commented Sep 27, 2021 at 23:53
  • It's getting called from another wire Commented Sep 27, 2021 at 23:53
  • order of wire execution is not guaranteed. What you need to do is store data in variables and in both wire callbacks call resolution method that should check that both are set and only act if so
    – zaitsman
    Commented Sep 28, 2021 at 0:15
  • Your first comment was enough for me to realize the execution order was not guaranteed, thanks alot! Commented Sep 28, 2021 at 0:41

0

You must log in to answer this question.