Difference between Form_ID and Instance_ID?

Hi all –

My developer uses various record fields through the API.

He was for some reason having a hard time getting his app to get the Form_ID… so he found that he could use Instance_ID instead. It is nice and Unique per each form.

–> can you tell me what Instance ID is for, how it is maybe different from Form ID?
–> can you see any downside to him using it? He’s hoping to use it to log which forms he has already synced in the past, so he only grabs the new ones.

eric

Hi Eric,

I believe that HQ uses the isntanceID as the form ID for the vast majority of forms.

The only case where I don’t think this is true is if there are duplicate form submissions, or a form which replaces another (as would occur with Data Corrections), in which case the new form receives a different FormId.

As long as you aren’t using Data Corrections I don’t see any downside to using the instanceid. If you are, I think the downside would be that referencing the instanceId as the formID would give you the original (overwriten) form rather than the new (correcting) form.

-Clayton

Hello Clayton – thanks for the info you gave below. A few questions:

à when you say “data corrections,” does that mean, when we go onto commcareHQ and make an “edit form” to an existing form? That regular edit form function… is that what you refer to as edit form?

à Assuming that you do mean that…I am trying to think of the non-flawed approach for our use situation. Here is a story of our web-based data app as it works through the API:

Hi Eric,

I think your response was cut off by the forum.

When I say Data Corrections I mean the use of this feature: https://confluence.dimagi.com/display/commcarepublic/Edit+Form+Submissions

If a separate XForm is used to correct data, the instanceID and formID will be consistent for both forms.

-Clayton

Hi Clayton – Ug, I don’t know why the forum cut it off. I will re-submit the same email here, using the web UI, instead of through email. Sorry to be a pain, but could you look and reply to the below? I think you DID answer one aspect in the reply you just gave, but it’s easiest for me to move forward with a full sense of this situation – So here:
—ORIGINAL POST—
Hello Clayton – thanks for the info you gave below. A few questions:

** When you say “data corrections,” does that mean, when we go onto commcareHQ and make an “edit form” to an existing form? That regular edit form function… is that what you refer to as edit form?

** Assuming that you do mean that…I am trying to think of the non-flawed approach for our use situation. Here is a story of our web-based data app as it works through the API:

  1. Our app stores up lots of forms through normal commcare use.
  2. Once per day at 5am, our php-based web app does a big huge PULL through the api, and copies the full set of all of our forms records.
  3. That is all kind of setting up the baseline. Then, here is the planned normal “ongoing” cycle for incremental syncing, that we plan to implement:
    a. For one day, our many users submit a lot of new forms, which of course wind up in commcareHQ.
    b. At 5am, our web app does a new sync, but this time it will use a certain field’s uniqueID (formID or instanceID, that is the question) to determine the correct cut-off between old and new forms.
    c. Using that, it will only download the new, previously non-existing forms, therefore not having to do the erase amd 100% all-forms total new fresh download that we have been doing daily until now.
    d. At the end of that, our web database matches the commcareHQ database.

** SO, note again that we do use the “forms edit” function fairly often…
** So when I look at your highlighted text below, which implies that the very same form, when edited, would generate a totally new ID. In my above scenario, I believe that would wind up “doubling” that form, because we would keep the old form and also keep the new one intended to “replace” it. (OR, sorry, are you saying that when the new edited form is created, it actually deletes the old version? But if that happened, I can’t see how we could, in your yellow text below, wind up mistakenly retrieving an old form?

… I have to admit, I don’t know the true algorithm the developer has been building. But let me know your reactions to the above before I blab any more…

Thx

Eric