0

I have created a custom button that will load a page to create an opportunity in which few fields needs to be prefilled and it should have a specific RecordType. But the issue is all the fields are getting populated but the record is created with the default Record Type and not the RecordType mentioned. This is the code I am using

/lightning/o/Opportunity/new?defaultFieldValues=RecordType=0121U000000KDRIQA4,AccountId={!Task.What},Campaign_Member__c={!Task.Campaign_Member__c},CampaignId={!Task.CampaignId__c},ContactId={!Task.Who}

I have also tried the below code but nothing seemed to work. It is using the default record type.

/lightning/o/Opportunity/new?RecordType=0121U000000KDRIQA4&defaultFieldValues=AccountId={!Task.What},Campaign_Member__c={!Task.Campaign_Member__c},CampaignId={!Task.CampaignId__c},ContactId={!Task.Who}

Can anybody please help me on this.

4
  • How did you come up with /new?RecordType=.... as the format for forcing the record type?
    – identigral
    Commented Jul 15, 2022 at 18:13
  • Can we not update like this? I was using this format to open the page when we click on you and some of the fields will be fetched by default, does recordType data cannot be brought like this? Commented Jul 18, 2022 at 5:34
  • Is the recordtype enabled for your profile? If not, it will revert to the default recordtype. Commented Jul 18, 2022 at 12:01
  • It was enabled but there was something else restricting it. Also I used Vinay approach as well it worked Commented Jul 19, 2022 at 18:21

1 Answer 1

1

Here recordTypeId is case sensitive and make sure you use 'recordTypeId' to set default record type value.

/lightning/o/Opportunity/new?recordTypeId=0121U000000KDRIQA4&defaultFieldValues=AccountId={!Task.What},Campaign_Member__c={!Task.Campaign_Member__c},CampaignId={!Task.CampaignId__c},ContactId={!Task.Who}
5
  • Hi @Vinay I tried this but didnt work Commented Jul 18, 2022 at 5:35
  • /lightning/o/Opportunity/new?recordTypeId=0121U000000KDRIQA4&defaultFieldValues=AccountId={!Task.What},Campaign_Member__c={!Task.Campaign_Member__c},CampaignId={!Task.CampaignId__c},ContactId={!Task.Who} Commented Jul 18, 2022 at 6:04
  • It worked for me and record type is being populated, make sure you have access to record type on opportunity and use correct record id (/lightning/o/Opportunity/new?recordTypeId=0122v000001SmZ2AAK&defaultFieldValues= Phone__c={!Account.Phone}, field2,field3 etc.,)
    – Vinay
    Commented Jul 18, 2022 at 13:33
  • Hey Vinay it worked there was some other logic in the system preventing it but now everything is working as expected. Commented Jul 19, 2022 at 18:19
  • Thanks for your help. Much appreciated Commented Jul 19, 2022 at 18:20

You must log in to answer this question.

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