@rose.thomas
Summary
The Aspose.Words LINQ Report Engine expression language does not expose the full .NET String API, so you cannot call instance members such as .ToString() or the .Length property inside an IIF expression. Instead, you need to use the functions that the engine provides for string handling (e.g., Len, IsNullOrEmpty, CStr).
Why it happens
When the template is compiled the expression parser only recognises a limited set of built‑in functions. Calls to .ToString() or .Length are not part of that supported set, which results in a parsing error.
What to do next
- Use the built‑in length helper (if available) to test for a non‑empty string:
IIF(
Len(First(Fields!WitnessedBy.Value)) > 0,
IIF(
Len(First(Fields!SecondWitness.Value)) > 0,
",",
""
),
""
)
- Or test the string directly (if the engine allows direct comparison):
IIF(
First(Fields!WitnessedBy.Value) <> "",
IIF(
First(Fields!SecondWitness.Value) <> "",
",",
""
),
""
)
- If the field might not be a string, cast it with the engine’s conversion helper (e.g.,
CStr) before applying Len:
IIF(
Len(CStr(First(Fields!WitnessedBy.Value))) > 0,
IIF(
Len(CStr(First(Fields!SecondWitness.Value))) > 0,
",",
""
),
""
)
- Verify the expression by previewing the Word template with the LINQ Report Engine or by running a small test program.
- Check the official Aspose.Words documentation for the exact list of supported functions in the LINQ Report Engine, as the available helpers can differ between versions.
If you still encounter errors, double‑check the field names, ensure the fields contain string data, and consult the Aspose.Words LINQ Report Engine reference for the correct function names.
I could not fully verify this explanation against the retrieved sources. Please double-check the behaviour in your environment and confirm the exact SDK/version.