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
BB 

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");
        action.setParams({
            "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);
                        //component.set("v.accountInfo.Bridger_check__c","None");
                 }
            } 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");
                toastEvent.setParams(toastParams);
                toastEvent.fire();
            }
            
        });
        $A.enqueueAction(action);
    },

        
    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"];
       component.find('myform').submit(eventFields); 
           
    },
    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: {
                "recordId": payload.id,
                "objectApiName": "Account",
                "actionName": "view"
            }
        }
        event.preventDefault();
        navService.navigate(pageReference);
    }
    
 


})

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>
    <aura:if isTrue="{!!v.saved}">
        <lightning:recordEditForm
            aura:id="myform"
            onload="{!c.handleLoad}"
            onsubmit="{!c.handleSubmit}"
            onsuccess="{!c.handleSuccess}"
            recordId="{!v.recordId}"
            objectApiName="Account">
            <!-- 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" />
            </div>
        </lightning:recordEditForm>
        <aura:set attribute="else">
            <p>Saved!</p>
        </aura:set>
    </aura:if>
  
    </aura:if>
    
    <aura:if isTrue="{!!v.bridge}">
        "Not good"
    </aura:if>
    
</aura:component>

Apex controller 
@AuraEnabled
  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
BB
It is working if  
eventFields["RecordTypeId"] = "xxxxxxxxx" in handlesubmit   
and    put this at the end of handle success 
$A.get('e.force:refreshView').fire();

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
 
$A.get('e.force:refreshView').fire();

 
BB
I dont have a trigger to update...
BB
It is working if  
eventFields["RecordTypeId"] = "xxxxxxxxx" in handlesubmit   
and    put this at the end of handle success 
$A.get('e.force:refreshView').fire();
This was selected as the best answer