18.2LTS 4DWP bug and related question

Just ran into a really strange bug (as I was trying to get my head around WritePro for the first time). The following code:

ST INSERT EXPRESSION(*;"WPareaReceipt";[ReceptLetters]Name;ST Start highlight;ST End highlight)

causes the Project Method ‘Test’ to run when the [ReceptLetters]Name field contains the value “Test”.

It took me a few minutes to realize what was happening because I had an import routine loaded into the “Test” method and at first thought that 4D was grabbing a method from a deleted table and executing it.

Question about 4D WritePro. I’m NEW to using it, and cannot (under any circumstances) get any of the items under the Insert and View tab to insert anything into the document (Insert date, Insert time, Insert 4D expression all do absolutely nothing). I have Show References turned on for the doc, so must be missing something very fundamental. Is there an example DB or blog post somewhere that shows how to do a simple mail merge style template? I need the user to create a receipt letter that merges with selected data, but can’t seem to get even basic field references to embed in the doc. Does 4DWP even work with ORDA?

Hi John,

Have you tried toggling the “Show/Hide Expression” button (its the toolbar icon that looks like [ ]. When you inserted a field, the value will be appear only when a record is loaded and the field contains a value. Looking at your example, you were attempting to insert a value from a field. May be empty value or no loaded record was the problem.

HTH,
Add

As for ORDA, you cannot insert an entity attribute (field) as an expression like you could with the field reference. For example:

The following are allowed

// Insert a field as a computable expression
ST INSERT EXPRESSION(*;"WParea";"[ReceptLetters]Name";ST Start highlight;ST End highlight)

or

// Insert the current value of a field
ST INSERT EXPRESSION(*;"WParea";[ReceptLetters]Name;ST Start highlight;ST End highlight)

or

// Insert the current value of an entity attribute
ST INSERT EXPRESSION(*;"WParea";enReceptLetters.Name;ST Start highlight;ST End highlight)

The following is not allowed:

// Insert an entity attribute as a computable expression
ST INSERT EXPRESSION(*;"WParea";"enReceptLetters.Name";ST Start highlight;ST End highlight)

I hope this clears things up for you.

Add

Thank you very much for the clarification about ORDA!

As for toggling the “Show/Hide Expression” button, yes, I’ve toggled it on and off, but with no change. I also issued a query against the Customer table with the [ReceiptLetters]Name changed to [Customer]First, and also have the WritePro form directly on the input form with the record loaded by double-clicking on the output layout, but still nothing will display when I try and add either an expression, or current date or time (while toggling the Show/Hide to check), but nothing seems to be copied to the document, and I’m unsure of how to manually add a placeholder of some kind (or if that’s even possible).

Ah sorry, I gave you a wrong information. After doing a bit more testing, This is what happened.

When you called

ST INSERT EXPRESSION(*;"WParea";[ReceptLetters]Name;ST Start highlight;ST End highlight)

it is equivalent to

ST INSERT EXPRESSION(*;"WParea";"John";ST Start highlight;ST End highlight)

As is, John is considered to an expression that needs to be evaluated. The problem is that John is already a value, it is not a command, method, or other computable expressions. Therefore, you will always get blank.

Try putting a quote around [ReceptLetters]Name like the following example and see what happen.

ST INSERT EXPRESSION(*;"WParea";"[ReceptLetters]Name";ST Start highlight;ST End highlight)

ALSO, I think I might be wrong about inserting an entity attribute. I just ran a quick test and it appears to be accepted. For example:

// Insert an entity attribute as a computable expression
ST INSERT EXPRESSION(*;"WParea";"enReceptLetters.Name";ST Start highlight;ST End highlight)

Add

Thank you Add, very interesting!

Yes, putting quotes around the “[ReceptLetters]Name” correctly shows the value or expression, depending on the toggle of Show/hide 4d expressions.

I’m still unable to get an expression to insert and/or display using Insert 4D expression, but since I can do it using code, as you just showed, I build a custom interface for the users with pre-selected expressions to insert.

Really appreciate your following up with this–made my evening end nicely!