Context Logic

From iDempiere en
Jump to navigation Jump to search

Context Logic Explained

Note, this page is work in progress, please feel free to contribute and help completing the documentation

There are many places within iDempiere where the application manages Context Logic and is difficult to keep track of all the possibilities of every field. This wiki page tries to collect the documentation about the fields and the possibilities of each logic.

Conditional Context Logic

Used in

Column Class
AD_Tab.DisplayLogic org.adempiere.impexp.GridTabCSVExporter.export
AD_InfoProcess.DisplayLogic org.adempiere.model.MInfoProcess.isDisplayed
AD_Field/AD_UserDef_Field.DisplayLogic
AD_Process_Para.DisplayLogic
org.compiere.model.GridField.isDisplayed
AD_Column/AD_Field/AD_UserDef_Field.ReadOnlyLogic org.compiere.model.GridField.isEditable
AD_Process_Para.ReadOnlyLogic org.compiere.model.GridField.isEditablePara
AD_Column/AD_Field/AD_UserDef_Field.MandatoryLogic
AD_Process_Para.MandatoryLogic
org.compiere.model.GridField.isMandatory
AD_Tab.DisplayLogic org.compiere.model.GridTab.isDisplayed
org.adempiere.webui.adwindow.AbstractADTabbox.isDisplay
org.adempiere.webui.adwindow.CompositeADTabbox.updateBreadCrumb / updateTabState
AD_Tab/AD_UserDef_Tab.ReadOnlyLogic org.compiere.model.GridTab.isReadOnly
AD_InfoColumn.DisplayLogic org.compiere.model.MInfoColumn.isDisplayed
AD_ZoomCondition.ZoomLogic org.compiere.model.MZoomCondition.findZoomWindowByTableId / findZoomWindowByTableId
AD_Workflow.DocValueLogic org.compiere.wf.DocWorkflowManager.process
AD_StyleLine.DisplayLogic org.adempiere.webui.adwindow.GridTabRowRenderer.applyFieldStyle
org.adempiere.webui.editor.WEditor.buildStyle
org.adempiere.webui.adwindow.GridTabRowRenderer.applyFieldStyle
AD_ToolBarButton.DisplayLogic org.adempiere.webui.adwindow.ToolbarCustomButton.dynamicDisplay
org.adempiere.webui.adwindow.ToolbarProcessButton.dynamicDisplay

Syntax

format := {expression} [{logic} {expression}]
expression := @{context}@{operand}{value} or @{context}@{operand}{value}
logic := {|}|{&}
context := any global or window context
value := strings or numbers
logic operators := AND{&} or OR{|} with the previous result from left to right
operand := eq{=}, gt{>}, le{<}, not{~^!}

In other words, a conditional context logic is composed by one or several expressions (comparisons) processed from left to right with AND or OR operators, in this statement is important to note:

  • Expression: means a comparison between a context variable and a constant (also between two constants or two context variables)
  • Context variable can be:
Syntax Example Description
@#Variable@
@#AD_Org_ID@
These variables starting with # are set at login time
@$Variable@
@$C_AcctSchema_ID@
Accounting variables (starting with $) also set at login time
@Variable@
@C_Tax_ID@
This usually refers to a field in the current window (or another process parameter in the process dialog)
@TabNo|Variable@
@0|C_Tax_ID@
This refers to a field on the specified tab (tab numbering starts with zero)
@~Variable@
@~C_Tax_ID@
When the variable starts with ~ that means a field in the CURRENT tab, do not look for fields in the other tabs
@P|Variable@
@P|C_Country_ID@
These are preferences, sometimes defined at login time, sometimes defined by the user
@AnyVariable:Default@
@0|C_Tax_ID:0@
At the end of any of the variables described above, you can set a default to be set when the variable is null or it doesn't exist, the default is defined at the end of the variable after a colon :
@AnyVariable.Column@
@AD_Org_ID.Name@
This is a way to obtain and compare values from foreign tables, in the example it gets the Name from the table AD_Org for comparison
  • Note that when checking a context variable ending with _ID the null is replaced with a zero value
  • Constants are strings or numeric values, the constants don't need to be surrounded by quotes, but if they are surrounded by quotes they are properly managed
    • The constant empty string is defined as two quotes:
  • The expression then requires a comparison operator, these are:
    • Equals =
    • Greater than >
    • Less than <
    • Different ! or ^ or ~
  • Several expressions can be evaluated FROM LEFT TO RIGHT using AND or OR logical operators
    • the AND operator is &
    • the OR operator is |

Examples

Condition Description
1=2
This is evaluated always as false
@ElementType@=A & @IsSummary@=N & @IsDetailBPartner@=Y
If the field ElementType contains an A, and the flag IsSummary is unchecked, and the flag IsDetailBPartner is checked
@#AD_Client_ID@>0
When the field AD_Client_ID is greater than zero, this means false in System client, and true for all the other clients


SQL Context Logic

TBD

Context Variables Replacement

TBD