Object Map
In the current system, whenever you want to copy data from one object to another we used to call some functions and do the same. This methodology used to take more time. Hence, we wanted to develop an ability to copy things descriptively, i.e., using definitions and attributes.
Purpose
To store ‘derived’ information for an object from information entered by the user. Object map is the ability to map the data objects from the source object context to the target object context.
Definition – Object Map
The definition Object Map functions as a pure mapping definition and will not do anything platform TDL specific. This section covers Object Map as a definition-based capability. It covers its attributes, behaviour and sequence of execution.
Syntax
Object Map : <Object Map Name>
Definition Modifiers
Attributes |
Proposal |
Remarks |
---|---|---|
|
Supported | |
|
Not Supported | Conditional evaluation is possible through other parameters for attributes. |
Local Formula
Object Map definition supports Attribute, Local Formula and the usage is same as definitions, Function or a Field.
Attributes
Variable
The definition Object Map supports variables. You can declare a variable at the definition level in TDL and then use those variables. The Object Map supports only simple and compound variables. The list variables are also supported and variable attribute stores temporary variables for the later usage in the same or another definition.
Syntax
Variable: <Variable Name> : <Variable Type> [: <Value/ Method/ System Formula>]
where,
<Variable Name> is the name of the variable
<Variable Type> is the type of the variable
<Value/ Method/ System Formula> It is an optional parameter which takes a value/method/system formula. It gets evaluated with respect to the source object context.
The variable attribute in the object map is provided to store temporary variables for usage at a later stage in the same or another definition. During variable declaration (Ex: Variable: Name : String : $Name ) $Name evaluated against the inherited Source object.
Example
[Object Map: Om TST set var With condition]
Variable : SvLedger : String
Set Var : SvLedger : “TallyERP9” : $$InCreateMode and $$IsBillWiseOn
Set Var
The attribute Set Var used to set values to variables
Syntax
Set Var : <Variable Name> : <Value/ Method/ System Formula>[ : <Condition>]
where,
<Variable Name> is the name of the variable.
<Value/ Method/ System Formula> It is an optional parameter which takes a value/method/system formula and it is evaluated with respect to source object context.
<Condition> is the logical value and it is evaluated with respect to source object context.
In the case of Set Var (For example, Set Var : Name: $Name), it will be evaluated against the Source Object which is set by the Source Object attribute.
Example
[Object Map: Om TST set var With condition]
Variable : SvLedger : String
Set Var : SvLedger : “TallyERP9” : $$InCreateMode and $$IsBillWiseOn
Target Object
Every object map has a target object. You can modify or update the methods of this object. By default, the target object is set from the requestor’s data object (if in edit mode). It can be overridden by using the Target Object attribute. Setting a target can be done only once. Other scenarios where the target object is set: Insert Collection Object attribute.
While in the case, Target Object Ex is used and when the specified Target object exists, it will be returned. If it doesn’t exist, it will be inserted into the collection and a new object will be returned. If Target Object and Target Object Ex both are specified, only Target Object Ex will be considered.
Can the primary object be set as the target object?
Let’s say a user is in the Voucher context and is getting persisted. During this time if the user invokes the object map and changes the target to its sub-objects, then it updates. However, if the user switches the context to a different primary object [for example, Target Object : (Ledger, ‘CASH’). ], in that case, it will not be persisted.
Syntax
Target Object: <Object dotted syntax>
Target Object Ex: <Name of collection> : <Index> [: <Condition>]
Example
Target Object : .
Target Object : ..
Target Object : ().
Target Object: LedgerEntry[1].
Target Object: LedgerEntry[-1].
Target Object: LedgerEntry[1,@@SomeFilter].
Target Object: Source
It is required to switch context so that if the source needs some update. However, if the source object is not fully fetched (Source can be set with primary object) then set operations will not work.
Copy Object
It is used to copy an object from the source context into the target context. It takes condition as an input. The condition is to identify whether to copy direct methods only or include sub objects also. If the condition is evaluated TRUE, it will copy everything.
Syntax
Copy Object: <Keyword>
Where Keywords are Full, Direct Methods Only (Dir Methods Only, Primary Methods Only)
Example
Copy Object: Full
Set As
Set Asattribute is used to initialize and set value for the storage of the target object. It can be set conditionally as well based on the condition given.
Syntax
Set As: <Storage Name>[: <Value/ Method of Source Obj/ System Formula>[ : <Condition>]]
where <Value/ Method/ System Formula> and <Condition> are evaluated with respect to source object context. If Value/ Method/ System Formula is not specified, then the system will check if the value of the same name exists in the source context, and if so, will copy that value to the storage.
Example
Set As: Period : $Date
;;Checks for the same storage name in source and copies the value to target storage
Set As: GSTRegistration
Set Multi Values
Set Multi Values attribute is used to initialize and set values for the multiple methods of the target object. Can be set conditionally as well based on the condition given.
<Condition> are evaluated with respect to source object context.
The system will check if the value of the same name exists in the source context, and if so, will copy that value to the storage.
Syntax
Set Multi Values: <comma separated list of methods> [: <Condition>]
Example
Set Multi Values: FromDate, ToDate
Set Direct Values
The attribute can be used when the values from the source object need to be copied into the target object. The values can be copied where either name of storage is the same in the source and target object or the copy needs to be done using a method (storage/ biz computed method/ object compute or local formula).
Syntax
Set Direct Values : <Target storage name>[ : <Source method name>]
Example
Set Direct Values : PartyLedgerName : GSTPLTVchPartyLedgerName
Set Direct Values : Date
Reset Values
It is used to reinitialize storage (i.e, make empty) of the target object. Multiple storages can be given as comma-separated values. Can be reset conditionally as well based on the condition given. The condition will get evaluated with respect to source object context.
Syntax
Reset Values: <Storage Name(s)>[[, <Storage Name(s)>, … ] : <Condition>]
Example
Reset Values : Inv_Typ
Reset Values : oinum : @@IsGSTR1B2BAQualifier
Reset Values : HSNMasterName, Taxability
;;Reset multiple storages
Insert Collection Object
To insert the new object inside the collection. The target context is changed to the created object. So that one can set values to a newly created object. If multiple Insert Collection Object has to be done, it has to be done via multiple Object Map definition or Repeat.
Limitation: This attribute need to be single. Multiple Insert collection objects cant be done directly.
Syntax
Insert Collection Object: <collection name>
Example
;; To insert the new object inside sub-collection.
Insert Collection Object : GSTDetails
Delete Collection Object
The attribute Delete Collection Object is used to remove object/objects from the given collection. If the index is specified, that particular object in the collection gets deleted. If the index is specified along with the condition, the ‘x'(index) object which matched the condition gets deleted.
Syntax
Delete Collection Object: <Name of collection> [: <Index> [: <Condition>]]
Where
<Name of Collection> The collection is taken from the target object.
<Index> can be given as 1(first object), -1(last object), keywords – first, last, all.
<Condition> gets evaluated inside each object in the collection.
If the index & condition is not specified All objects will be deleted and are evaluated with respect to target object context.
Example
To delete collection objects conditionally
Delete Collection Object: GSTDetails : first :##vIsObjectsCleared
Delete Collection Object : AllInventoryEntries : 1 : Yes
Object Map
The attribute Object Map is used to call another object map definition. If the condition evaluates to true, then the specified object map is evaluated. When the definition is fully executed, then the execution flow will move back to this point. This is useful to segregate certain mappings logically.
Syntax
Object Map: <Definition Name> [: <Condition>]
Where,
<Condition> is evaluated with respect to the source object context.
Example
Object Map : GSTPTVchCopyMandatoryIELETallyContent : ##vIsOverridden
Repeat
The attribute Repeat is used to walk over-collection and to perform mappings. The object map definition name repeats over the entire collection.
Syntax
Repeat: <Object Map Definition Name> : <Collection Name>[ : <Condition>]
Where,
<condition> is evaluated against each object of the collection. If evaluated to True, then move to the Object Map definition name, which is executed with the current object as the Source object. The target object will not be changed. This is used to logically segregate certain actions but while walking over a collection. It is also evaluated with respect to the source object context.
<Collection> can be named collection or sub-object collection.
Example
Repeat: InsertInvEntry : Inventory Entries: Yes
Inheritable Collections
The attribute is used to mention collections that need to be gathered and cached in the object map level so that it’s sub-object map using the same collection can fetch from cached collection at its parent rather than having to gather again.
The logic implemented is such that, all the inheritable collections declared in object map and sub-object map would be cached and stored at the first object map level where the inheritable collection has been declared. If any sub-object map uses a collection declared as inheritable collection at any level above in the hierarchy, it will loop till it finds the highest object map definition where inheritable collection was defined and capture the collection from it.
Syntax
Inheritable Collections : <Collection Name>,<Collection Name>,…
Example
Inheritable Collections: Collection1, Collection2
Form Attributes
Preload Object Map
This attribute gets invoked during form construction. The condition is evaluated first, when it is true, the object map gets called. In the case of Modifies on form accept specified, before creating duplicate object this attribute is processed.
Syntax
Preload Object Map : <Object Map Name>[ : <Condition>]
Preaccept Object Map
This attribute gets invoked before the form acceptance. The condition is evaluated first, when it is true, the object map gets called. In the case of Modifies on form accept specified, after the duplicate object is accepted this attribute is processed.
Syntax
Preaccept Object Map : <Object Map Name>[ : <Condition>]
Part Attributes
Preaccept Object Map
When the condition is evaluated first, and it is true, the Object map gets called. Object map will be executed during part validation. Any interaction which leads to validation of the part will also trigger the object map.
Syntax
Preaccept Object Map : <Object Map Name>[ : <Condition>]
Behaviour
- The part will not go for validation again if any of its fields are not modified or edited, which will prevent the redundant call of the object map.
- Object map will not be invoked if the part is invisible.
- If the form has multiple parts and those parts have a child part and if for every part the Preaccept Object map attribute is defined then the order of invocation will be from left most child part to the root part.
- Object map will not be invoked for the exploded part, invisible part, and the part that has only buttons.
- For a compound part, an object map of the child parts will get executed first and then the object map of the compound part will get executed.
Line Attributes
Preaccept Object Map
When the condition is evaluated first, and it is true, the Object map gets called. Object map will be executed during line validation. Any interaction which leads to validation of the line will also trigger the object map.
Syntax
Preaccept Object Map : <Object Map Name>[ : <Condition>]
Behaviour
- The line will not go for validation again if any of its fields are not modified or edited, which will prevent the redundant call of object map.
- Object map will not be invoked if the line is invisible.
- Object map should not be specified in the compound line.
- If the part containing the line has an object map, then the line’s object map will be executed first and then the part’s object map will be executed.
Field Attributes
Preaccept Object Map
When the condition is evaluated first, when it is true, the Object map gets called. The object map will be executed during field validation. Any interaction which leads to validation of the field will also trigger an object map.
Syntax
Preaccept Object Map : <Object Map Name>[ : <Condition>]
Behaviour
- The field will not go for validation again if it is not modified or edited, which will prevent the redundant call of object map.
- Object map will not be invoked if the field is invisible/inactive/skipped.
- For a field having ‘Skip Forward’, if contains an object map, will be executed since it goes into validation.
- Object map should not be called from a compound field.
- If the field has an object map and also the line containing this field has an object map, the field’s object map will get executed first and then the line’s object map will get executed.
Additional Notes
- Field’s validate attribute will be executed first and then the object map will be executed.
- If the Field, Line and Part are Invisible, Inactive, skipped then object Map will not work but it will work with the Skip forward.
Action
ExecuteObjectMap
The action ExecuteObjectMap is used to execute object map before Recompute Query is executed, to ensure that the schema update takes place before recomputing query in the Company GST Details Report. (Cannot be achieved with preaccept object map attribute, as this attribute executes only on ‘Form accept’).
Syntax
ExecuteObjectMap : <Object Map Name>
Example
In the ‘Error Handler’, definition Object map can be called by action. ExecuteObjectMap is a new action that accepts an Object map and processes it.
[Error Handler: GSTPLT Vch ErrorHandler]
On Error : Default : Stop : ExecuteObjectMap : GSTVch InsertErrorCode
If the object map fails, the cursor will remain at the line or field which invokes the object map.
Behavior In Remote
All required fetch should be done by the caller of the object map. i.e If function call ‘ExecuteObjectMap’ then it is responsible for object fetching. Object map will only traverse(dotted notation) in specified object and does the mapping.
Function
$$LoopIndex
This function gives the loop index in the Repeat attribute of Object Map based on the depth given.
Syntax
$$LoopIndex : <Logical Value>
Example
[Object Map: ObjMap1]
Repeat: ObjMap2 : CityNames : Yes
[Object Map: ObjMap2]
Repeat: ObjMap3 : StateNames : Yes
[Object Map: ObjMap3]
Repeat: ObjMap4 : CountryNames : Yes
[Object Map: ObjMap4]
Set Var: V1 : $$LoopIndex: Yes
; Corresponds to index of Country Names collection
Set Var: V2 : ($$LoopIndex:1) : Yes
; Corresponds to index of State Names collection
Set Var: V3 : ($$LoopIndex:2) : Yes
; Corresponds to index of City Names collection
Note: Local Formula is executed each time it is invoked, hence, no defined order of execution.