Recurring Form

Hi, I hope you are well.

I am currently gathering information for a service mapping. Usually these tools are so extensive and recurrent, there is a lot of resistance to answer them in Venezuela.
A colleague told me that in KoBo, it was possible for a person to answer the form, and then send it back to them for changes and/or validation of the information, through a link generated at the time of sending this form. (this link would be the previously answered form)
I would like that the organization’s focal point could fill out and submit the form, and after two months I could send it back to them with the information answered and they could validate it and/or change it, if necessary.

Is this possible in KoBo? Under what option?

Thank you in advance!!

This can be done, but it requires a manual effort to generate the link as discussed in our previous post:

Hi @Kal_Lam the other day I commented on the post you reference - can you please confirm, how long does that edit URL (that you’ve generated manually) last? From other posts I thought it is only intended to last for 30s before it expires. We too are trying to solve same problem of getting a list of edit links (though in our case it’s only because it seems that the ‘edit’ view is the only one that shows the submitted data in Enketo layout)

Would appreciate your insights re longevity of the edit URL - thanks!

1 Like

Hi @nat,

At my end i could use the edit URL link for 1 edit. The time did not matter here as i could even edit it after 1 minutes. The main thing i have noticed here is that you are able to edit your submissions only once with the edit URL. For the next time you will have to go back and then again generate the edit URL. That again works for another edit. So the same cycle keeps following.

Thanks for taking a look @Kal_Lam ! Hmm, in @martijnr 's post on Access Enketo API functionality through KoboToolbox - #6 by martijnr he stated that it was a configuration option that should only be set at 30s - do you know if the server you were testing on had a different config or if the time restriction has since been removed on the code side?

In any case I’d still love to have an option to “view” a submission in Enketo without having “edit” permissions (per the suggestion box) but good to know that the edit URL sticks around for longer on the server you were using. Will give it anothernother go on the one I’m on. Cheers!

1 Like

@nat i tried the same in our public server i.e. HHI server. Thus the same should also be with the OCHA server.

Regarding your feature’s request please be informed that i have compiled them. Thank you once again for your wonderful suggestion and all the support provided to the community!

1 Like

Hello @Kal_Lam I’ve been trying to find out why I can’t access the form, and @nat is right, after 30s the link is not active anymore. I need a workaround.
This is very veeeery important for our form. We don’t know when the organisations and public institutions. are going to review the form and we really need them not to have to enter all the information again and again, we need them to change just if necessary.
Pleeeeaaseee how can I solve this???

Hi @analucia_espinoza and @nat,

I was able to reproduce what you are bringing up. As Martijn points out here, this is essentially a security feature to ensure that the forms don’t remain editable for long.

I tried using John’s workaround from here but it seems the filtering doesn’t work as it used to (or at least in my tests — perhaps this is a bug!).

As a work around, this isn’t a great, user-friendly solution, but it works despite the filtering issue. If you know how to use a terminal, you can do the following whenever you are needing a new edit link:

TOKEN=<token>
PARENT_UID=<form uid>
ASSET_UID=<asset uid>

ID=`curl -s "https://kf.kobotoolbox.org/api/v2/assets/$PARENT_UID/data.json" \
-H "Authorization: Token $TOKEN" \
| jq --arg ASSET_UID "$ASSET_UID" '.results[] \
| select(._uuid == $ASSET_UID) \
| ._id'`

curl -s "https://kf.kobotoolbox.org/api/v2/assets/$PARENT_UID/data/$ID/edit/?return_url=false&format=json" \
-H "Authorization: Token $TOKEN" | jq

This will output the following which you can then send to whomever (keeping in mind that this link also only last for 30 seconds):

{
  "url": "https://ee.kobotoolbox.org/edit/<enketo_url>?instance_id=<instance_id>&return_url=false"
}

If it’s more helpful, I can send through a Python script that will do the same.

1 Like

Thank you josh! But it doesn’t solve the problem, we do not know when will the organization be able to access the form, and with Venezuela’s internet I don’t know if it will take longer than 30s to access the form :confused:

El El lun, 1 de feb. de 2021 a la(s) 9:44 p. m., Joshua Beretta via KoBoToolbox Community Forum <noreply@community.kobotoolbox.org> escribió:

Thanks @Josh for the script! In the end (as I had business users) I went with a manual solution but with formulae to help people go directly to ‘edit view’ of the particular submissions they needed at the time they needed to:

I

  • Downloaded the submissions data in Excel format
  • Got the $PARENT_UID you refer to above just by going into the UI and clicking on ‘edit’ and watching the network requests in browser console to find the string (this is the part most business users would need a hand with)
  • Created a formula in Excel to give the hyperlink to get the edit URL for each submission: =HYPERLINK("https://kf.kobotoolbox.org/api/v2/assets/"&[$PARENT_UID string I had got above]&"/data/"&[$ID from data download]&"/edit/")
    (I had also used a formula based on the data in the download to construct the filename I wanted the pdf saved as)

I could then give the business users the following instructions:

  1. Log into KoBo in your browser like normal
  2. Copy the Get_Edit_URL field into your browser address bar (I find that copying and pasting the URL works better than just clicking on the hyperlink to open it via Excel). You’ll see something like the below:
  3. Click on the URL to go straight to edit view
  4. Save as pdf - you can copy and paste the “Filename to use” to make it easier to get the right filename

Notes:

  • if in step 2 you see a URL but it’s not a clickable link then either use Firefox browser or install a JSON plugin to Chrome (e.g. this one) to make it clickable
  • if in step 2 you see the below then hit refresh in a few seconds and it will eventually give you a new URL (likely about 30s before it works again)
    image

@analucia_espinoza note re the above method - as far as I can tell it doesn’t matter how long the form takes to download once you’ve clicked on the edit link, or how long the user takes to edit once the form is opened - the key is that once you’ve created an Edit URL via step 2 above then you have 30s to click on it to start the edit process - and also you won’t be able to get another Edit URL for that same submission record until 30s have passed. Good luck!

3 Likes

Thanks for your great solution @nat. Note that if your goal is to just download a PDF of the filled in form, you could also automate it and send your client the PDF rather than a link. You could do something like the following (assuming you have Google Chrome and macOS — adjust accordingly):

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
--headless --print-to-pdf=$HOME/Downloads/example_file.pdf \
--virtual-time-budget=25000 $ENKETO_URL

(EDIT: looks like you could use this tool to simplify the pdf creation)

Where $ENKETO_URL is from my previous message, i.e.:

ENKETO_URL=`curl -s "https://kf.kobotoolbox.org/api/v2/assets/$PARENT_UID/data/$ID/edit/?return_url=false&format=json" \
-H "Authorization: Token $TOKEN" | jq '.url'`

You may have to increase virtual-time-budget if you find that it’s printing blank forms or missing data since it takes time for it to download.

1 Like

@nat, just read your suggestion here and will reply over there.

3 Likes

Edit: I goofed :man_facepalming: The parameter is query, not q, as described in the API documentation:

I know this is pretty tangential to the topic here, but specifying filters like q={"_uuid":"952d24f5-26d0-4cc1-9c30-09b997e9703e"} and which fields to return, like fields=["_id"], is pretty fundamental to the data API. What was the issue?

More to the point, @nat’s solution seems like a great one, but it does require that the person editing have permission to edit (any) submission in the project. @analucia_espinoza, does this work for you, or were you looking for something more like a single-use link that anyone could use (without logging in) to edit a specific submission one time only?

(@Josh, if it’s the latter, could you distill this into a feature request? This is the kind of thing we have no plans to build yet, but it’d be great to have on our radar.)

3 Likes