I'm trying to modify an external application to directly open a particular form in ODK Collect to start filling it. The URIs of the forms to be opened will be pushed from the backend to this external application. I am using Kobotoolbox to create the forms. How can I get the form URI which Collect uses for a form, before the user fetches that form?
2. What app or server are you using and on what device and operating system? Include version numbers.
Kobotoolbox as the server.
App version is 1.30.1
3. What you have you tried to fix the problem?
Following the documentation provided here : https://docs.getodk.org/launch-collect-from-app/#launching-the-form-list-or-instance-list-activity
I am able to launch a form with URI content://org.odk.collect.android.provider.odk.forms/forms/1, content://org.odk.collect.android.provider.odk.forms/forms/2, etc..
But these correspond to the forms residing on ODK Collect currently (in order of date added from oldest to newest). I need to know these form IDs before the user syncs Collect and fetches the forms.
4. What steps can we take to reproduce the problem?
5. Anything else we should know or have? If you have a test form or screenshots or logs, attach below.
If you don't have those forms downloaded you don't know their ids in the Collect's database and you shouldn't try to predict them. What you can do is read the whole database and filter the values using formId and version (you should know them because those a part of a form so you can set them) and then read the id of a matching form in order to start it.
Thanks a lot for your support on this, I got it working great.
Can I also change the login credentials of Collect from an external app? So that users don't have to go to Collect to sign in.
It is possible to override url/username/password used in ODK Collect when you download/upload forms via an external app. You can test that option in Collect Tester.
But those credentials will be used just for downloading/uploading triggered from that external app so if you open the original ODK Collect app you will still have your old credentials.
I am using React Native but the code for Launching ODK is in Java which is called in my react native code using native modules.
Intent intent = new Intent(Intent.ACTION_EDIT);
Uri uri = Uri.parse("content://org.odk.collect.android.provider.odk.forms/forms/" + formID);
This is what I have. The problem is it opens ODK but shows the entire list of forms and not a specific form. The formid is passed in the function correctly.
Hi, could you please help with how to read the whole database using api end point if it's possible? I tried downloading the form using the download url that comes with XML response of openrosa form list apis but the downloaded content do not have any formID apart from xml form id.