What is wrong with the way I am calling the script? Pls help

Greetings Friends,

I keep having trouble when I call a script.

I have made the following template, for listing a ticket:

[LAYOUT]

<L00><SIZE 20><bold>Ticket:[=TN('{TICKET NO}'.substr(12))-2000]</bold></SIZE> <SIZE 16><bold>[='{DEPARTMENT}' == 'Rolly Poli Takeaway' ? 'Parcel' : 'Eat In']</bold></SIZE> 

<L00><SIZE 20><bold>Ticket:{CALL:rfqs.ReduceTicketNumber(TN('{TICKET NO}'.substr(12)))}</bold></SIZE> <SIZE 16><bold>[='{DEPARTMENT}' == 'Rolly Poli Takeaway' ? 'Parcel' : 'Eat In']</bold></SIZE> 

<L00>{TICKET STATE:Delivery}
<F>-
<L00><SIZE 14>T:{TICKET TIME}   D:{TICKET DATE}</SIZE>
<EB>
{ORDERS}
<DB>
<F>-
[ORDERS]
<F>-
<L00><SIZE 16><bold>- {QUANTITY} x {NAME}</bold></SIZE>
{ORDER TAGS}
[ORDERS:Void]
<J00>- {QUANTITY} x {NAME}|**Void**
{ORDER TAGS}

[ORDER TAGS]
-- Format for order tags
<L00><SIZE 14>     * {ORDER TAG NAME}</SIZE>

The code of my script is as follows:

function ReduceTicketNumber(nTicketNo) {
if (nTicketNo) > 2000 {
	nTicketNo = nTicketNo - 2000;
}
	return (nTicketNo);
}

When I deduct 2000 from the Ticket No within the template, it shows the right result.

But, the script, which is supposed to do the same, is not returning any value at all. Where am I going wrong? Please do help…

Regards,

Somil

are you sure you have 16 digit (12 digits + 2000) ticket number.

yes, my ticket number format is TAM/2017-18/xxxx where xxxx is the Ticket Number

That ^ is not correct.

if (nTicketNo > 2000) {
This ^ is correct syntax

Obviously you haven’t run test you script. It will throw “Syntax error”

I made the change, still getting no value back from the function!

Oh , you can’t use TN in call.
{CALL:rfqs.ReduceTicketNumber('{TICKET NO}')}

function ReduceTicketNumber(nTicketNo) {
nTicketNo = Number(nTicketNo.substr(12)); //Add this line to sub string and make sure it is number
if (nTicketNo > 2000) {
nTicketNo = nTicketNo - 2000;
}
return nTicketNo;
}

@Jesse How can I format this quote thing lol. Can’t add tab/indent.

function ReduceTicketNumber(nTicketNo) {
    nTicketNo = Number(nTicketNo.substr(12)); //Add this line to sub string and make sure it is number
    if (nTicketNo > 2000) {
        nTicketNo = nTicketNo - 2000;
    }
    return nTicketNo;
}

This better but can’t do Bold

Type ` at start and end of your quote. like this:

```
blahblah
```

Can even tell it what type of code like:

```java
blablbalh
```
1 Like

thanks a lot sukasem, it works now, i really appreciate this