I have a component with 3 button with name of record Type. I need that when I click on a certain button, the Record Type of the account record will be update.
that's what i have:
ComponentButtons.cmp
<aura:component description="ComponentButtons"
controller="AccountTransferCont" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction"
access="global">
<!--iconName="action:change_record_type"-->
<lightning:overlayLibrary aura:id="overlayLib"/>
<lightning:card>
<div class="slds-grid slds-einstein-header slds-card__header">
<header class="slds-media slds-media_center slds-has-flexi-truncate">
<div class="slds-grid slds-grid_vertical-align-center slds-size_3-of-4 slds-medium-size_2-of-3">
<div class="slds-media__body">
<h2 class="slds-truncate" title="Einstein (10+)">
<a href="javascript:void(0);" class="slds-card__header-link" title="Einstein (10+)">
<span class="slds-text-heading_small">Account Transfer1</span>
</a>
</h2>
</div>
</div>
<div class="slds-einstein-header__figure slds-size_1-of-4 slds-medium-size_1-of-3"></div>
</header>
</div>
<div class="c-container">
<lightning:layout>
<lightning:layoutItem padding="around-small">
<lightning:button label=" - > Generic Sales" variant="brand"
onclick="{!c.doGeneric}"/>
</lightning:layoutItem>
</lightning:layout>
<lightning:layout>
<lightning:layoutItem padding="around-small">
<lightning:button label=" - > Foreign Sales" variant="brand"
onclick="{!c.doForeign}"/>
</lightning:layoutItem>
</lightning:layout>
<lightning:layout>
<lightning:layoutItem padding="around-small">
<lightning:button label=" - > Military Sales" variant="brand"
onclick="{!c.doMilitary}"/>
</lightning:layoutItem>
</lightning:layout>
</div>
</lightning:card>
</aura:component>
ComponentButtonsController.js
({doGeneric: function (component, event, helper) {
alert("Nowhere to convert!");
},
doForeign: function (component, event, helper) {
},
doMilitary: function (component, event, helper) {
}
});
ApexController AccountTransferCont.apx
public without sharing class AccountTransferCont {
@AuraEnabled
public static void Military(String RecordID) {
Account a = [SELECT Id,RecordTypeId FROM Account WHERE Id = :RecordID];
RecordType rt = [SELECT Id FROM RecordType WHERE Name = 'Military' AND SobjectType = 'Account' LIMIT 1];
a.RecordTypeId = rt.Id;
update a;
}
}