Bulk Row Creation/Duplication

Bulk Row Creation/Duplication

crowsongcrowsong Posts: 2Questions: 0Answers: 0
edited July 2017 in Free community support

Hello. I want to enable the user to create/duplicate many copies of a single record. I've tried to create a "quantity" field in the Editor that hooks to the create() function to create X copies of a new record. I've also tried to use the duplicate button to create X copies of an existing record. Without success I tried using the preCreate event to pick up a quantity and insert extra records.

My question is similar to this discussion but I'm missing something and can't get it working.

Thanks,
George

Replies

  • allanallan Posts: 63,481Questions: 1Answers: 10,467 Site admin

    Hi George,

    For the duplicate case, you should be able to use:

                        editor
                            .create( 2, {
                                title: 'Duplicate record',
                                buttons: 'Create from existing'
                            } )
                            .set( values );
    

    where the 2 will create 2 records. Change as required.

    Regards,
    Allan

  • crowsongcrowsong Posts: 2Questions: 0Answers: 0

    Could the user decide how many copies to create?

    Thanks,
    George

  • allanallan Posts: 63,481Questions: 1Answers: 10,467 Site admin

    You'd need an input element somewhere on the page where they can type that in, or perhaps a select where they could select the value and then use that value in your create() call.

    Potentially you could use a different Editor instance to get that value. Have a single field form that will get a value from them and then the action for the button would be to call create() on the "real" Editor instance.

    Allan

This discussion has been closed.