Move identical data from one data type to another

Hello there,

I have two “products” data types. They have exacly the same fields, but I have it duplicated since I’m using one of those tables to save “temporary” things.

Once the user “confirms” a sale by clicking a button, I want to move all “products” things from product A to product B.

I mean, I want to copy products A in products B data type, and delete them from product A.

How can I do it?

Hi!

First, I wouldn’t recommend this setup. Duplicate data types are rarely a good solution and often create headaches down the road. What you could do instead is to add a boolean field (yes/no) and change the field to “yes” when a user has confirmed the sale. Ultimately, the solution is the same: Scheduling a backend workflow on a list.

If you want to keep your existing setup, you would first create a new backend workflow. You would add one parameter: Product Type A (the existing thing).

Screen Shot 2022-09-24 at 6.59.04 PM

Next, you would add the action “Create a new thing” and select Product Type B. Then add all fields and input the data from Product Type A into the new Product Type B thing.

Screen Shot 2022-09-24 at 6.59.51 PM

Now add the action “Delete a thing” and select Product Type A from the workflow parameter. You’re now done with the backend workflow, which should look like this:

Screen Shot 2022-09-24 at 7.00.57 PM

Finally, return to the page where the action should be scheduled. Start a new workflow on the button that should trigger the backend workflow (e.g. “Confirm sale”). and add the action “Schedule API workflow on a list”. Select “Product Type A” as the type of thing and select the backend workflow you just created. Search for the list of Product Type A you want to run the workflow on. Set Scheduled date to current date/time, and select “This Product Type A” for the Product Type A parameter.

If you want to go with my alternative solution, you would follow the same process, but instead of creating a new Product Type B and deleting the Product Type A in the backend workflow, you will instead Make Changes to the Product and set the boolean (e.g. Sale confirmed) to “yes”. You will then schedule the API Workflow on the same list with the same Product parameter. And whoops, you’ve gotten rid of the duplicate.

Hope that helps.

3 Likes

Thank you very much! great explanation!! thank you :slight_smile: