Table of Contents

 

Object Map

An Object Map definition in TDL is a reusable mapping element that copies or derives data from a source object context into a target object context. Instead of writing functions to move values from one object to another, an Object Map lets you describe the mapping declaratively — pick a source, pick a target, and state what should be copied, set, reset, inserted, or deleted. It is commonly used to store derived information for an object based on what a user has entered, and to map data from a source object into a target object during Voucher or Master entry.

Syntax

Object Map : <Object Map Name> 

Example

[Object Map : TSPL Object Map Stock Item Creation]  

Set as : Name : $StockItemNameUDF 

Set as : Parent : $ParentNameUDF 

The Object Map TSPL Object Map Stock Item Creation reads two values the user typed into a form — held in the UDFs StockItemNameUDF and ParentNameUDF — and sets them as the Name and Parent of a newly created Stock Item. Capturing input into UDFs on one screen, then mapping those UDFs onto a freshly created object, is a common way to use Object Map: deriving or populating a real object from what the user has already entered. 

Click here to download Set As Attribute Sample

Copy Object attribute is used to copy an object from the Source Object context to the Target Object context. The keyword specifies whether only direct methods or the complete object, including sub-objects, should be copied. 

Syntax

Copy Object : <Keyword> 

Permissible Values: Full, Direct Methods Only (Dir Methods Only, Primary Methods Only)

Example 

Copy Object : Full 

This copies the complete source object — all its methods and sub-objects — into the target context in one step. 

This attribute deletes the objects from a collection on the target object. If an index is specified, the object at that index is deleted. If an index and condition are specified, the object at that index is deleted only when it satisfies the condition. If neither index nor condition is specified, all objects in the collection are deleted. 

Syntax 

Delete Collection Object : <Name of collection> [: <Index> [: <Condition>]] 

Permissible Values: Index accepts 1 (first object), -1 (last object), or the keywords First / Last / All 

Example 

Delete Collection Object : GSTDetails : first : ##vIsObjectsCleared  

Delete Collection Object : AllInventoryEntries : 1 : Yes 

The first line deletes the first object in the GSTDetails collection, but only when the variable vIsObjectsCleared is true. The second unconditionally deletes the first object in the AllInventoryEntries collection. 

Insert Collection Object inserts a new object inside a sub collection on the target, and switches the target context to that newly created object, so subsequent attributes set values on it. Only one Insert Collection Object is permitted directly within a single Object Map; for multiple inserts, use separate Object Map definitions or the Repeat attribute. 

Syntax 

Insert Collection Object : <Collection Name> 

Example 

[ObjectMap: TSPL Object Map PartyLedgerEntry] 

Insert Collection Object  : AllLedgerEntries 

Set as : LedgerName : “Cash”             : Yes 

Set as : IsDeemedPositive : Yes          : Yes 

Set as : Amount : -($$AsAmount:300)      : Yes 

Set as : IsPartyLedger : Yes             : Yes 

This inserts a new object into the target Voucher’s AllLedgerEntries collection, moves the target context onto it, and the Set As statements that follow populate it as the party’s ledger entry — LedgerName, whether it’s a debit or credit (IsDeemedPositive), the Amount, and a flag marking it as the party ledger. The same voucher build repeats this pattern three more times, inserting into InventoryAllocations, Batch Allocations and Accounting Allocations — which is exactly why only one Insert Collection Object is allowed per Object Map: each sub-collection insert gets its own definition, chained together with the Object Map attribute.

Local Formula lets an Object Map define its own Formula with the expression value, the same way a Field or Function can. Once defined, the value can be retrieved anywhere later in the same Object Map using the $ prefix, the same way a method is retrieved from a primary object. 

Syntax 

Local Formula : <Formula Name/Label> : <Expression> 

Example 

Local Formula : LFValidMobile : $$StringLength:$MobileNo = 10 

Set As        : MobileValid   : $LFValidMobile 

This defines a local formula LFValidMobile that checks whether the source’s MobileNo method is exactly 10 characters long, then retrieves it via $LFValidMobile to set the target’s MobileValid storage. 

An Object Map is used to call another Object Map definition. When the condition evaluates true, control passes to the named definition; once it finishes executing fully, control returns to the point right after the call. This is useful for logically segregating certain mappings into their own definitions. 

Syntax 

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

Example 

[ObjectMap: TSPL Object Map Create Voucher] 

Set as : Date : ($$Date:”01-05-2023″) : Yes 

Object Map : TSPL Object Map PartyLedgerEntry     : Yes 

Object Map : TSPL Object Map SalesLedgerEntry : Yes 

