Cannot save changes to my model in Skuid JS

  • 1
  • Question
  • Updated 1 week ago
  • In Progress
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.



Photo of Ebin

Ebin

  • 132 Points 100 badge 2x thumb

Posted 3 weeks ago

  • 1
Photo of Anna Wiersema

Anna Wiersema, Official Rep

  • 11,754 Points 10k badge 2x thumb
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