1

I have the onclick javaScript custom clone which has a functionality that populates a custom field called "Cloned From".

Upon click of Clone button, on create record layout, the "Clone From" will be populated by the Record ID of the Original Record. Since this is not supported on Lightning Experience, we would like to know if there is a workaround kind of behavior?

5
  • 1
    You need to share your code if you want an answer to why it doesn't work. Nov 29, 2016 at 11:57
  • @RobertSussland here is code for the onclick javscript clone button. "00NC0000005Ijne" is sa custom field. parent.location.href = '/{!Campaign.Id}/e?clone=1&retURL=%2F{!Campaign.Id}&00NC0000005Ijne={!Campaign.Id}'
    – Von
    Dec 1, 2016 at 0:55
  • Ahh, OK. URL hacking like this doesn't work in Lightning, but you can call actions that achieve this. See trailhead.salesforce.com/en/lex_migration_customization/… Dec 1, 2016 at 17:20
  • @RobertSussland how will i use clone functionality on actions?
    – Von
    Dec 2, 2016 at 8:06
  • You have to write your own component as per the answer below, but instead of including a script block to populate the record id, if you component implements force:hasRecordId, then it will be given the record id automatically. See here for sample code: andyinthecloud.com/2016/08/21/… Dec 2, 2016 at 22:47

1 Answer 1

1

Create a visualforce page for selected object. e.g:- for contact object

<apex:page standardController="Contact" >
<script>
    var id= "{!record.id}";
    console.log(id);
</script>

then you can pass this id to a component. which will create a cloned record.

you have to create a new action button on contact which will open above page and then add it to the page layout.

9
  • @Manjos - what specific component i need to create to pass the record ID?
    – Von
    Dec 1, 2016 at 7:38
  • $Lightning.createComponent("c:creteClone",{ "id" : id },"lightning",function(cmp) {}); Dec 1, 2016 at 7:56
  • you have to create a new LightningComponent which will get id of record as parameter and make clone of that record. Dec 1, 2016 at 7:59
  • <aura:component controller="cloneRecord"> <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> <aura:attribute name="id" type="String" /> Dec 1, 2016 at 8:08
  • <aura:component controller="cloneRecord"> <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> <aura:attribute name="id" type="String" /> </aura:component> Dec 1, 2016 at 8:09

You must log in to answer this question.

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