Dynamic reports with JSON formula - loop
Dear all,
Bonjour,
Je travaille actuellement sur un rapport dynamique qui a besoin d'afficher un enregistrement à imprimer, ainsi que des sous enregistrements.
Je travaille avec trois tables :
La table A (table principale)
La table B, sous table de la table A,
La table C sous table de la table B.
J'arrive à faire ma boucle (Boucle 1) pour obtenir les informations de la table B en fonction de mon ROW principal en table A .
J’ai un problème avec ma boucle (Boucle 2) pour obtenir les informations de la table C : le filtre dépend de la boucle de la table B (Boucle 1).
Quel argument et quelle boucle utiliser et dans quel ordre ?
Voici mon code
"// Ceci est un commentaire";
let myPiece := 'Etat-Lieux-Pièces'.ID;
let myEtat := this; {
date: format('Date et heure de l’état des lieux', "DD-MM-YYYY - HH:mm"),
commercial: concat(COMMERCIAUX.'Civilité' + " " + COMMERCIAUX.Nom + " " + COMMERCIAUX.'Prénom'),
type: concat("Etat des lieux :" + 'Type état des lieux' + " - " + BIEN.Type_bien),
adresse: concat(BIEN.'N°' + ", " + BIEN.Rue + " - " + BIEN.CP + " " + BIEN.Ville),
proprios: 'CLAUSE PROPRIÉTAIRES',
Sign1: 'URL Sign Proprio 1',
Sign2: 'URL Sign Proprio 2',
Sign3: 'URL Sign Proprio 3',
Sign4: 'URL Sign Proprio 4',
locataires: 'CLAUSE LOCATAIRES',
Sign5: 'URL Sign Loc 1',
Sign6: 'URL Sign Loc 2',
Sign7: 'URL Sign Loc 3',
Sign8: 'URL Sign Loc 4',
Ngaz: 'N° Compteur Gaz',
Igaz: 'Index compteur gaz',
Egaz: 'Emplacement compteur gaz',
Pgaz: 'URL Compteur gaz',
Nelec: 'N° Compteur électricité',
Ielec: 'Index compteur électricité',
Eelec: 'Emplacement compteur électricité',
Pelec: 'URL Compteur elec',
Neauf: 'N° Compteur eau froide',
Ieauf: 'Index compteur eau froide',
Eeauf: 'Emplacement compteur eau froide',
Peauf: 'URL Compteur eau froide',
Neauc: 'N° Compteur eau chaude',
Ieauc: 'Index compteur eau chaude',
Eeauc: 'Emplacement compteur eau chaude',
Peauc: 'URL compteur eau chaude',
Pcles: 'URL Clés',
Cles: for i in 'ETATS DES LIEUX - CLÉS' order by 'Quantité' do
{
Type: i.Type,
Qte: i.'Quantité',
Libelle: i.'Libellé'
}
end,
Pieces: for i in 'Etat-Lieux-Pièces' order by Niveau do
{
myIDPiece: i.ID,
Piece: i.text('Pièce'),
Niveau: i.text(Niveau),
Sol: i.text(Sols),
SolEtat: i.text('Etat sols'),
SolCom: i.text('Commentaire sol'),
Murs: i.text(Murs),
MursEtat: i.text('Etat murs'),
MursCom: i.text('Commentaire murs'),
Plaf: i.text(Plafonds),
PlafEtat: i.text('Etat plafond'),
PlafCom: i.text('Commentaire plafonds'),
Vol: i.text(Volets),
VolEtat: i.text('Etat volets'),
VolCom: i.text('Commentaire volets'),
Chassis: i.text(Chassis),
ChassisEtat: i.text('Etat chassis'),
ChassisCom: i.text('Commentaire chassis'),
Portes: i.text(Portes),
PortesEtat: i.text('Etat portes'),
PortesCom: i.text('Commentaire portes'),
Equip: for i in 'Etat-Lieux-Pièces'.'EQUIPEMENT ETAT DES LIEUX' order by 'CONCERNE PIECE ETAT DES LIEUX'.ID do
{
Categorie: i.text('Catégorie'),
Libelle: i.'Libellé',
Annee: i.'Année équipement',
Etat: i.text('Année équipement'),
Com: i.'Commentaire équipement',
PhotoEquip: i.'URL Equipement',
Concerne: i.'CONCERNE PIECE ETAT DES LIEUX'.ID
}
end
}
end
}
2 replies
-
Hello,
I'm currently working on a dynamic report that needs to display a record to be printed, as well as sub-records.
I'm working with three tables:
Table A (main table)
Table B, a sub-table of table A,
Table C, a sub-table of table B.I can do my loop (Loop 1) to get the information from table B based on my main ROW in table A.
I have a problem with my loop (Loop 2) to get the information from table C: the filter depends on the loop in table B (Loop 1).Which argument and which loop should I use and in which order?
Here's my code
"// Ceci est un commentaire"; let myPiece := 'Etat-Lieux-Pièces'.ID; let myEtat := this; { date: format('Date et heure de l’état des lieux', "DD-MM-YYYY - HH:mm"), commercial: concat(COMMERCIAUX.'Civilité' + " " + COMMERCIAUX.Nom + " " + COMMERCIAUX.'Prénom'), type: concat("Etat des lieux :" + 'Type état des lieux' + " - " + BIEN.Type_bien), adresse: concat(BIEN.'N°' + ", " + BIEN.Rue + " - " + BIEN.CP + " " + BIEN.Ville), proprios: 'CLAUSE PROPRIÉTAIRES', Sign1: 'URL Sign Proprio 1', Sign2: 'URL Sign Proprio 2', Sign3: 'URL Sign Proprio 3', Sign4: 'URL Sign Proprio 4', locataires: 'CLAUSE LOCATAIRES', Sign5: 'URL Sign Loc 1', Sign6: 'URL Sign Loc 2', Sign7: 'URL Sign Loc 3', Sign8: 'URL Sign Loc 4', Ngaz: 'N° Compteur Gaz', Igaz: 'Index compteur gaz', Egaz: 'Emplacement compteur gaz', Pgaz: 'URL Compteur gaz', Nelec: 'N° Compteur électricité', Ielec: 'Index compteur électricité', Eelec: 'Emplacement compteur électricité', Pelec: 'URL Compteur elec', Neauf: 'N° Compteur eau froide', Ieauf: 'Index compteur eau froide', Eeauf: 'Emplacement compteur eau froide', Peauf: 'URL Compteur eau froide', Neauc: 'N° Compteur eau chaude', Ieauc: 'Index compteur eau chaude', Eeauc: 'Emplacement compteur eau chaude', Peauc: 'URL compteur eau chaude', Pcles: 'URL Clés', Cles: for i in 'ETATS DES LIEUX - CLÉS' order by 'Quantité' do { Type: i.Type, Qte: i.'Quantité', Libelle: i.'Libellé' } end, Pieces: for i in 'Etat-Lieux-Pièces' order by Niveau do { myIDPiece: i.ID, Piece: i.text('Pièce'), Niveau: i.text(Niveau), Sol: i.text(Sols), SolEtat: i.text('Etat sols'), SolCom: i.text('Commentaire sol'), Murs: i.text(Murs), MursEtat: i.text('Etat murs'), MursCom: i.text('Commentaire murs'), Plaf: i.text(Plafonds), PlafEtat: i.text('Etat plafond'), PlafCom: i.text('Commentaire plafonds'), Vol: i.text(Volets), VolEtat: i.text('Etat volets'), VolCom: i.text('Commentaire volets'), Chassis: i.text(Chassis), ChassisEtat: i.text('Etat chassis'), ChassisCom: i.text('Commentaire chassis'), Portes: i.text(Portes), PortesEtat: i.text('Etat portes'), PortesCom: i.text('Commentaire portes'), Equip: for i in 'Etat-Lieux-Pièces'.'EQUIPEMENT ETAT DES LIEUX' order by 'CONCERNE PIECE ETAT DES LIEUX'.ID do { Categorie: i.text('Catégorie'), Libelle: i.'Libellé', Annee: i.'Année équipement', Etat: i.text('Année équipement'), Com: i.'Commentaire équipement', PhotoEquip: i.'URL Equipement', Concerne: i.'CONCERNE PIECE ETAT DES LIEUX'.ID } end } end }
-
It is hard to keep track of loops in the beginning. I find it easier if you rename your loop variables so they are unique so you can track which loop you are talking about.
For example:
Cles: for loop1 in 'ETATS DES LIEUX - CLÉS' order by 'Quantité' do { Type: loop1.Type, etc } end, Pieces: for loop2 in 'Etat-Lieux-Pièces' order by Niveau do { myIDPiece: loop2.ID, etc Equip: for loop3 in loop2.'Etat-Lieux-Pièces'.'EQUIPEMENT ETAT DES LIEUX' order by 'CONCERNE PIECE ETAT DES LIEUX'.ID do { Categorie: loop3.text('Catégorie'), etc } end }
You can see that it is a bit easier to see which part of the loop you are in by which loop variable you are referencing.
Content aside
- 1 yr agoLast active
- 2Replies
- 72Views
-
2
Following