How to change the description of a file?

Hi, 

In my groovy file, I wrote a loop function like below:

Document doc=apiAccessor.getProcessAPI().getDocument(it.id);

doc.description=it.comment;
if(doc.description.equals(it.comment)){
request.vendorName+=" description changed";
}

And my "vendorName" attribute got changed accordingly. But on my front page where I  retrieve and display the file, I used one input widget with its value binding to "$item.description"(item is the current attachment in a collection of attachments) and there's nothing showing up. And the full information of my attachment goes like below:

{"submittedBy":"-1","fileName":"Z%0V9D)X%Y`)Z%BEOVSA875.png","author":"-1","contentStorageId":"441","description":"","index":"0","creationDate":"2020-01-29 10:51:04.782","version":"1","contentMimetype":"image/png","url":"documentDownload?fileName=Z%0V9D)X%Y`)Z%BEOVSA875.png&contentStorageId=441","isInternal":"true","caseId":"5025","name":"attachmentsToDisplay","id":"441"}

Can somebody explain it to me? Why at the backend the description had been assigned a value but I couldn't see it at the front page?

Hello,

I don't understand your need.
If you need to change the 'Document.description':

You need to override your Document in 'Operation'. If you change the description only in your grovvy, that will never save.
You need to do somethink like:
In 'Operations':
myDocuments (type on 'List<Document>' ) -> myGroovyScript.

And, in your groovy script:

List<Document> docs = new ArrayList<Document>();
for(Document doc : myDocuments){
    
    doc.description=it.comment;
    docs.add(doc);

}
return docs;

Hi, what I'm trying to do is to bind the attachments with comments. Because in our program, we need to display attachments with comments per business request. Here lies the full function of that “operation” I used to store attachment-comment pair:

 

Sorry the format is weird so I upload the screenshot of the code here

 

On my front page where I tried to display the "attachmentsToDisplay", their descriptions are blank.

 

 

 Your operation is save in 'attachmentsToDisplay' who are the list of 'Document' ?

For your needs, you can use logger in groovy script like that:

import org.slf4j.Logger
import org.slf4j.LoggerFactory

Logger logger = LoggerFactory.getLogger("org.bonitasoft.groovy.script.converter");

logger.error("my log in error");

logger.info("my log in info");

 

I tried to print my document id by logger and to display it in an input widget, but I found they differed. The id I printed in Groovy file was 709, but at the front page, it turned 710. It seems when I retrieved the "attachmentsToDisplay"(only on attachment in this list) at the front page, Bonita had generated a copy for that attachment with new information(id, description, etc.). So I'm wondering is there any method I can get the original document list rather the copy of it?