We're updating the issue view to help you get more done. 

Env.parseVariable not keeping unparseable variable

Description

The method parseVariable from org.compiere.util.Env class will parse some text using the provided PO class. When the variable is not present in the PO, you can use the parameter keepUnparseable to determine if the variable will be deleted from the text or if it will remain there.

This is working when the PO class is provided, but when the PO class is null the variable is ripped off the text regardless the parameter keepUnparseable.

Here is a simple test you can run in Tools > Script:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 import org.compiere.util.Env; import org.compiere.model.MUser; // Test #1, PO provided, keep unparseable = OK result = Env.parseVariable (" Test #1: @Name@ - @XXX@", MUser.get(Env.getCtx()), null, true); // Test #2, PO provided, do not keep unparseable = OK result = result + Env.parseVariable (" Test #2: @Name@ - @XXX@", MUser.get(Env.getCtx()), null, false); // Test #3, PO not provided, keep unparseable = Not OK result = result + Env.parseVariable (" Test #3: @Name@ - @XXX@", null, null, true); // Test #4, PO not provided, do not keep unparseable = OK result = result + Env.parseVariable (" Test #4: @Name@ - @XXX@", null, null, false);

Attached you can find the fix

Environment

None

Status

Assignee

Ricardo Santana

Reporter

Ricardo Santana

Labels

Tested By

Ricardo Santana

Components

Affects versions

4.1

Priority

Major