After setting the voucher header fields, this calls two separate Object Map definitions — one to build the party’s ledger entry, one for the sales ledger entry — each unconditionally (the trailing Yes). The sales-entry Object Map itself goes on to call a third, TSPL Object Map InventoryEntries, which calls a fourth for Batch Allocations, which calls a fifth for Accounting Allocations — a whole voucher assembled as a chain of small, purpose-named Object Maps rather than one large one. 

Repeat walks over an entire collection and perform the mapping for each object in it, with the current collection.The target object is not changed while repeating. This is used to logically segregate certain actions while walking over a collection, and the condition is evaluated with respect to the source object context. 

Syntax 

Repeat : <Object Map Definition Name> : <Collection Name> [: <Condition>] 

Example 

Repeat : InsertInvEntry : Inventory Entries : Yes 

This walks over every object in the Inventory Entries collection of the source, and for each one where the condition holds true, executes the Object Map InsertInvEntry with that object as the source. The Ledger Import case elsewhere in this document achieves a similar result differently, using Walk Collection as a Function-level action — looping outside the Object Map, creating a fresh target object and calling Execute Object Map once per row — rather than looping from inside a single Object Map.

Set As initializes and sets the value of a storage on the target object, optionally conditionally. If a value, method or system formula is not specified, the system checks whether a value of the same name exists in the source context, and copies it across if it does. 

Syntax 

Set As : <Storage Name> [: <Value/ Method of Source Obj/ System Formula> [: <Condition>]] 

Example 

[Object Map : TSPL Object Map Stock Item Creation] 

Set as : Name : $StockItemNameUDF ; Used as storage at ‘[Field: TSPL Object Map Stock Item Field]’ 

Set as : Parent : $ParentNameUDF ; Used as storage at ‘[Field: TSPL Object Map Parent Field]’ 

The target here is a newly created Stock Item object, created just before this Object Map runs. The first line sets its Name from $StockItemNameUDF, the second sets its Parent from $ParentNameUDF — both UDFs are populated earlier by two ordinary entry fields on a form, so this Object Map is the step that turns typed-in values into a real master. 

Set Multi Values initializes and sets several methods on the target object in one statement, all under a single shared condition. For each method named, the system checks whether a value of the same name exists in the source context, and copies it across if it does. 

Syntax 

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

Example 

Set Multi Values : FromDate, ToDate 

This copies FromDate and ToDate from the source object to the same-named storages on the target object in a single statement. 

Set Var is used to set values to the variables declared with Variable. The value is evaluated with respect to the Source Object context set by the Source Object attribute, and can be made conditional. 

Syntax 

Set Var : <Variable Name> : <Value/ Method/ System Formula> [: <Condition>] 

Example 

[Object Map: TSPL SetVar With Condition] 

Variable : SvLedger : String   

Set Var : SvLedger : “TallyPrime” : $$InCreateMode and $$IsBillWiseOn 

This sets the variable SvLedger to the value “TallyPrime”, but only when the condition $$InCreateMode and $$IsBillWiseOn evaluates to true. Both the value and the condition are evaluated against the Source Object context.

Target Object Ex identifies an object in the specified collection using the given index and optional condition. If the specified object exists, it is used as the Target Object. If it does not exist, a new object is inserted into the collection and used as the Target Object. 

Syntax 

Target Object Ex : <Name of collection> : <Index> [: <Condition>] 

Permissible Values: Index accepts 1 (first object), -1 (last object), or the keywords First / Last / All 

Example 

[Object Map: TSPL Object Map Address] 

Target Object Ex : LedMailingDetails : 1 : ($ApplicableFrom=$LedMailingApplicableFrom) 

Set as : Mailing Name : $LedName     : Yes 

Set as : ApplicableFrom: ##Svcurrentdate     : Yes 

This looks for the first object in the target Ledger’s LedMailingDetails collection whose ApplicableFrom matches $LedMailingApplicableFrom from the source. If a mailing-details entry for that date already exists, it’s reused and updated; otherwise a new one is inserted — either way, the Set As statements that follow populate it with the imported Mailing Name and the current date. 

Object Map supports declaring variables at the definition level, the same way a Function or Field can. Simple, compound and list variables are all supported, and once declared they are available for use anywhere later in the same Object Map, or in a definition it calls. When a variable’s initial value is specified at declaration, that value is evaluated against the inherited Source Object. 

Syntax 

Variable: <Variable Name> : <Variable Type> [: <Value/ Method/ System Formula>] 

Example 

[Object Map: TSPL SetVar With Condition] 

Variable : SvLedger : String 

This declares a variable named SvLedger of type String inside the Object Map TSPL SetVar With Condition.

Is this information useful?
YesNo
TallyHelpwhatsAppbanner
Is this information useful?
YesNo
TARA