API Example: Simple record copy

Ian, is there a chance I need to do something in the page to find the API?
I customized all the names I thought were necessary, based on the comments.
I’m starting with zero Javascript knowledge.

@CathyHMcB We can hop on a Zoom so I can see if you’re console is showing any errors. Feel free to schedule a time here.

1 Like

Thank you for your previous help. The code is working fine, but I lost the button I’d added at the top of my page. I have a form submit button at the bottom, but I need to get the duplicate button back to the top of my form.
I can’t remember how I got it on there to start with…
Any help?
Cathy

Hi Cathy,

Speaking for @Nic here, but the button is added to the page with JavaScript. Here’s the line of code responsible for adding the button to the page:

// Add a button to execute the action
$('#' + view.key).prepend('<button id="copy-button">Duplicate Record</button>');

If the button is not appearing on your page, then you can open your Console and try looking for JavaScript errors (errors will typically show in the Console). If you don’t see any errors, then I recommend scheduling a consultation over Zoom to investigate.

Thanks @Nic -
Here’s my code. And I’ll follow your lead.

More tomorrow!

Make sure your code has the button element; it should look exactly like this:

$('#' + view.key).prepend('<button id="copy-button">Duplicate Record</button>');

Thanks all for this great idea.

I will have to try this for copying multiple child records when a parent record is created. I am currently doing this with Make. Make works fine but it takes about 10-15 seconds, and i have a view that the user needs this to happen more immediately. Will definitely give this a go!

However, for copying a single record?
Is there a reason this is needed for making a copy of a single record rather than using built in functionality via an action link called, say, ‘duplicate’ on the table line that inserts a new record on the table copying whatever values you need? This works for me in the builder, does not need code, and is instant.
This is what I do: Knack
Is there an issue with doing it that way?

Kind regards.

@Calvin_B @Calvin_B

By any chance would you mind sharing how you are using Make to copy multiple child records to a parent record?
I am trying to use Make to create a copy of a parent record and it’s multiple child records. I’ve spent a couple days on this and am not having much luck. I am able to copy both the parent and child records but cannot seem to get the connection established between the two. I’d really appreciate any direction you could share with me!

Thanks!

Kathy