On a la liste éditable suivante :
Les deux champs libellé et pièce jointe sont modifiables.
On souhaite avoir dans l’attribut Date la dernière modification sur la pièce jointe
On a essayé dans un post update(code ci dessous) de récuperer si l’attribut pièce jointe a été change en utilisant getField(document_field).haschanged() mais ça retourne toujours vrai quand la liste éditable contient un seul élément même si le document n’a pas été changé
Ce que résulte à avoir l’attribut Date modifié même si on change seulement le libelle ( ce changement aura lieu seulement si on a un seul élément dans la liste sinon pour 2 éléments et plus has changed renvoie les bonnes valeurs)
Technical information
Instance /health
[Platform]
Status=OK
Version=5.2.34
BuiltOn=2023-03-13 16:54
Git=5.2/8cf8688af7cd3e007a96621540535e34c4f3abf2
Encoding=UTF-8
EndpointIP=169.254.132.4
EndpointURL=http://87b862703bc2:8080
TimeZone=UTC
SystemDate=2023-05-26 15:55:48
[Application]
ApplicationVersion=2.3.31
ContextPath=
ContextURL=https://agent-recette.ladom.fr
ActiveSessions=2
TotalUsers=16
EnabledUsers=14
LastLoginDate=2023-05-26 13:11:25
[Server]
ServerInfo=Apache Tomcat/9.0.73
ServerType=WEB
ServerActiveSessions=2
ServerSessionTimeout=30
[OS]
Name=Linux
Architecture=amd64
Version=5.10.164.1-1.cm1
DockerImageName=centos7
SystemEncoding=UTF-8
[JavaVM]
Version=17.0.6
Vendor=Eclipse Adoptium
VMName=OpenJDK 64-Bit Server VM
VMVersion=17.0.6+10
ScriptEngine=rhino
ScriptEngineVersion=Rhino 1.7.13 2020 09 02
HeapFree=188323
HeapSize=949248
HeapMaxSize=1703936
TotalFreeSize=943011
[Cache]
ObjectCache=160
ObjectCacheMax=10000
ObjectCacheRatio=1
ProcessCache=0
ProcessCacheMax=10000
ProcessCacheRatio=0
APIGrantCache=1
APIGrantCacheMax=1000
APIGrantRatio=0
[Database]
Vendor=3
ProductName=PostgreSQL
ProductVersion=13.10
DriverName=PostgreSQL JDBC Driver
DriverVersion=42.5.4
DBDate=2023-05-26 15:55:48
DBDateOffset=0
DBPatchLevel=5;P02;14f8034ce5a285931ca480a5451ce96e
UsingBLOBs=false
[Healthcheck]
Date=2023-05-26 15:55:48
ElapsedTime=34
@Override
public String postUpdate() {
if(getField(FIELD_JUSTIF_COMP_PIECEJOINTE).hasChanged()) {
String rowId = getRowId();
AppLog.info(getClass(), "docComplDate()", "rowid postUpdate : " + rowId, null);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String localDate = LocalDateTime.now().format(formatter);
AppLog.info(getClass(), "docComplDate()", "localdate : " + localDate, null);
BusinessObjectTool objT = this.getTool();
if (this.select(getRowId())) {
AppLog.info(getClass(), "docComplDate()", "setFieldValue : " + localDate + " to rowid : " + getRowId(), null);
try {
this.setFieldValue(FIELD_JUSTIF_COMP_DATE, localDate);
objT.validateAndSave();
} catch (Exception e) {
AppLog.error("Erreur lors de la validation de la date", e, null);
}
}
}
return super.postUpdate();
}
[/details]
Autre Problème rencontré
On a voulu récupérer le path du document dans init update (pour le comparer avec celui dans le post update) mais bizarrement même si le document existe on a cette erreur :
2023-05-26 15:26:55,758|SIMPLICITE|INFO||http://87b862703bc2:8080||INFO|system|com.simplicite.objects.ladnext.LadJustificatifsComplementaires|erreur()||Event: get path du doc id: 24449 , msg : Cannot invoke "com.simplicite.util.DocumentDB.getPath()" because the return value of "com.simplicite.util.ObjectField.getDocument()" is null
2023-05-26 15:26:55,494|SIMPLICITE|INFO||http://87b862703bc2:8080||INFO|designer|com.simplicite.objects.ladnext.LadJustificatifsComplementaires|initUpdate()||Evénement: get path : LadJustificatifsComplementaires/ladJustifComplPieceJointe/0/70/sample.pdf
pour l’objet métier ci dessous, un path a été récuperer mais pas le deuxième