Action Execution Failed
While importing data from Excel to Tally using User Defined Function, Quantity and Rate Fields do not get imported, resulting in this error.
In an User Defined Function, there can be 2 Object Contexts at a time viz., Source and Target such that Source Context Method value can be set to Target Context Methods.
While importing data from Excel to Tally, data collected from Excel acts as a Source and Tally DB Object i.e., Stock Item, Ledger, Voucher, etc. where data is set acts as a Target Object. While setting value to Methods bearing data types, Quantity and Rate, Unit information set within the Stock Item is needed hence the Target context i.e., the Tally Inventory context is needed.
There are 2 ways of switching the context while setting value from Source Context:
1. Using Function TGTObject - We can store the Quantity and Rate in a temporary Numeric Variable. Subsequently, using Function TGTObject, switch the context to Target Object Context and parameter can be the specified variable.
Example:
[Function: Import from Excel]
00 : SET : QtyVar : $ExcelQtyNum
10 : SET : RateVar : $ExcelRateNum
20 : SET VALUE: BilledQty : $$TGTObject:$$AsQty:##QtyVar
30 : SET VALUE: Rate : $$TGTObject:$$AsRate:##RateVar
2. Using Start Block & End Block - We can also use Block Statements with Start Block and End Block which retains the object contexts which was available prior to entering this Block later. Similar to the above, we can retain the Quantity and Rate in a temporary Numeric Variable. Subsequently, within Start Block, change the object context and set value to the required methods.
Example:
[Function: Import from Excel]
00 : SET : QtyVar : $ExcelQtyNum
10 : SET : RateVar : $ExcelRateNum
20 : START BLOCK
30 : SET OBJECT
40 : SET VALUE : BilledQty : $$AsQty:##QtyVar
50 : SET VALUE : Rate : $$AsRate:##RateVar
60 : END BLOCK
Subsequent to the Block Statements, the Object context would be restored.