Erreur de doublons et de liaison dynamique à partir d'un fichier CSV

Bonjour,

J’ai conçu un formulaire qui extrait certaines informations à partir d’un fichier CSV externe. Cependant, lors de la collecte des données, je rencontre un problème de doublons.

J’ai essayé d’utiliser la liaison dynamique de données (dynamic data attachment), mais j’obtiens systématiquement des erreurs.

Pourriez-vous m’aider à résoudre ce problème ?

type name label hint required read_only calculation constraint relevant
xml-external monitoring
start start
end end
today today
select_one qr0cn48 _0_Ville 0. Ville true
text _1_Site_de_Distribution 1. Site de Distribution true
select_one he7mq74 Charg_de_distribution Chargé de distribution true
note ENTRE_LES_SOUSSIGNES_UCP_TRANSFORME_Et ENTRE-LES SOUSSIGNES 1° L’UNITÉ DE COORDINATION DU PROGRAMME D’AUTONOMISATION DES FEMMES ENTREPRENEURS ET MISE EN OUVRE DES PME POUR LA TRANSFORMATION ECONOMIQUE ET L’EMPLOI EN RDC, TRANSFORME RDC en sigle, ayant son siège au 9-11, Croisement des avenues KISANGANI et Le MARINEL, 2ème étage, Immeuble SOFIDE (en face du Collège BOBOTO), Code postal 01209, Kinshasa/Gombe, République Démocratique du Congo, ici représenté par Monsieur/Madame Chef(fe) d’Antenne du TRANSFORME, suivant mandat reçu de Monsieur MANGALA NGONGO Alexis, Coordonnateur National, agissant au nom et pour le compte du Ministère de l’Entrepreneuriat, Petites et Moyennes Entreprises, Ci- après dénommée « L’UCP-TRANSFORME », Et false
text Id 2.Id de la femme true
calculate count count(instance(‘monitoring’)/root/data[Id = current()/../Id])
calculate Id_count concat(${Id}, ‘_’, ${count})
text _3_Nom_de_la_femme 3. Nom false true pulldata(‘Corridor’, ‘Nom’, ‘key’, ${Id})
text _4_Post_nom_de_la_femme 4. Postnom false true pulldata(‘Corridor’, ‘Postnom’, ‘key’, ${Id})

I assume you are entering an Id into your form, and the count calculation result is returning greater than 1 for the Id (having found more than 1 matching Id in the monitoring DDA attachment =). Correct?

If you have duplicate Ids in your parent DDA form then you probably have an issue with collecting the parent data. That said, if you still want to look something up in your child form nevertheless you can tweak your form to return the first matching Id. That will prevent you getting errors when you do have duplicate Ids, but its also means which (duplicated) parent record you get is somewhat random; you’ll get the ‘first’ matching Id, but there is no guarantee what order the records in the monitoring DDA file are returned in.

There’s an example of how to do this in the Kobo docs here: Dynamic data attachments in XLSForm — KoboToolbox documentation :

…You can also use the position=1 argument to ensure that only one matching row is returned and reduce the risk of errors when multiple matches exist.

Basically, instead of:

instance(‘monitoring’)/root/data[Id=current()/../Id]/full_name

you’d put:

instance(‘monitoring’)/root/data[Id=current()/../Id][position()=1]/full_name

where the additional [position()=1] returns the first match only.

This will stop you getting errors in your child form when you have duplicate Ids, but it doesn’t address the more fundamental problem of why you are collecting duplicate Ids in the first place.