Explore Categories

 

 PDF

Object Map

In the current system, whenever you want to copy data from one object to another we used to call some functions. This methodology used to take more time. Hence, we wanted to provide a TDL capability to copy things descriptively using definitions and attributes.  

You can use the capability Object Map to store ‘derived’ information for an object from information entered by the user and 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

The definition Object Map supported with the following definition modifiers.

  1. Use
  2. Add
  3. Delete
  4. Replace

The following attributes are not supported.

  1. Option
  2. Switch
  3. Local

Object Map definition supports Attribute, Local Formula and the usage is same as Definition, 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.

You can use the variable attribute in the object map to store temporary variables for usage at a later stage in the same or another definition.  During variable declaration, (for example, Variable: Name : String : $Name) the method $Name is evaluated against the inherited Source object.

Example

[Object Map: TSPL SetVar With Condition]

Variable   : SvLedger        : String    

Set Var

The attribute Set Var is used to set values to the 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 or 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),the value will be evaluated against the Source Object context which is set by the Source Object attribute.

Example

[Object Map: TSPL SetVar With condition]         

    Variable   : SvLedger       : String  

    Set Var    : SvLedger        : “TallyPrime”    : $$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 it is in edit mode). It can be overridden by using the Target Object attribute. You can set the target only once and other scenarios where the target object is set with Insert Collection Object attribute.

When you use Target Object Ex and the specified Target Object exists, then the Target Object will be returned. If it doesn’t exist, it will be inserted into the collection and a new object will be returned. If both Target Object and Target Object Ex are specified, only Target Object Ex is considered.

Can the primary object be set as the target object? 

If a user is in the Voucher context and is getting persisted and when 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’). ],  then 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

If the source needs some update then it is required to switch the context. However, if the source object is not fully fetched (source can be set with primary object) then set operations will not work.   

Copy Object

Copy Object 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, the value for Keyword can be Full, Direct Methods Only (Dir Methods Only, Primary Methods Only)

Example

Copy Object: Full

Set As

The attribute Set As 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 check if the value of the same name exists in the source context or not. If it exists, it 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

The attribute Set Multi Values is used to initialize and set values for the multiple methods of the target object. It can be set conditionally based on the condition given.

The system check whether the value of the same name exists in the source context or not. If it exists, it will copy that value to the storage.

Syntax

Set Multi Values: <comma separated list of methods> [: <Condition>]

<Condition> is evaluated with respect to source object context.

Example

Set Multi Values: FromDate, ToDate

Set Direct Values

The attribute Set Direct Values is used when the values from the source object need to be copied into the target object. The values can be copied either the name of storage is same in the source and target object or the values can be copied 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

The attribute Reset Values is used to reinitialize the storage (i.e, make empty) of the target object. You can give multiple storages as comma-separated values. It 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 

The attribute Insert Collection Object to insert the new object inside the collection.  The target context is changed to the created object. By using this you can set values to a newly created object. If multiple Insert Collection Object has to be used, it has to be used via multiple Object Map definition or Repeat.

Limitation:  Use the attribute Insert Collection Object as single. Multiple Insert collection objects cannot be used 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 both index and condition are not specified, all objects will be deleted and are evaluated with respect to the 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 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, 

<Object Map Definition Name> is the name of the object map definition.

<Collection Name> is the name of the collection or sub-object collection.

<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.

Example

Repeat: InsertInvEntry : Inventory Entries: Yes

Inheritable Collections

The attribute Inheritable Collections 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 loops 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

The attribute Preload Object Map gets invoked during form construction. The condition is evaluated first, when it is true, the object map gets called. In the case of Modifies is specified on form accept, before creating duplicate object this attribute is processed.

Syntax

Preload Object Map : <Object Map Name>[ : <Condition>]

Preaccept Object Map

The attribute Preaccept Object Map 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 is specified on form accept, after accepting the duplicate object, 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, and 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

  • The field attribute validate will be executed first and then the object map is 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 when it is invoked, hence, no defined order of execution.

TallyHelpwhatsAppbanner
Is this information useful?
YesNo
Helpful?
/* */