Table of Contents

 

 PDF

Form Attributes 

Resource 

This attribute is used in the context of the capability Customisation using productivity suites, where data can be exported to a designed document template in productivity suite, by mapping the data in a form definition. The attribute Resource at Form definition is used to specify the name of the Resource definition, which provides the details of the document template. This document template is used for exporting/printing the Form. 

Syntax 

[Form: <Form Name>] 

Resource: <Resource Name> 

Where, 

< Resource Name > is the name of the resource definition. 

Map/XML Map/JSON Map 

Map/XML Map/JSON Map is a Form level list type attribute, used to provide correct value for the token(s) specified in the document template. This attribute is used to map the data with the tokens specified in the document template (MS word, MS Excel, XML, JSON) while using the capability of customization using productivity. Token is an alpha-numeric value without any spaces, prefixed with $. No special characters are allowed in the token name. It is an expression specified in the document template to map the values from TallyPrime. 

For example, $Name, $CmpName, $FrDate, $Val1 

When the document template is used for exporting/printing: 

  • The defined tokens in the document template are substituted with the respective values by evaluating the expression in Map attribute, against the defined token. 
  • If the token is not defined in the document template, it evaluates as a method in current object context. A token refers to a method of current object context. In this case, defining Map is not necessary. 
  • Map also allows specification of repeatable data, when it is referenced in TallyPrime. It creates a required number of rows/entries for each object in the collection. 

Syntax 

[Form: <Form Name>] 

Map: <Map Name>: <Expression >[:<Collection Name>] 

                                                         OR 

JSON Map: <Map Name>: <Expression >[:<Collection Name>] 

                                                         OR 

XML Map: <Map Name>: <Expression >[:<Collection Name>] 

Where, 

< Map Name > is the name of the token specified in the document template for evaluating the value. 

< Expression > is a valid TDL expression such as method, variable, system formula. 

< Collection Name > is specified where the token is defined for repeating the data. It is an optional parameter. 

Map, XML Map, JSON Map are aliases of each other. Specifying any one of them in the Form definition and will provide the mapping for the tokens irrespective of the type of document template. 

Example: MS Word 

[Resource: InvoiceWord] 

Source : “D:WorkInvoiceWord.xml”

;;It is the word document saved as .xml(WORDXML)

Resource Type : Word XML 

[Form: InvFrm] 

Resource : InvoiceWord 

Map : BasicSDN : @@DelNoteNo 

Map : SVCompany : ##SVCurrentCompany 

Map : Rate : $Rate : Inventory Entries 

[System: Formula] 

DelNoteNo : $BasicShipDeliveryNote 

In the example, InvoiceWord is the name of the resource. BasicSDN , SVCompany and Rate are the tokens which are defined in the document template, and values are taken from the respective second parameters, @@ DelNoteNo, ## SVCurrentCompany and $Rate:Inventory Entries. 

You can use a relative path in the attribute Source as given below: 

[Resource: InvoiceWord] 

Source : “ResourceInvoiceWord.xml” 

/*It is the word document saved as .xml(WORDXML). The specification of resource always accepts the relative path as the TDL Folder and not the TallyPrime application folder. If you mention a relative path, it is concatenated along with the absolute path of the folder where TDL File exists. */

Resource Type : Word XML 

[Form: InvFrm] 

Resource: InvoiceWord 

Map : BasicSDN : @@DelNoteNo 

Map : SVCompany : ##SVCurrentCompany 

Map : Rate : $Rate : Inventory Entries 

[System: Formula] 

DelNoteNo : $BasicShipDeliveryNote 

Use the following code to prevent printing values of  Not Applicable or  End of List . 

[System: Formula] 

DelNoteNo : If $$IsEmpty:$BasicShipDeliveryNoteor $$IsSysName:$BasicShipDeliveryNote then ” ” + else $BasicShipDeliveryNote 

Microsoft Word has a limitation to print the special character used in TallyPrime for the SysNames, Not Applicable or End of List .

For every token, TallyPrime looks for a Map definition 

  • If TallyPrime finds the specified token in the Map definition, it evaluates and replaces the specified expression. 
  • If TallyPrime does not find the specified token in the Map definition, it treats the token as a method in current object context and evaluates the value. 
  • If the value corresponding to a token is not found in the Map or in any of the object storages/methods, the token is printed as it is in the document. 
  • For example, $DutyValue is the token, and there is neither Map with this name nor any storage/method in that object context, then the system prints $DutyValue as it is, indicating that the value corresponding to the token is not available. 
  • When the collection name is specified, the specified paragraph or row in the document template is repeated for every collection object. When the objects are not found in the collection, paragraph or row is not displayed. 

Example: JSON 

This example shows how JSON document template with tokens is mapped with data values in the form definition. The document template is designed to capture distributor id and his sales information, using this template the distributor sales vouchers are exported in JSON format with structure defined in the JSON document template.  

;;Resource that has the details of the JSON document template using which the data will be exported 

