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

Free Support Forum - aspose.com

Issue with updateFields updating more than just docProperty with version 10.2

With the 10.2.0 release of Aspose.Words the update engine now updates more than just DocProperty and DocVariable. However, this causes errors in some of our documents and we would like a way to limit the engine to only processing those field types we desire and not others.

Is there any way of doing this? We are looking for a solution ASAP as this is causing production issues.

Thanks

CJD

Hello

Thanks for your request. I’m afraid there is no way to limit the engine using Aspose.Words.

Could you please be more specific regarding the problem with UpdateFields. Also could you please attach the document you are getting problem with? I will check it on my side and provide you more information.

Best regards,

Andrey,

I have attached an example document we are seeing the problem on - currently I have about 20 similar ones where other field types (other than DocProperty type) are embedded in the document and the engine seems to be throwing an null error (see attached image) when processing them. Currently we trap an error, report it and exit. We could bypass the error, however, when we do that, any DocProperty fields after the error do not get updated in the remainder of the document.

This is a very critical situation as we are seeing this issue in our Production environment and impacting our businesses. What we are looking for is to be able to run updatefields or a similar commands that behaves like prior versions and only updates DocProperty and DocVariable field types.

Thank you in advance for you assistance in this critical issue,

Chad

Hi Chad,


As Andrey stated above, it is not possible to limit field update functionality to specific field types, but it is surely possible to fix the issue so that the engine would not throw. I’ll look into the problem once Andrey (or somebody) check it and log it into our bug tracking system. Therefore we will try to include the fix into the forthcoming release (end of December or beginning of January I believe).

Meanwhile, as a workaround, you can extract all fields from the document and update them one by one in a loop, selecting the DocProperty and DocVariable types only. I think Andrey will provide you a sample code if needed.

Thanks.

Hi Chad,

Thank you for additional information. But it’s not quite clear for me how can I reproduce the problem on my side? Could you please be more specific? Could you please provide me the code which will allow me to reproduce the problem on my side?

Best regards,

Hi There,

This is the code we are using to update the document properties and it is failing at update Fields()

com.aspose.words.Document doc = new com.aspose.words.Document(“Spec-07-002313_3.docx”);
for (int i = 0; i < doc.getCustomDocumentProperties().getCount(); i++)
{
DocumentProperty prop = doc.getCustomDocumentProperties().get(i);
if( prop.getName().equals(“dm_object_name”) )
prop.setValue(“Les Mani Document”);
if( prop.getName().equals(“dm_release_date”) )
prop.setValue(“06/05/2009”);
if( prop.getName().equals(“dm_title”) )
prop.setValue(“Test Aspsoe”);
}
doc.updateFields();
doc.save(docName);

Please give us some sample code to update only DOCPROPERTY AND VALUE.

Thanks,
Manikandan

Hi

Thank you for additional information. I cannot reproduce the problem on my side using the latest version of Aspose.Words for Java 10.7.0.

You can download the latest version from here:

http://www.aspose.com/community/files/72/java-components/aspose.words-for-java/category1378.aspx

I use the following code for testing:

Document doc = new Document("C:\\Temp\\AAMD-PS-169674_1+EXAMPLE.doc");

for (int i = 0; i < doc.getCustomDocumentProperties().getCount(); i++)

{

DocumentProperty prop = doc.getCustomDocumentProperties().get(i);

if (prop.getName().equals("dm_object_name"))

prop.setValue("Les Mani Document");

if (prop.getName().equals("dm_release_date"))

prop.setValue("06/05/2009");

if (prop.getName().equals("dm_title"))

prop.setValue("Test Aspsoe");

}

doc.updateFields();

doc.save("C:\\Temp\\out.doc");

Best regards,