Cannot save changes to my model in Skuid JS

I am calling a JS Snippet after editing a few rows from a Table.
My requirement is to clone the changed rows and save the edits only to the cloned records. And I want to keep the original rows unchanged. 

What I did here :
-Used the “changed” object to get the edited values
-Used the “originals” object to get old values and reverted the changes done to the existing record.

-Since I thought it would be a better idea to clone the records using the standard salesforce clone function, I passed those values to an apex class, cloned the records there.

Now I am confused, how the data is affected in the model. I guess the newly created records through Apex won’t be loaded in the model.

Hence I tried a model.save() and then a model.updateData(). The updateData() is throwing an error that says " you have unsaved changes in xyz model( which however is not the model I am working with) and save or cancel changes before updateData()". I am sure I am missing something silly here.

Any inputs? or a better way to do this?

Thanks in advance.

Hi Ebin, If I’m understanding correctly it sounds like you want to use existing records as a starting point to create new data. Have you looked into setting up a clone model on the page?

  1. In the model advanced properties, select the option to “Clone data returned by Model” query: when checked, all records queried by the model will be cloned and treated as brand-new records. Any record updates are not applied to currently existing records, but saved as totally separate records.You can choose to clone the data returned by this model query based on the presence of certain URL parameters or all the time.

  2. Then, you can use an action sequence to choose which rows will get queried by your clone model (e.g. based on user inputs you can activate and setting the values of different conditions on your clone model, and then querying the clone model will clone the records)

Does this sound like what you’re trying to do? Let me know if you have further questions.

See also

Thank you Anna, I am yet to try this yet. In our requirement, we had to use the clone function that was already written in an Apex class (since it had clone+ some other functionality that is supposed to happen to the records.). But it was good to learn about this option. Thanks !