Difference between revisions of "Context Logic"

From iDempiere en
(Add logic columns table to investigate)
Line 9: Line 9:
 
{| class="wikitable"
 
{| class="wikitable"
 
! Column
 
! Column
 +
! Class
 +
! Comments
 
|-
 
|-
 
| AD_Column.AlwaysUpdatableLogic
 
| AD_Column.AlwaysUpdatableLogic
−
|-
+
AD_Field.AlwaysUpdatableLogic
−
| AD_Field.AlwaysUpdatableLogic
+
AD_UserDef_Field.AlwaysUpdatableLogic
−
|-
+
| org.compiere.model.GridField.isEditable
−
| AD_UserDef_Field.AlwaysUpdatableLogic
+
| if the logic starts with <code>@SQL=</code> is parsed with #Evaluator.parseSQLLogic
 +
otherwise is parsed using #Evaluator.evaluateLogic with the value from GridField or DefaultEvaluatee
 
|-
 
|-
 
| AD_Tab.DeleteConfirmationLogic
 
| AD_Tab.DeleteConfirmationLogic
Line 203: Line 206:
 
| <pre>@#AD_Client_ID@>0</pre> || When the field AD_Client_ID is greater than zero, this means false in System client, and true for all the other clients
 
| <pre>@#AD_Client_ID@>0</pre> || 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 ==
 
== SQL Context Logic ==

Revision as of 13:01, 31 July 2026

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

Column Class Comments
AD_Column.AlwaysUpdatableLogic

AD_Field.AlwaysUpdatableLogic AD_UserDef_Field.AlwaysUpdatableLogic

org.compiere.model.GridField.isEditable if the logic starts with @SQL= is parsed with #Evaluator.parseSQLLogic

otherwise is parsed using #Evaluator.evaluateLogic with the value from GridField or DefaultEvaluatee

AD_Tab.DeleteConfirmationLogic
AD_UserDef_Tab.DeleteConfirmationLogic
AD_Attribute.DisplayLogic
AD_Field.DisplayLogic
AD_InfoColumn.DisplayLogic
AD_InfoProcess.DisplayLogic
AD_InfoRelated.DisplayLogic
AD_PrintFormatItem.DisplayLogic
AD_Process_Para.DisplayLogic
AD_StyleLine.DisplayLogic
AD_Tab.DisplayLogic
AD_ToolBarButton.DisplayLogic
AD_UserDef_Field.DisplayLogic
AD_UserDef_Info_Column.DisplayLogic
AD_UserDef_Info_Related.DisplayLogic
AD_UserDef_Proc_Parameter.DisplayLogic
AD_UserDef_Tab.DisplayLogic
AD_Workflow.DocValueLogic
AD_Column.MandatoryLogic
AD_Field.MandatoryLogic
AD_Process_Para.MandatoryLogic
AD_UserDef_Field.MandatoryLogic
AD_UserDef_Proc_Parameter.MandatoryLogic
REST_ViewColumn.MandatoryLogic
AD_ToolBarButton.PressedLogic
AD_Column.ReadOnlyLogic
AD_Field.ReadOnlyLogic
AD_Process_Para.ReadOnlyLogic
AD_Tab.ReadOnlyLogic
AD_ToolBarButton.ReadOnlyLogic
AD_UserDef_Field.ReadOnlyLogic
AD_UserDef_Proc_Parameter.ReadOnlyLogic
AD_UserDef_Tab.ReadOnlyLogic
REST_ViewColumn.ReadOnlyLogic
AD_Window.TitleLogic
AD_Scheduler.WebSessionLogic
AD_ZoomCondition.ZoomLogic


Used in

Column Class
AD_Tab.DisplayLogic org.adempiere.impexp.GridTabCSVExporter.export
AD_InfoProcess.DisplayLogic org.adempiere.model.MInfoProcess.isDisplayed
AD_Field.DisplayLogic
AD_UserDef_Field.DisplayLogic
AD_Process_Para.DisplayLogic
org.compiere.model.GridField.isDisplayed
AD_Column.ReadOnlyLogic
AD_Field.ReadOnlyLogic
AD_UserDef_Field.ReadOnlyLogic
org.compiere.model.GridField.isEditable
AD_Process_Para.ReadOnlyLogic org.compiere.model.GridField.isEditablePara
AD_Column.MandatoryLogic
AD_Field.MandatoryLogic
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.ReadOnlyLogic
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.

NOTES:

  • In process parameters this syntax just works for columnnames where the tablename is implicit in the name (like Table Direct).
  • In Tab Display Logic this notation doesn't work
@$env.VARIABLE@
@$env.USER@
Obtain the value from an operating system environment variable (since r8.2).

Example:

  • @$env.USER@ will be rendered as the username of the operating system
  • @$env.LANG@ will return the language of the operating system
@$sysconfig.VARIABLE@
@$sysconfig.ZK_MAX_UPLOAD_SIZE@
Obtain the value from a System Configurator variable (since r12).

Example:

  • @$sysconfig.ZK_MAX_UPLOAD_SIZE@ will return the value of the System Configurator ZK_MAX_UPLOAD_SIZE
  • 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

Logic based on a SQL query works like this:

  • no row returned means false
  • otherwise is true.

The SQL logic must start with @SQL= and it uses commonly context variables.

Preceding the query with a ! sign, this is, starting with @SQL=!, inverts the logic (no rows is true, otherwise false)

Example:

@SQL=!SELECT 1 FROM WS_WebService_Para WHERE WS_WebServiceType_ID = @WS_WebServiceType_ID:0@

Context Variables Replacement

TBD

Cookies help us deliver our services. By using our services, you agree to our use of cookies.