function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

How to Trigger an update to change recordTypeId ?

I have this code 

Js controller 

    init : function(component, event, helper) {
        var action = component.get("c.getAcc");
            "accid": component.get("v.recordId")                   
        action.setCallback(this, function(response) {
            var state = response.getState(); // get the response state
            if (state === "SUCCESS"){
                component.set("v.accountInfo", response.getReturnValue());
                if(component.get("v.accountInfo.Bridger_check__c")=="No Match"){
                          component.set("v.bridge", true);
            } else if(state === "ERROR"){
                var errors = response.getError();
                let toastParams = {
                    title: "Error",
                    message: "Unknown error", // Default error message
                    type: "error"
                // Pass the error message if any
                if (errors && Array.isArray(errors) && errors.length > 0) {
                    toastParams.message = errors[0].message;
                // Fire error toast
                let toastEvent = $A.get("e.force:showToast");

    handleLoad : function(component, event, helper) {
    component.set("v.showSpinner", false);
    handleSubmit : function(component, event, helper) {
       //We don't need to put basic validation here as that are handle by lightning:inputfield and recordEditForm
       event.preventDefault(); // stop form submission
       var eventFields = event.getParam("fields");
       eventFields["Bridger_check__c"] = "";
        eventFields["BillingCountry"] = eventFields["Billing_Country__c"];
    handleSuccess : function(component, event, helper) {
    //Redirect to detail page on success
    var payload = event.getParams().response;
     var navService = component.find("navService");
        var pageReference = {
            type: 'standard__recordPage',
            attributes: {
                "objectApiName": "Account",
                "actionName": "view"


Aura Component 

<aura:component implements="force:appHostable,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" controller="AccountController">
    <aura:attribute name="accountInfo" type="Account"/>
    <aura:attribute name="bridge" type="Boolean"/>
    <aura:handler name="init" value="{!this}" action="{!c.init}"/>
        Account: {!v.accountInfo.Bridger_check__c}

        <aura:attribute name="disabled" type="Boolean" default="false" />
    <aura:attribute name="saved" type="Boolean" default="false" />
    <aura:attribute name="showSpinner" type="Boolean" default="true" />
    <lightning:navigation aura:id="navService"/>
    <aura:if isTrue="{!v.bridge}">
    <aura:if isTrue="{!v.showSpinner}">
        <lightning:spinner />
    <aura:if isTrue="{!!v.saved}">
            <!-- the messages component is for error messages -->
            <lightning:messages />
             Account Information
            <lightning:inputField fieldName="Region__c" />
            <lightning:inputField fieldName="Country__c" />
            <lightning:inputField fieldName="Segment__c" />      
             <lightning:inputField fieldName="Name" /> 
            <lightning:inputField fieldName="Account Site" /> 
            <div class="slds-m-top_medium">
                <lightning:button disabled="{!v.disabled}" variant="brand" type="submit" name="save" label="Save" />
        <aura:set attribute="else">
    <aura:if isTrue="{!!v.bridge}">
        "Not good"

Apex controller 
  public static Account getAcc(String accid) {
           return [SELECT id,Bridger_check__c
            FROM Account
            WHERE id =: accid
            LIMIT 1];

But after i press save the record type the same. 
Normally if the record is updated then it should change it's record type.

Any ideas ? 
Best Answer chosen by B
It is working if  
eventFields["RecordTypeId"] = "xxxxxxxxx" in handlesubmit   
and    put this at the end of handle success 

All Answers

Raj VakatiRaj Vakati
You need to refresh the page to see the changes .. if you have a trigger to update the record types it will update but changes wnr show until you refresh the page  ..use the below code in submit

I dont have a trigger to update...
It is working if  
eventFields["RecordTypeId"] = "xxxxxxxxx" in handlesubmit   
and    put this at the end of handle success 
This was selected as the best answer