We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

updateFields() method throwing null exception

Hi There,

We recently upgraded to Aspose Words 10.2 and after that we are facing an issue whenever we call the updateFields() method. All we are trying to do is update some custom properties in a document and save it. It is happening very frequently in our Production environment and we would like to know the reason and workaround at the earliest.

Thanks,
Manikandan

Hi Manikandan,

Please use the latest version of Aspose.Words for Java 10.7.0 and use the following code snippet to update the custom properties of document. I have attached the generated document with this post.

Document doc = new Document("d:/AAMD-PS-169674_1.doc");
for (int i = 0; i < doc.getCustomDocumentProperties().getCount(); i++)
{
    //Update the fields with their name + "- Updated"
    doc.getCustomDocumentProperties().get(i).setValue(doc.getCustomDocumentProperties().get(i).getName() + " - Updated");
}
doc.getRange().updateFields();
doc.save("d:/AsposeOut-Java.doc");