Symptoms
When the script in the Event Handler is executed, it fails with the error No field with name '<Document Section Name>\<Field Name>'.
Cause
Unlike Script Rules, where you can reference the fields by their Alias Names that you can specify in the Rule Settings, when accessing the fields in the Event Handlers, you need to use the full path and name of the field in the form of "<Document Section Name>\<Field Name>".
Example:
string fieldText = Document.Field("Document Section 1\\Field").Text;
The error No field with name '<Document Section Name>\<Field Name>' means that the name or full path of the field is not correct.
Solution
If you get the error No field with name '<Document Section Name>\<Field Name>' when the script in the Event Handler runs, check the following points:
1. The field is specified with its full path and there are no typos.
2. If according to the Assembly settings of your Document Definition, the specified Document Section can have multiple or 0 instances (i.e., Min number - 1, Max number - 10; or Min number - 0, Max number - 1), it is needed to specify the instance of the Document Section when accessing the Field, in the form of "<Document Section Name>[i]\<Field Name>", where [i] is the index of the instance. The first instance's index is 0.
Example:
string fieldText = Document.Field("Document Section 1[0]\\Field").Text;
Comments
2 comments
FOUZIA MOUSSAOUI
The error can bi trigged also for unkown documents in wokflow
Anton Vakhtel
Yes, you are correct. Unknown documents can also trigger this error in some cases because they have no fields, so addressing the field directly fails.
Please sign in to leave a comment.