[Resource: TSPL Json ColRepSupinSuite] 

Source : sales.json 

Resource Type: JSON 

[Form: TSPL Json ColRepSupinSuite] 

Resource: TSPL Json ColRepSupinSuite  

Map : DistributorId : ##SVDistributorName 

Map : TotalSales : @@TSPLDistSales 

Map: VchNum: $VoucherNumber: TSPLSalesDNVchCollection 

Map : Vchdt : $Date 

Map : VchType: If ($$IsSales:$VoucherTypeName) then “Sales” else “Debit Note” 

Map : StkName : $StockItemName : AllInventoryEntries 

Map : Qty : $BilledQty 

Map : unit : ($(StockItem,$StockItemName).BaseUnits) 

[System: Formulae] 

TSPLDistSales : $$CollAmtTotal:TSPLSalesDNVchCollection:$Amount 

[Collection: TSPLsalesVchCollection] 

Type: Vouchers : VoucherType  

Child Of: $$VchTypeSales 

Fetch: VoucherNumber, Amount, Date,VoucherTypeName, All Inventory Entries.* 

While integrating with a JSON document template, here some keywords and pointers to keep in mind 

Keywords in JSON Template 

The following keywords are used in JSON to handle special cases like ignore the object if a certain condition is satisfied. 

Keyword 

Usage 

__tlyEmptyIf 

  • Add this keyword as key : value pair within a JSON object when the value of JSON is a string type and the expression evaluates to a logical value. 
  • Use this attribute at any level in the JSON template file. When the value of this attribute is true, the object will not appear in the output. 

Example 

In this example, the array uses the keyword at the object level. When the value is true, for vouchers other than sales, it will not export the particular voucher object, except for sales vouchers. 

{ 

“Vch”: 

[ 

{ 

“Vch Num”: “$VchNum”, 

“__tlyEmptyIf” : “$Check” 

} 

] 

} 

[Form: TSPL Json ColRepSupinSuite] 

Resource: TSPL Json ColRepSupinSuite 

Map : VchNum : $VoucherNumber : TSPLVchCollection 

Map : Check : @@Check 

[System: Formula] 

Check : NOT $$IsSales:$VoucherTypeName 

__tlyEmptyIf_<JSON Tag> 

  • This attribute is similar to the attribute __tlyEmptyIf. This appears as a “key:value” pair within an JSON object, when the value of JSON is a string type and the expression evaluates to a logical value. 
  • Use this keyword to skip the value in key: value pair of a JSON object based on the condition specified. 
  • When the value of this attribute is true, the specified tag will not appear in the output. 
  • The JSON Tag used with the keyword should match with the actual JSON Tag. Tags are case and space sensitive. For exampl, if the JSON Tag is Vch Num , then the keyword would be _ _tlyEmptyIf_Vch Num . 

Example 

Here the JSON Tag Vch Num uses the keyword __tlyEmptyIf . 

{ 

“Vch”: 

[ 

{ 

“Vch Num”: “$VchNum”, 

“__tlyEmptyIf_Vch Num” : “$Check” 

} 

] 

} 

 

[Form: TSPL Json ColRepSupinSuite] 

Resource: TSPL Json ColRepSupinSuite 

Map : VchNum : $VoucherNumber: TSPLVchCollection 

Map : Check : @@Check 

[System: Formula] 

Check : NOT $$IsEmpty:$VoucherNumber 

An array member in the JSON template repeats over a collection. 

  • A collection is identified by a name specified against the first method occurring within the array. The identification can either be at the array level directly in case of an array of simple values, or within an object template in the array. 
  • If no collection name is specified against the first occurring method, then it is assumed that the template value or the object is not repeating. In this case, the array is exported with the methods being evaluated against the current object context. 

Example 

JSON Template 

TDL Code 

Result 

 

{ 

“Vch”: 

[ 

{ 

“Vch Num”: “$VchNum”, “Vch dt”:”$Vchdt” 

} 

] 

} 

 

 

 

 

[Form: TSPLJSONColRepSupinSuite] 

Resource: TSPLJSON ColRepSupinSuite 

Map : VchNum : $VoucherNumber 

Map : Vchdt : $Date: TSPLVchCollection 

 

 

 

 

Evaluates $VoucherNumber in the current context and exports Vch with single object. Ignores the Vchdt token where the collection is mentioned. 

{ 

“Vch”: 

[ 

{ 

“VchNum”:””, “Vchdt”:”” 

} 

] 

} 

  • The default value for the attribute __tlyEmptyIf or __tlyEmptyIf__ <JSON Tag> is false. 
  • If __tlyEmptyIf is mentioned at the root level and it evaluates to true, then the exported file will be empty.

To skip values or object conditionally use the keywords _tlyEmptyIf_<MemberName> or _tlyEmptyIf which appears as a key:value pair. It is not possible to specify these attributes for array members, since values within JSON arrays are not named.

TallyHelpwhatsAppbanner
Is this information useful?
YesNo
Helpful?
TARA