Field Related Attributes
Background
The attribute Background is used to set the Background Color of a Field in Display mode.
Syntax
[Field : <Field Name>]
Background : <Color Name Formula>
Example:
[Field : Party Ledger Name]
Background : Yellow
Print BG : Red
Validate
This attribute checks if the given condition is satisfied. Unless the given condition for Validate is satisfied, the user cannot move further, i.e., the cursor remains placed on the current field without moving to the subsequent field. It does not display any error message.
Syntax
Validate : <Logical Formula>
Example
[Field : CMP Name]
Use : Name Field
Validate : NOT $$IsEmpty : $$Value
Storage : Name
Style : Large Bold
In this example:
- The field CMP Name is a field in Default TDL which is used to create/ alter a Company.
- Attribute ‘Validate’ stops the cursor from moving forward, unless some value is entered in the current field.
- The function $$IsEmpty returns a logical value as TRUE, only if the parameter passed to it contains NULL.
- The function $$Value returns the value entered in the current field.
- Thus, the Attribute ‘Validate’, used in the current field, controls the user from leaving the field blank, and forces a user input.
Unique
This attribute takes a logical value. If it is set to Yes, then the values keyed in the field have to be unique. If the entries are duplicated, an error message Duplicate Entry pops up. This attribute is useful when a Line is repeated over UDF/Collection, in order to avoid a repetition of values.
Syntax
Unique : [Yes/No]
Example
[!Field : VCHPHYSStockItem]
Table : Unique Stock Item : $$Line = 1
Table : Unique Stock Item, EndofList
Unique : Yes
In this code snippet, the field VCHPHYSStockItem is an optional field in DefTDL , which is used in a Physical Stock Voucher. The attribute Unique avoids the repetition of Stock Item names.
Notify
It is similar to attribute Validate. The only difference is that it flashes a warning message and the cursor moves to the subsequent field. A system formula is added to display the warning message.
Syntax
Notify : <System Formula> : <Logical Condition>
Example :
[!Field : VCH NrmlBilledQty]
Set as : if @@HasInvSubAlloc then $$CollQtyTotal: BatchAllocations : $BilledQty else @ResetVal
Skip On : @@HasInvSubAlloc
Style : if @@IsInvVch then “Normal” else “Normal Bold”
Notify : NegativeStock :##VCFGNegativeStock AND @@IsOutwardType AND$$InCreateMode AND $$IsNegative: @@FinalStockTotal
Here, VCH NrmlBilledQty is a default optional field in TDL used in a Voucher. ‘Notify’ pops up a warning message, if the entered quantity for a stock item is more than the available stock, and the cursor moves to the subsequent field.
Control
The attribute Control is similar to Notify. The only difference is that it does not allow the user to proceed further after displaying a message. The cursor does not move to the subsequent field.
Syntax
Control : <System Formula> : <Logical Condition>
Example
[Field : VCH Number]
Use : Voucher Number Field
Inactive : @@NoVchNumbering
Skip On : @@AutoVchNumbering
Control : DuplicateNumber : @@NoDupVchNumbering AND (NOT $$InAlterMode OR NOT @SameVchTypeAndNum)AND
$$IsDuplicateNumber : $$Value : SameVchTypeAndNum : $VoucherTypeName = ##ORIGVchType AND $$Value = ##ORIGVchNum
Validate : (@@NoDupVchNumbering AND NOT $$IsEmpty:$$Value) OR NOT @@NoDupVchNumbering
Keys : PrevVchNumber
In this example, the field, VCH Number is a default field in TDL, used in a Voucher. The duplication of voucher numbers for a particular voucher type is prevented by using the attribute Control.
Print BG
The Print BG attribute is used to set the Background Color of a Field in Print mode.
Syntax
[Field : <Field Name>]
Print BG : <Color Name Formula>
Example:
[Field : Party Ledger Name]
Print BG : Red
Cell Write
When the data is exported from an external application to Excel Format, especially in the following scenarios, Excel faces refresh issues. Here, we are considering the scenarios when Tally exports the data into Excel.
- When a cell in an Excel Template is having a formula which depends on multiple cells which are being written from Tally. If one out of these cells is having a drop-down list, then the excel formula is not refreshed after the Export.
- If the design of Excel template is depending on one of the Excel cells, and this cell is written by Excel Export from Tally, then the template using the contents of this cell will not take these changes into effect.
This problem can be addressed at the TDL level by writing those data corresponding to cells prior to on the one on which the rest of the cells containing the formula/template are dependent. The rest of the data can be written as a chunk only.
For this purpose, the attribute ‘Cell Write’ has been used at Field. This attribute enables writing of the specific field value in the Excel file, before the entire information gets written.
This attribute has to be used judiciously and strictly as per the above scenarios, since this will increase the export time multifold.
Syntax
Cell Write : <Logical Value>
Where,
<Logical Value> can be YES or NO.
Example
[Field : VAT acc Rate Fld]
Cell Write : YES
Format
The attribute Format is used in the Field definition. It determines the Format of the value being displayed/printed within the Field.
Syntax
[Field : <Field Name>]
Format : <Formatting Values separated by comma>
The value for the attribute Format varies, based on the data type of the Field.
Field of Type Number
Example:
[Field : My Rate of Excise]
Set AS : $BasicRateOfInvoiceTax
Format : “No Comma, Percentage”
Field of Type Date
Example:
[Field : Voucher Date]
Set AS : $Date
Format : “Short Date”
Field of Type Amount
Example:
[Field : Bill Amount]
Set AS : $Amount
Format : “No Zero, No Symbol”
Field of Type Quantity
Example:
[Field : Bill Qty]
Set as : $BilledQty
Format : “No Zero, Short Form, No Compact”
Format for Quantity Data Type
In Tally quantity of a Stock item can be expressed using a Simple or Compound Unit of Measure. Simple Unit – Unit of measure used to express the quantity of an item. E.g., kgs, nos, pcs, etc. Compound Unit – The unit of measure which is a combination of Simple units related to each other by a conversion factor, is termed as a Compound Unit. Examples of compound units are kg of 1000 gms, dozen of 12 nos, etc. In the case of the compound unit, the highest unit is referred to as the Base/Primary unit and the subunits thereafter, are referred to as the Tail units. The quantity is always expressed in terms of the Primary unit. A compound unit can be nested further to contain another compound unit as a Tail unit, up to any no. of levels. E.g., Bag of 10kgs of 1000 gms.
Example, if the unit of measure used for a Stock item “Grains” is Bag of 10kgs of 1000 gms and the closing balance is 12-5-250 bags, it means that the quantity of items is 12 bags 5 kgs 250 gms. Whenever the tail unit quantity crosses the conversion factor, it adds up to the bigger unit. If the gms part exceeds 1000 in this example and the value is 12-5-1250 bags, then it will be converted to 12-6-250 bags.
In TDL, the data type to support representation & storage of data of the above type is Quantity. It comprises of subtypes Number, Base/Primary units, Alternate/Secondary units and unit symbol.
We know that when a method of type ‘Quantity’ is retrieved in a report, it is always expressed in terms of primary units. In case the Unit of Measure is a nested compound unit, the user may require the quantity in terms of any of the units in the entire Compound unit chain. The ‘Format’ attribute of Field has been enhanced to specify the Tail unit, in which the quantity value needs to be extracted.
Syntax
[Field : <Field Name>]
Type : Quantity
Set As : $<Method Name>
Format : “Tail Units:” + <String Expression>
Where,
<String Expression> must evaluate to any Tail Unit Name used in the Item.
Example
As per the previous example, the unit of measure used for the Stock item “Grains” is Bag of 10kgs of 1000 gms and the closing balance is 12-5-250 bags. In a field, we may require to retrieve the value in kgs or gms instead of bags. For this, the following specification can be used:
[Field : Qty Format Enhancement]
Use : Qty Primary Field
Set As : $Closing Balance
Format : “Tail Units:” + “kgs”
- If Format is “Tail Units:kgs”, value returned is 125kgs250 gms=12X10 kgs+5kgs & 250 gms
- If the Format is “Tail Units:gms”, the value returned would be 125250 gms = 12X10X1000 gms+ 5X1000 gms +250 gms.
Appropriate conversions take place as per the conversion factors set in the nested Compound unit chain.
MAX
You can use the attribute MAX at field definition to specify the maximum number of characters that can be entered in the field. It also helps to control the field length with some specific number of characters based on a conditional expression. The expression is evaluated while opening the report.
Alias for this attribute is Maximum . This attribute accepts a number which is less than 972.
Syntax
MAX : <Numerical Expression/Constant>
Where,
< Numerical expression > evaluates to a number.
For example, in Tally.ERP 9, the field PAN/National Identity Number accepts only 10 characters, because India restricts the PAN number with 10 characters. However, by using this attribute enhancement, based on the country selected, we can control the length of the field.
Example
Max :If $$Number:$OpeningBalance:Ledger:”Cash”< 6 then 9 else $OpeningBalance:Ledger:”Cash”
Modifies
If a field had Modifies parameter, the field value would be set to the variable. And based on this variable value, some calculations or concatenation was required to be performed. An invisible field was required for the same. With the enhancement in this Release, one can modify the variable value at the same field itself using an expression, i.e., the field, and the variable may have different values.
Syntax:
Modifies : <Variable Name> : <Logical Value> : <expression>
Where,
<Variable Name> is the name of the variable.
<Logical Value> is any expression which evaluates to a logical value.
<Expression> can be used to modify the variable value within the field.
Example
[Field : BatchesInGodown]
Modifies : DSPGodownName : Yes : ##DSPGodownName + “ – Godown”
Set By Condition
The attribute Set By Condition is similar to a conditional Set at Field level. If multiple Set By Condition are mentioned under a Field, then the last satisfied Set By Condition will be executed.
Syntax
Set By Condition : <Condition> : <Value>
Where,
< Condition > is any logical formula.
< Value > is any string or a formula.
Example:
[Field : Sample SetbyCondition]
Set as : “Default Value”
SetbyCondition : ##Condition1 : “Set by Condition 1”
The Field Sample SetbyCondition will contain the value Set by Condition1 if the expression Condition1 returns TRUE, else the Field will contain the value Default Value.
Switch
The attribute modifier Switch is similar to the Option attribute, but reduces code complexity and improves the performance.
The modifier Option compulsorily evaluates the conditions for all the options provided in the description code, and applies all the option statements which satisfy the evaluation conditions. This means that it is not easy to write the code where you just want one of the options to be applied. You have to make sure that other options are not applied using a negative condition. The attribute modifier ‘Switch’ has been provided to support these types of scenarios, where evaluation is carried out only up to the point where the first evaluation process has been cleared.
Apart from this, Switch statements can be grouped using a label. Therefore, multiple switch groups can be created and zero or one of the switch cases would be applied from each group.
Syntax
Switch : <Label> : <Definition Name> : <Condition>
Switch : <Label> : <Definition Name> : <Condition>
If multiple Switch statements are mentioned within a single definition, then the evaluation will be carried out up to the point where the first condition is satisfied for the given label.
Example: 1
[Field : Sample Switch]
Set as : “Default Value”
Switch : Case1 : Sample Switch1 : ##SampleSwitch1
Switch : Case1 : Sample Switch2 : ##SampleSwitch2
Here, out of multiple switch statements having same label, zero or one statement is executed.
Example: 2
[Field : Sample Switch]
Set as : “Default Value”
;; If none of the condition is TRUE then Field will have Default Value
Switch : Case1 : Sample Switch1 : ##SampleSwitch1
Switch : Case1 : Sample Switch2 : ##SampleSwitch2
Switch : Case2 : Sample Switch3 : ##SampleSwitch3
Switch : Case2 : Sample Switch4 : ##SampleSwitch4
Here, multiple switch groups are created, and zero or one of the switch cases would be applied from each such group or label.
Table Search
A field attribute called Table Search has been used to achieve the above capability.
Syntax
[Field : <Field name>]
Table Search : <Enable reducing table search> : <Apply search to all columns>
Where,
<Enable reducing table search> is a logical value (YES/NO), to specify whether we want to enable the reducing of search or not.
<Apply search to all columns> is a logical value (YES/NO), to specify whether the search criteria should apply to all columns of the table or not.
We can also use expressions in attribute values which evaluate to logical values.
Tool Tip
As the name suggests, the value specified with this attribute is displayed when the mouse pointer is placed on a particular field. This means that, in addition to the static information displayed by Info or Set As attributes, we can provide additional meaningful information using this attribute.
In other words, when the user hovers the mouse pointer over the Field, a small hover box appears with supplementary information regarding the item being pointed over. As against attributes Info or Set As , this attribute value is independent of the Field Width.
Syntax
Tool Tip : <Value>
Where,
< Value > can be a String or a Formula.
Example:
[Field : Led Name]
Storage : Name
Tool Tip : “Please Enter the Name of the Ledger”
Trigger
When a table is displayed from a field, and a new value is to be added to the same table, the attribute Trigger is used. It invokes a report. For example, adding a new number in fields using dynamic tables such as Tracking number, Order No, etc.
Syntax
Trigger : <Report Name> : <Trigger Condition>
Where,
<Report Name> is the name of the report which is invoked if <Trigger Condition> is True. The value entered in the Output field of the <Report Name> is added to the table in the field.
Example
[Field : FieldTrigger]
Use : Name Field
Table : New Number, Not Applicable
Show Table : Always
Trigger : New Number : $$IsSysNameEqual:NewNumber:$$EditData
CommonTable: No
Dynamic : “”
In the field “FieldTrigger”, a report “New Report” is called when the option New Number is selected from the pop-up table. When the value has to be obtained from the complicated flow, a report name does not suffice. To support this functionality, the attribute Trigger Ex is used. This attribute allows adding values to the dynamic table through an expression or user-defined functions.
Trigger Ex
The Trigger Ex attribute allows adding values to the dynamic table through an expression or user-defined function.
Syntax
TriggerEx : <Value-expression> : <Trigger Condition>
Where,
<Value Expression> is an expression/function which evaluates to a String if <Trigger Condition> is True. The string value thus obtained is added to the dynamic table.
Example
[Field : FieldTriggerEx]
Use : Name Field
Table : Ledger, New Number, Not Applicable
Show Table : Always
TriggerEx : $$FieldTriggerEx:$$IsSysNameEqual:NotApplicable:$$EditData
CommonTable : No Dynamic : “”
In the field, if the user selects any ledger from the table, the function $$FieldTriggerEx returns the parent, i.e., Group name of the ledger selected, and adds to the table “Ledger”.
[Function : FieldTriggerEx]
01 : RETURN : $Parent : Ledger : $$EditData
Press Backspace in the report to view the additions to the table Ledger.