Table of Contents

 

 PDF

Actions

HTTP Request 

This action helps send Get and Post requests from TallyPrime to the given API and collect and consume the response in XML and JSON formats. Once the response is received, a function is called, where user can decide how to consume the response. Thus, giving user, the flexibility to choose how the response should be processed. 

The response is received in the collection ‘Parameter Collection’ whose scope is limited to the function called post action. If user needs to use this collection in a report called from the function, then this collection needs to be associated with the report via the report attribute ‘Inheritable Collection’. i.e. Inheritable Collection: Parameter Collection to be mentioned in the report. 

Syntax 

Action : HTTP Request : <URL> : <HTTP Method> : <Request Format > : <Encoding> : <Request Report>: <Post Action Function> 

Where, 

< URL> The list of URLs to which the request should be made. If the request to a URL is successful then the rest of URLs are ignored 

<HTTP Method> HTTP Method of the request can be GET or POST. If the method is GET then request body is ignored, only headers are considered. 

<Request Format> The format of the request can be XML, JSON, JSONEx 

< Encoding > is the encoding of the request – ASCII or UNICODE. 

< Request Report > is the name of the TDL Report which will be used for generating the Request to be sent. 

< Post Action Function> Function that is called post completing the action. This is the function where the response received in the collection ‘Parameter Collection’ is consumed.  

When a Get request in sent with the HTTP Request action, only the HTTP headers if mentioned in the Export Header attribute in the <Request Report> will be considered and rest of the report will be ignored. 

Example 

Here the function Get Branch List_JSON calls the action HTTP Request which sends a GET Request and receives response in json format in parameter collection. Which is further used to display a report with the status of response is 1 and a message box if the status is 0. 

[Function:Get Branch List_JSON] 

100: HTTPRequest : https://webhook.site/0377a282-fac9-4799-a05f-7970fb95f525″: GET : JSONEX: ASCII : RequestReportJSON : ShowBranchesJson 

;; Function and corresponding report to show how to consume the response obtained in Parameter Collection 

[Function: ShowBranchesJson] 

    Variable: vStatus   : Number 

    001: Walk Collection: Parameter Collection 

    002:  Set: vStatus : $Status 

    003:  Log: ##vStatus 

    006: End Walk 

    007: If: ##vStatus = 0 

    008:   Msg Box: “Error”: “Could Not Retrieve Branch List. Try Again!” 

    009: Else 

    010:   Display : BranchListReportJson 

    011: End If 

 

[Report: BranchListReportJson] 

    Inherit Collection : Parameter Collection ;; This is mandatory 

    Form                : BranchListReport 

 

[Form: BranchListReport] 

    …. 

    …. 

HTTP Post 

A new action HTTP Post has been introduced which will help in exchanging data with external applications using web services. In other words, HTTP Post action can be used to submit data to a server over HTTP and gather the response. This will enable a TDL Report to perform a HTTP Post to a remote location. 

Syntax 

Action : HTTP Post : <URL Formula> : <Encoding> : <Request Report>: <Error Report> : <Success Report > 

Where, 

< URL Formula > can be any string formula which resolves as an URL and is defined under System Definition. 

< Encoding > is the encoding scheme ASCII or UNICODE . 

< Request Report > is the name of the TDL Report which will be used for generating XML Request to be sent. 

< ErrorReport > is displayed in case of failure. 

< Success Report > is displayed when the post is successful. 

The details pertaining to URL (at the receiving end), Encoding Format, RequestReport , Error Report and Success Report should be specified along with HTTP Post Action. The Request, Error and Success reports are optional. 

Success and failure is determined by <STATUS> tag in the standard message format. If it is 1 then success else it is failure. Based on the value of the <STATUS> tag 0/1, the error report and success report are executed respectively. It will not close or accept the form if status is not equal to 1. 

[Button: PostButton]

Key : Ctrl+K

Action : HTTP Post : @@MyURL : ASCII: HTTP Post ReqRep : HTTP Post Failure

Report : HTTP Post Success Report

[System: Formula]

MyURL : “http://Localhost/CXMLResponse as per tally.php”

[Report: HTTP Post ReqRep]

Form : HTTP PostReqRep

[Form: HTTP PostReqRep]

Parts : HTTP PostReqRep

[Part: HTTP PostReqRep]

Lines : HTTP PostReqRep

XML Tag : “REQUEST”

Scroll : Vertical

[Line: HTTP PostReqRep]

Fields : HTTP PostReqRepName, HTTP PostReqRepPwd

[Field: HTTP PostReqRepName]

Set As : “TALLY”

XML Tag : “NAME”

[Field: HTTP PostReqRepPwd]

Set As : “00000”

XML Tag : “EMPID”

[Report: HTTP Post Failure Report]

…..

….

[Field: HTTP Post Failure Report]

Set As : “Unable to access data”

[Report: HTTP Post Success Report]

….

….

[Part: HTTP Post Success Report]

Lines : HTTP Post Success Report

Repeat: HTTP Post Success Report : Parameter Collection

Scroll : Vertical

….

….

The defined Key PostButton in the snippet above must be attached to an initial Report. When the report is activated and this Key is pressed, the Action HTTP Post activates a defined report HTTP Post ReqRep which generates the request XML. The response data is made available in collection called Parameter Collection. The reports HTTP Post Failure Report and HTTP Post Success Report can use the Parameter Collection to display the error message/data in the Report. 

TallyHelpwhatsAppbanner
Is this information useful?
YesNo
Helpful?
TARA