Please help - recover undeployed form (clone error changed original form)

I cloned a shared form (undeployed), and then also created a new form to build from scratch.
Somehow, in building the new form, it overrode not just the clone, but the original shared form too - changing the title as well as the questions. It changed the shared form for all users, not just myself.
Leaving me with 2 rather than 3 undeployed projects.

I can (and will) raise this as a bug, but if there is any way to roll-back the form, I would really appreciate the help as we need to deploy it for pilot testing today, and I may need to recreate it otherwise.

I have already tried this - and there are no versions showing:

(NB: I saw in a previous post that the suggestion was accessing Form History - see here - but I can’t find a Form History option on my dashboard.)

Welcome to the community, @samforsberg! Maybe you could go to the FORM. Under the FORM you could select Form history and see the versions you wish to Clone. Then you could clone the appropriate version you wish to have for your survey project.

Thank you for showing me where Form History should be visible, as I’d been unable to locate it. Unfortunately, this form does not have any history showing other than v1:

@samforsberg, you should be able to retrieve your xlsform as outlined in the post discussed previously:

@jnm - I have managed to find a json file of the form version that needs to be reinstated, but cannot find how to do this or message @staff as suggested in a community post.
I need this fixed asap - could you please help?

As demonstrated in my original post, there were no versions showing in my Asset Version List. I managed to access the json via my colleague’s account, but the Get XMLs option was returning an error message.

Hi @samforsberg, @Kal_Lam, it sounds like there are two issues here:

  1. In the UI, we only show deployed versions in the history. This is a known limitation that we would like to fix. What I believe happened in this case is that a form had various revisions without ever being deployed (as shown in this screenshot)—and we do store these—but we don’t offer any way to recover them in the UI.
  2. Something is wrong with cloning a form and subsequently editing a new form, where the new form somehow overwrites the previous one. This sounds like a serious issue that we’ve never heard about before, and any help you can provide, @samforsberg, in the form of reproduction steps would be very much appreciated.

To get out of the current predicament (revert the form content now that you’ve found the correct JSON), you need to manually PATCH the JSON to the asset where it belongs. I’ll show an example where I’ve created a form with only one question; I’ll then overwrite that form with different JSON content.

  1. The destination form:
    • Note its UID, ab72MkqfFN8g3aY4SvnhT2
  2. The “raw data” form shown at the asset detail endpoint for this form, https://kf.kobotoolbox.org/api/v2/assets/ab72MkqfFN8g3aY4SvnhT2/ (observe use of form UID in the URL):
  3. I’ll now erase everything from the “Content:” box and replace it with my desired form JSON surrounded with the following context:
    {"content":
    PASTE FORM JSON HERE
    }
    
    Don’t worry about making the indentation consistent, but make sure you include the closing curly brace at the end. In my example, the form JSON with context looks like:
    {"content":
    {
        "schema": "1",
        "survey": [
            {
                "name": "start",
                "type": "start",
                "$kuid": "CJjKco56O",
                "$autoname": "start"
            },
            {
                "name": "end",
                "type": "end",
                "$kuid": "wmyuj7O5M",
                "$autoname": "end"
            },
            {
                "type": "select_one",
                "$kuid": "fo8dv50",
                "label": [
                    "What's your favorite fruit?"
                ],
                "required": false,
                "$autoname": "What_s_your_favorite_fruit",
                "select_from_list_name": "nz7yq33"
            }
        ],
        "choices": [
            {
                "name": "persimmon",
                "$kuid": "jAmHkjb5R",
                "label": [
                    "Persimmon"
                ],
                "list_name": "nz7yq33",
                "$autovalue": "persimmon"
            },
            {
                "name": "peach",
                "$kuid": "t1MEPE5zX",
                "label": [
                    "Peach"
                ],
                "list_name": "nz7yq33",
                "$autovalue": "peach"
            },
            {
                "name": "plum",
                "$kuid": "tiy5DzzIp",
                "label": [
                    "Plum"
                ],
                "list_name": "nz7yq33",
                "$autovalue": "plum"
            },
            {
                "name": "pear",
                "$kuid": "rliyn6r49",
                "label": [
                    "Pear"
                ],
                "list_name": "nz7yq33",
                "$autovalue": "pear"
            }
        ],
        "settings": {},
        "translated": [
            "label"
        ],
        "translations": [
            null
        ]
    }
    }
    
  4. Before the next step, make sure neither you nor anyone else who has edit access to the form has the form open in a tab where they might accidentally click SAVE. If they save the broken form after you’ve done the next step, they will undo all of your work.
  5. Click the blue PATCH button;
  6. Once the page reloads, look for “CURRENT ENDPOINT”. I’d suggest using Control/Command+F in your browser. You should see PATCH /api/v2/assets/YOUR-FORM-UID/ followed by HTTP 200 OK, for example:
    image
  7. At this point, your form should be restored. You can navigate away from the API endpoint or close the tab and return to the normal UI:

Let us know if you’re able to complete this successfully.

2 Likes