Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

custom tags

New Here ,
Mar 02, 2009 Mar 02, 2009
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
245
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Mar 02, 2009 Mar 02, 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.
Translate
LEGEND ,
Mar 02, 2009 Mar 02, 2009
LATEST
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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources