I am using a custom tag and am getting an Invalid CFML Construct error on the following:
Invalid CFML construct found on line 27 at column 10.
26 : <cfscript>
27 : cfparam( 'attributes.action', 'new' );
28 : cfparam( 'attributes.fieldList', '' );
29 : cfparam( 'attributes.return', 'variables' );
You are using incorrect syntax for param. I think you have got the cfparam mistaken for a simple ColdFusion function. For cfparam you need to specify the parameters with names like name, default when passing the data. Not as just the values for comma separated values like you can do for a normal function (like listfind(list, 'str')).
<cfscript>
cfparam(name="attributes.action", default='new');
param name="attributes.action" default='new';
</cfscript>
And the short hand syntax is param attributes.action ='new';
Related
I think my timestamp needs to be at the end of the string. But when I move it there - I get an odd output of the × turns into an x. Is there a fix for this? At the front it works fine.
<cfset usem = "timestamp=#unixdatetimeNow.getTime()#&symbol=#pair#&side=#side#&type=#type#&quantity=#size#">
Outputs :
timestamp=1645552579468&symbol=SHIBUSDT&side=sell&type=market&quantity=9005
<cfset usem = "symbol=#pair#&side=#side#&type=#type#&quantity=#size#×tamp=#unixdatetimeNow.getTime()#">
Outputs with the x :
symbol=SHIBUSDT&side=sell&type=market&quantity=9005×tamp=1645552579468
How do I fix this x replacement? Does it in both cfset and in script
Update: 2022-04-06
TLDR; Bottom line, nothing needs to be done. As mentioned in the comments, and your other thread ColdFusion : Binance API : Not all sent parameters were read, the parameter name is still ×tamp, it just appears to be xtamp when displayed on screen.
It's because the substring × is being treated as the html entity ×, which gets rendered as the symbol x.
Why is [timestamp] fine at the front but not back?
When timestamp is the first parameter in the query string, there's no & preceding "time". So it's not treated as an html entity.
Keep in mind this is just a presentation issue. The substring &time is only rendered as x when you output the variable. The actual contents of the variable don't change. So nothing happens its used in your cfhttp call:
// sends "×tamp" not "xstamp"
cfhttp(....) {
...
cfhttpparam(type="body", value="#yourString#");
}
Fixed with : & : <cfset usem = "...×tamp=#unixdatetimeNow.getTime()#">
That might display correctly on screen, but will break your cfhttp call because it sets the parameter name to the literal string ×tamp but the API is expecting a parameter named timestamp.
I'm trying to modify existing codes in my ColdFusion application left by previous programmer. I don't understand the meaning of this line of code (the one with question marks):
<cfset Application[#form.username#] = 0> ??????
<cfset Session.loggedin="Yes">
<cfset Session.username="#Trim(Form.username)#">
Maybe I haven't been working with CF long enough to see this syntax so I don't know what this mean.
When setting an application variable I usually use this syntax:
<cfset application.variableName = "some value">
Can someone explain to me what is this ?
Thank you
As well as explicitly stating variable names at "code time" with dot notation, CFML allows one to reference them dynamically at runtime via a string value.
This is done via associative array notation (using square brackets), eg:
myVariableName = "foo";
variables[myVariableName] = "moo"; // equivalent to variables.foo = "moo"
I have a silly question...
for some reason I just can't get it work...
I want to insert a row into an empty table using the today(function).
This is what I do:
insert into gal_risk_factor (RISK_FACTOR_ID, VALID_FROM_DTTM,
RISK_FACTOR_NM, EFFECTIVE_FROM_DTTM, EFFECTIVE_TO_DTTM)
values ("1",today(),
"GGG",
"01JAN1901:00:00:00"dt, "01JAN2999:00:00:00"dt
)
This is the error I get:
today(),
_____
22
202
ERROR 22-322: Syntax error, expecting one of the following: a quoted string, a numeric constant, a datetime constant,
a missing value, ), +, ',', -, MISSING, NULL, USER.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
What am I missing here...?
Thank you in advance,
Gal.
I guess the VALUES list cannot contain function, only constants.
Try creating a macro var and use it:
%let today=%sysfunc(today());
insert into gal_risk_factor (RISK_FACTOR_ID, VALID_FROM_DTTM,
RISK_FACTOR_NM, EFFECTIVE_FROM_DTTM, EFFECTIVE_TO_DTTM)
values ("1", &today,
"GGG",
"01JAN1901:00:00:00"dt, "01JAN2999:00:00:00"dt
)
Edit:
In case VALID_FROM_DTTM is meant to store datetime values use a constant like this:
%let today_dttm=%sysfunc(dhms(%sysfunc(today()), 0, 0, 0));
I'm a bit stumped on this one..
I currently have a string.
Please enter your variable.firstname here
What i would like to do is find the variable.firstname in the string and convert it to be used as #variable.firstname#
Im using CF8, and ive looked at using findNoCase() but the variable.firstname portion can appear anywhere. I am also trying to use this in a Coldfusion Custom Tag as its to simply display the firstname of the user that could be dynamically populated.
I cant use any other functionality to change it IE = variable['firstname] because the variable could be the result of a dynamic variable i pass in and the query for the content will reside within the custom tag.
<cfset yourNewString = replace(yourOldString,'variable.firstname',
'##variable.firstname##', 'all')>
Note the double pound signs.
I cant use any other functionality to change it IE =
variable['firstname] because the variable could be the result of a
dynamic variable i pass in and the query for the content will reside
within the custom tag.
I'm not sure I understand exactly what you're saying here but if you're saying that variables.firstname is coming from another variable and the .firstname is the dynamic part you could still use array notation.
<cfset myName = "Travis">
<cfset yourName = "user125264">
<cfset myCustomVariable = "myName">
<cfoutput>Hi, My name is #variables[myCustomVariable]#. </cfoutput>
<cfset myCustomVariable = "yourName">
<cfoutput>Your name is #variables[MyCustomVariable]#.</cfoutput>
Output: Hi, My name is Travis. Your name is user125264.
If that isn't what you meant, I apologize.
If you're trying to replace variable.firstname with #variables.firstname# and then also get the value of that variable, you'll need to do the replace <cfset yourNewString = replace(yourOldString,'variable.firstname',
'##variables.firstname##', 'all')> and then wrap the resulting string in an evaluate() function (and an inner de() to prevent CF from evaluating everything): <cfset evaluatedString = evaluate(de(yourNewstring))>.
If there are more variables besides variable.firstname that need this kind of translation, you'll need to get into regex with reReplace() to catch them all in one statement. My regex is rusty, so you'll need to Google that bit on your own. ;o)
I have a page called "shopping_cart_qry.cfm", that does a series of SELECT queries from various tables. It extracts data and populates a single structure called shopping. This structure contains around 50 parameters, like:
shopping.company_id
shopping.brand_id
shopping.cost_Price
shopping.expiry_dt
shopping.user_id
shopping.item_name
shopping.item_cost
...
I only need 15 out of the 50 parameters (shopping.item_name , shopping.item_cost, etc) for a different task. So I am calling "shopping_cart_qry.cfm" as <cfinclude> in a new file named "item_info.cfm".
In this file when I do an <cfdump> of the structure, I see all 50 parameters, including the 15 parameters I need. But when I try to assign new names to the 15 parameters I need like this:
<cfset itemName = "shopping.item_name">
<cfset itemCost = "shopping.item_Cost">
<cfset itemDt = "shopping.item_Dt">
And then use <cfdump> to see I was able to do successfully, I am seeing the variable names (itemName, itemCost, etc..) but no values.
<cfdump var="#shopping.item_name#">
<cfdump var="#shopping.item_Cost#">
<cfdump var="#shopping.item_Dt#">
Should I use <script>?
You should remove the quotation marks, ex:
<cfset itemName = shopping.item_name>
See Adobe docs on cfset.