+ Start a Discussion
azhar khasimazhar khasim 

I have a Custom Button (OnClick JavaScript) in Classic was not working in Lightning now i need to use Lightning Component to update my Record Type on a click of button.

Hello guys,

I have a Custom Button(OnClick JavaScript) in Classic was not working in Lightning now. I found that I need to use Lightning Component to update my Record Type on a click of a button.
 

This is My OnClick JavaScript for Updating Record Type.
************************************************
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}

// identify the record
var o = new sforce.SObject("Contact");
o.id = "{!Contact.Id}";

// Update the Record Type
o.RecordTypeId = "0122E000000KiWa"; //You can also Query the RecordTypeId

// save the change
sforce.connection.update([o]);

//refresh the page
window.location.reload();

**************************************************************

I need this requirement to use as Lightning Component in Salesforce Lightning 
Please provide me a solution for this in

( Component
  Controller
  Style
  Apex Class ) 


Thanks and Regards,
Azar Khasim.
Bhawana Mehta SFDCBhawana Mehta SFDC
Hi @ahar -- Did you try using the OOB change REcord type button instead of Custom Lightning Component?
azhar khasimazhar khasim
Hello Bhawana,

OOB change REcord type button means the standard button (Record type Field) in any object.!
or is it any other.

I have 4 record types I need to change from one to another.
Can u please give a detail point of view about the OOB change REcord type button.

Thanks and Regards,
Azar Khasim.
 
Bhawana Mehta SFDCBhawana Mehta SFDC
Hi,

There is a "Change Recod Type" standard button taht you can add to your page layout to change record type.
Refer to Below article where its been implemented for Contact record. You can follow same step and implement accordingly.

https://help.propertybase.com/hc/en-us/articles/202898816-Changing-Contact-Record-Types