Gravatar for jlynch@sonusnet.com

Question by Jim Lynch, May 31, 2016 12:25 PM

GetFieldValue behavior in PostConversion script when field is missing

What does DocumentInfo.GetFieldValue return if the requested field is missing ?

I have a Post Conversion script that attempts to retrieve a field value and store it in a custom field. I have initialized the custom field to a string ('InitializedState').

There are some documents that do not contain the field that the script tries to retrieve. In this case, I have some logic to deal with the missing field. However, the custom field still contains 'InitializedState' when the field is missing. Therefore, it seems that the conversion script exits when the field does not exist before I can execute additional logic.

1 Reply
Gravatar for sdesilets@coveo.com

Answer by Sebastien Desilets, Jun 6, 2016 4:39 PM

Get/SetFieldValue should really be renamed Get/SetMetaDataValue :)

The "field" DocumentInfo.GetFieldValue("somemeta") is not the field "somemeta" but the metadata "somemeta". If you have a field say "somefield" with "somemeta" as it's metadata name then using SetFieldValue("somemeta", "somevalue") will set the field value of "somefield" to "somevalue" , through it's metada "somemeta".

Gravatar for jlynch@sonusnet.com

Comment by Jim Lynch, Jun 13, 2016 4:44 PM

Yes, I understand how GetFieldValue works as I have implemented a few conversion scripts.

However, my question is what happens when the GetFieldValue does not find the field in the Coveo document ?

For example, we index a field called @sfsolutionwarningbulletinalertc. But it is not in all documents.

Therefore, if I call Document.GetFieldValue("sfsolutionwarningbulletinalertc") and the field not exist in the document what should GetFieldValue return ?

Thanks Jim

Ask a question