Skip to main content
Participant
March 2, 2009
Answered

custom tags

  • March 2, 2009
  • 1 reply
  • 274 views
Hi

I am new to CF and I am creating a custom tag with two attributes. However when calling the custom tag with name as "datefrom" and date as 01/01/2008, the calling page came with this error: "Variable DATEFROM is undefined".

In my custom tag:
<cfparam name="Attributes.date">
<cfparam name="Attributes.name">

<cfset dateA = "#Attributes.date#">

<cfset dateB = "#mid(dateA,7,4)&'-'&mid(dateA,4,2)&'-'&mid(dateA,1,2)#">
<cfset #Attributes.name# = "#dateB#">


Calling page:
<cf_convertdatetoSQL date="url.fromdate" name="datefrom">
<cf_convertdatetoSQL date="url.todate" name="dateto">
<cfquery name="balancesheet" datasource=#url.code#>


SELECT AccountCategories.accountcategoryname, sum(Transactions.debit) AS Total,dbo.accountcategories.acctype
FROM dbo.AccountCategories, dbo.AccountNumbers, dbo.Transactions
WHERE dbo.AccountCategories.accountcategoryno = dbo.AccountNumbers.accountcategoryno
AND dbo.AccountNumbers.accountno = dbo.Transactions.accountno
AND dbo.Transactions.date BETWEEN '#datefrom#' AND '#dateto#'
GROUP BY dbo.accountcategories.accountcategoryname,dbo.accountcategories.acctype

ORDER BY CHARINDEX(dbo.accountcategories.acctype, 'Asset,Liability,Equity') ASC

</cfquery>
etc..

Can anyone please let me know what I am doing wrong?

Thanks
    This topic has been closed for replies.
    Correct answer Dan_Bracuk
    The most fundamental thing you are doing wrong is to re-arrange a string instead of creating a date object.

    Other things are:
    In your custom tag, your cfparam tags don't have default attributes.
    When you attempt to set the value of attributes.name, the octothorps around the variable names are messing you up.
    In custom tags, to send values back to the calling template, you use the caller scope.

    1 reply

    Dan_BracukCorrect answer
    Inspiring
    March 2, 2009
    The most fundamental thing you are doing wrong is to re-arrange a string instead of creating a date object.

    Other things are:
    In your custom tag, your cfparam tags don't have default attributes.
    When you attempt to set the value of attributes.name, the octothorps around the variable names are messing you up.
    In custom tags, to send values back to the calling template, you use the caller scope.