Using IsDefined()

I have a web app that deals with both authenticated users (who log in via a central login) and unauthenticated ones.
For the authenticated ones, I call a web service that returns an XML file.  I'm using this code:
<cfif IsDefined("session.loginauth")>
    <cfset session.logincreds = XMLParse(session.loginauth)>
        <cfset session.userid = session.logincreds.user.row[1].user_id.XmlText>
        <cfset session.rights = session.logincreds.user.row[1].user_type.XmlText>
        <cfset session.usernm =  session.logincreds.user.row[1].name_first.XmlText & " " & session.logincreds.user.row[1].name_last.XmlText>
</cfif>
It works fine for authenticated users, but fails for unauthenticated ones.  The error is on the line with the XMLParse().  It's like the IsDefined isn't working and the code within the cfif is firing no matter what.
I've tried cfparam'ing that session variable like this:
<cfparam name="session.loginauth" default="">
Then:
<cfif session.loginauth neq "">
But that's no better.
Why on earth is that cfif always executing?  If I dump session.loginauth when a user's not logged in, I get nothing.

BreakawayPaul wrote:
Well here's the thing.  When a user logs in, I get an XML string from the authentication server, which I assign to session.loginauth.  I do this using a cfinvoke tag that calls a web service.
When a user arrives without logging in, session.loginauth is null.
That is what I mean by the blessing in disguise. The code is telling you otherwise: session.loginauth exists. Perhaps initialized in onSessionStart?
What I want to do is only run the XML parse when session.loginauth contains the XML data from the authentication server, but it seems to run no matter what.
My understanding is that if I cfparam something (even to "") it''s then defined, so isDefined won't work.  So I can either cfparam it to "" and test against "", or leave it alone and use IsDefined.  Right now neither seem to work.
The code snippet I gave is a good workaround.
The odd thing is, this code has been working for over 2 months and just started to fail yesterday morning.
Right now my workaround is to wrap the cfinvoke and entire cfif block from my original post in a try/catch block, with the catch being empty.  This seems to avoid the error message for non logged in users.  But I still can't figure out why <cfif IsDefined("foo") runs when foo isn't defined.  Or at least I don't see how or where it's defined.
Then it means that, yesterday morning, something happened to the code to make session.loginauth exist for unauthenticated users. As Sherlock Holmes said, "When you have eliminated the impossible, whatever remains, however improbable, must be the truth".
I used to use StructKeyExists() all the time, but for some reason a bunch of the apps I used it on started throwing errors. Having all these dissimilar systems having to talk to each other is a real challenge.  A few years ago I had standalone systems using cflogin and had zero problems, but now I have to use these web services, and it's introduced elements that I can't control as well.
Perservere. Software integration is always a challenge. On the plus side, it makes your system infinitely more scalable than cflogin would.

Similar Messages

  • Using isDefined within a cfloop

    I am trying to check a number of submitted form fields. The
    forms fields are numbered Q11, Q12, Q13, Q14, etc. Rather than do a
    set of steps for each form field, I'm trying to do it with cfloop.
    I have it set up as:
    <cfloop index="i" from="1" to="20">
    <cfif isDefined('form.Q1i')>
    Do this stuff
    </cfif>
    </cfloop>
    I don't get any errors, but it also is not processing the 'Do
    this stuff'. I've tried changing the format; ('form.Q1' & #i#,
    and 'form.Q1' & i, and others. Then I get error messages.
    Any clues to the problem?

    >> This code Does Not [work]
    That is because when using isDefined() the values *must*
    reside within quotes inside the function. So,
    isDefined("form.Q12#i#") is valid where isDefined('form.Q12' &
    i) is not (the string "& i" is outside the required quotes).
    Also, your reference to the unknown variable name is
    incorrect. Since *i* is a dynamic variable that you are saving to
    the name of another variable you'd need to reference it as
    something like "form.Q12#i#" where *FORM.Q12" is the string and *i*
    is the dynamic value.
    So, using your code as a base to work from, try this:
    <cfloop index="i" from="1" to="20">
    <cfif isDefined("form.Q12#i#")><cfset Q12Temp =
    Q12Temp & ", " & "form.Q12#i#" /></cfif>
    </cfloop>
    Or to be a little cleaner, try this:
    <cfloop index="i" from="1" to="20">
    <cfif structKeyExists(form, "Q12#i#")><cfset Q12Temp
    = listAppend(Q12Temp, "form.Q12#i#") /></cfif>
    </cfloop>

  • Using isDefined for a dynamic struct?

    I know how you can check for a defined variable or object using isDefined("myVar"), but I have a struct that can have varying properties. While I can explicitly write out the "myStruct.myProperty" checks in quotes for this method, I'd like to put these into a function where a variable is passed into it.
    Is this possible? Basically, I'm populating form fields and some fields may not be defined yet. Thoughts? Thanks.
    Ryan

    Thanks for the help BTW. I'm still new to CF, I'm more of a .net guy.
    Basically, I have this. It's a form that edits and adds bios for members:
    objStatement = objConnection.PrepareStatement("select bio_first_name, bio_last_name from cpppeBios where bio_id = ?");
    objStatement.setInt(1, Int(FORM.edit_bio_id));
    objResults = CreateObject("java", "coldfusion.sql.QueryTable").Init(objStatement.ExecuteQuery());
    EditBio = structNew();
    EditBio = objResults;
    ....and, I have input fields down below...
    <input type='text' value='' />
    I use the same form for adding and editing bios. What is the best approach for handling populating of these fields when the EditBio object can be null or contain data. I would access the data using EditBio.bio_first_name, etc.
    Thanks again.

  • Isdefined issue

    Hello,
    I just upgraded from cf5 to cf8. I have some code that was
    working but now isn't. Specifically I have a cfoutput
    query="xxxxxxx" and within that tag I have some IFs that use
    isdefined().
    Example:
    #isdefined("form.unitprice_"&trim(getprods.id))#
    This used to evaluate to true but now evaluates to false. If
    I put the evaluated value above the cfoutput it does evaluate to
    true.
    Further I even tried putting the evaluated value inside the
    cfoutput but it still does not work.
    Example:
    #isdefined("form.unitprice_1026")#
    With debugging set to on I can see the different form fields
    that are returned on the page and they are there. Furthermore If I
    dump form.fieldnames I get the list that includes the ones in
    question.
    I also noticed that I can reference the form fields without
    the "form." but only within the cfoutput.
    Very weird. Any help would be greatly appreciated.
    Thank you.

    Ok, very weird. I stripped the code down to the basics to see
    if I can reproduce the problem. If I do a simple query against the
    original table I can reproduce the problem. If I change the name of
    the table to another table, it does work. The code is below. The
    database is SQL server. Obviously the issue seems to be something
    in the database. However:
    1. The code worked fine in CF5
    2. In the code below I am not referencing any fields in the
    table
    3. Both tables are rturning one record as per the MAXROWS
    setting
    The table that doesn't work is named offerings2
    The table that does work is named units
    I've uploded to very simple pages with the code below and
    referencing both tables:
    http://darkeffigy.com/test_offerings2.cfm
    http://darkeffigy.com/test_units.cfm
    --------BEGIN CODE--------
    <CFQUERY NAME="getdata"
    DATASOURCE="#trim(user_datasource)#" USERNAME="#trim(dsn_uname)#"
    PASSWORD="#trim(dsn_pword)#" MAXROWS="1">
    select * from offerings2
    </CFQUERY>
    <CFIF #isdefined("form.the_form_field")#>
    <HR>ISDEFINED OUTSIDE THE CFOUTPUT<HR>
    </CFIF>
    <CFOUTPUT QUERY="getdata">
    <HR>REGULAR ROW OF OUTPUT<HR>
    <CFIF #isdefined("form.the_form_field")#>
    <HR>ISDEFINED INSIDE THE CFOUTPUT<HR>
    </CFIF>
    </CFOUTPUT>
    <FORM ACTION="test_offerings2.cfm" NAME="foreform"
    METHOD="POST" ENCTYPE="multipart/form-data">
    <INPUT TYPE="text" NAME="the_form_field"
    VALUE="ABCDEFG">
    <INPUT TYPE="submit">
    </FORM>
    --------END CODE--------
    Thank you

  • Is my cfif IsDefined being ignored?

    I have a form that allows a user to upload up to 3 images.
    They don't need to upload all three. For example, I get an error if
    I don't upload all three images.
    Despite having a <cfif> that uploads only if an image
    if the field name is defined, I still get a "The form field Image2
    did not contain a file" error. It seems my <cfif> is being
    ignored and trys to upload a field that is not defined? Any ideas?
    Thanks Rick
    FORM PAGE
    form action="act_uploadimage.cfm" method="post"
    enctype="multipart/form-data">
    <input type="file" name="Image1" >
    <input type="file" name="Image2" >
    <input type="file" name="Image3" >
    <input type="submit" name="Submit" value="Upload">
    ACTION PAGE
    <cftransaction>
    <cfquery name="Product" datasource="wioDB">
    SET NOCOUNT ON;
    INSERT INTO Products (CatID, USerID, Designer, Model, Color,
    DressSize, Price, Material, Description)
    VALUES ('#Trim(FORM.CatID)#',
    '#Trim(SESSION.Auth.UserID)#',
    '#Trim(FORM.Designer)#',
    '#Trim(FORM.Model)#',
    '#Trim(FORM.Color)#',
    '#Trim(FORM.DressSize)#',
    '#Trim(FORM.Price)#',
    '#Trim(FORM.Material)#',
    '#Trim(FORM.Description)#');
    SELECT @@identity AS ProdID FROM Products;
    </cfquery>
    <cfif isdefined("form.Image1")>
    <cffile action="upload" filefield="Image1"
    destination="D:\inetpub\woreitonce\users\uploads\"
    nameconflict="makeunique" accept="image/*" >
    <cfquery datasource="wioDB">
    INSERT INTO Images (ProdID, Image, IsPrimary)
    VALUES (#Product.ProdID#,'#file.ServerFile#',
    '#FORM.IsPrimary#')
    </cfquery>
    </cfif>
    <cfif isdefined("form.Image2")>
    <cffile action="upload" filefield="Image2"
    destination="D:\inetpub\woreitonce\users\uploads\"
    nameconflict="makeunique" accept="image/*" >
    <cfquery datasource="wioDB">
    INSERT INTO Images (ProdID, Image, IsPrimary)
    VALUES (#Product.ProdID#,'#file.ServerFile#',
    '#FORM.IsPrimary2#')
    </cfquery>
    </cfif>
    <cfif isdefined("form.Image3")>
    <cffile action="upload" filefield="Image3"
    destination="D:\inetpub\woreitonce\users\uploads\"
    nameconflict="makeunique" accept="image/*" >
    <cfquery datasource="wioDB">
    INSERT INTO Images (ProdID, Image, IsPrimary)
    VALUES (#Product.ProdID#,'#file.ServerFile#',
    '#FORM.IsPrimary3#')
    </cfquery>
    </cfif>
    </cftransaction>

    I have almost the same situation and when I changed my cfif
    to check for blank, it worked.
    So my question now is when are you suposed to use isDefined
    and when are you suppose to check for blank ?
    If a field in a form is left blank, does that mean that it
    does not exists, therefore using isDefined, or does that mean that
    it exists but contains a blank value ?
    I have the following code below. The first one works and the
    second one does not, but I changed it to check for blank and now it
    works, so I am a little confused now. What does isDefine do and
    when should it be used ?
    <cfif isDefined("form.output_type")>
    <cfset session.output_type = "#form.output_type#">
    <cfelse>
    <cfset session.output_type = "screen">
    </cfif>
    <cfif form.email_address is not "">
    <cfset session.email_address = "#form.email_address#">
    <cfelse>
    <cfset session.email_address =
    "[email protected]">
    </cfif>
    Thanks

  • Cfif vs isDefined vs cfparam

    I am a little confused as to when I should use these tags. I
    use isDefined to check for the existece of radio buttons and
    checkboxes on forms, and I use cfif to check for values. But when
    do I use cfparam ?
    Can someone give me an example on when to use each ?
    Thanks

    Essentially, if you want to ensure that a variable is defined
    or that a variable has a default value...you use cfparam. Lets say
    that you have a variable that defines the content of your page. By
    default, you want your site to load up body.cfm. You could set in
    your index page, <cfparam name="bodypage"
    default="body.cfm">.
    Now, if you just want to check and see if a varaible is
    present, you would use isdefined(). This coulkd be used for a wide
    range of uses. I generally use it a lot in instances where there is
    a varaible that may not exist (a prime exampole is varibles that
    may come in via a form, or a url)...
    <cfif isdefined("form.name")>
    <cfset varaibles.name="#form.name#">
    <cfelseif isdefined("ur.name")>
    <cfset variables.name="#url.name#">
    <cfelse>
    <cfset variables.name="">
    </cfif>
    Now the above examples can make use of both...
    <cfparam name="variables.name" default="">
    <cfif isdefined("form.name")>
    <cfset varaibles.name="#form.name#">
    <cfelseif isdefined("ur.name")>
    <cfset variables.name="#url.name#">
    </cfif>
    In the above, variables.name was already defaulted to "" so
    there was no need to put the default if statement in (no real
    benefit to doing it this way...just an example). I also use this a
    lot when I have a page that has content that changes based on group
    id or user id. I like to put isdefined in the logic to make sure
    that the variable has defined already for exception handling
    purposes. <cfif isdefined("variables.group_id") and
    variables.group_id eq 5>...then I use a default cfelse to cover
    the event that group_id has not been defined...
    They both have very differnt uses that can even compliment
    each other. The java code thqat is going on behind the scenes
    checks to see if the variable has already been defined for cfparam.
    That is the beauty of CF...thee is a lot that you don;t have to
    program into your pages because theat functionality has already
    been defined by CF,

  • Referencing field in a query struct

    About 5% of the time I get an error 'Element COMPANYSTATUS is
    undefined in Q.' from the code in SNIPPET 1. Can anyone tell me why
    I would ever get this error? If the query returns 0 results (which
    it may if the user is not logged in and SESSION.User.GetCompanyID()
    return 0) it should return false since q.RecordCount is 0. The
    problem is I know users in at least some cases are logged in and
    the query is returning at least one row. The IF statement should
    short circuit on the record count if its 0. If it doesn't then the
    comparison for q.CompanyStatus should always be valid. Does any
    know why CF flakes out occasionally when referencing
    q.CompanyStatus? I see this in other areas as well such as in
    SNIPPET 2. The method is called from another CFC where I can
    guarantee the passed argument '_company_id' is valid integer and
    the SQL should always return 1 result. Why then do I get the error
    'Element STATE is undefined in Q.' Is it bad practice referencing
    query fields this way?
    Thanks In Advance

    No. The cftry/cfcatch was for catching database errors.
    However, you may wish to let those bubble up.
    Since the component exists in a shared scope, using
    IsDefined() is potentially dangerous IMO. If you do not include a
    scope, CF automatically searches multiple scopes for the given
    variable name. So I would use structKeyExists instead.
    (Coincidentally a similar topic came up on HOF today)
    I would do something like this
    <cfset var Local = structNew()>
    <cfquery name="Local._SqlQuery"
    datasource="#APPLICATION.config.DSN#">
    #preserveSingleQuotes(ARGUMENTS._sql)#
    </cfquery>
    <cfif structKeyExists(Local, "_SqlQuery")>
    <cfreturn Local._SqlQuery>
    <cfelse>
    <cfreturn false>
    </cfif>
    ....

  • Reloading the same page

    I know this is surely a very retarded question, but I am
    tired of looking about and trying to get the proper answer on my
    own; I have a form that enters information into a database. what I
    want is to have it reset and reloaded each time submit is pressed
    instead of getting the blank page. Thanks In advance!.

    When I do forms with db actions, I always make the form
    action #cgi.script_name# and just do the action on the form page,
    using isdefined() to check for the existence of the form
    submission.
    If you're pre-populating the form with info from the DB, put
    the query to get those details *after* you do your insert, outside
    the cfif isdefined(), but before the form. That way, regardless of
    whether or not the page is being view before or after the form
    submission, you're still getting it pre-populated.

  • Fk error display on Action page

    I have a page that displays the content of a table. If you select one of the items and hit submit, it will navigate to another page that will allow you delete this item. Once the user hits delete the user is directed back to the page that displays the content of the table. If there is a fk error that needs to be displayed, is there a way to show this error on the page that displays the content of the table and not the page that has the delete button after the user hits the delete button?
    Thanks,
    Tim

    First, I would not be using ParameterExists as this function
    has been deprecated since CF 6 I believe and might not work in
    later releases, use IsDefined("Add") instead.
    Now on to your question, you cannot insert any values into
    fields such as autonumber or "auto identity" fields, the database
    inserts these values themselves when a new record is created.
    For this purpose I would not use <cfinsert, instead use
    <cfquery to insert into your database.
    <cflock timeout="30" throwontimeout="yes"
    name="InsertIntoConf2007Registration" type="EXCLUSIVE">
    <cftransaction>
    <cfquery name="Insert" datasource="DSSurvey">
    INSERT INTO Conf2007Registration (Name, Email, County, Title,
    Phone, Address1, Address2, PO, CityStateZip, Guests, Golfyes,
    Company, Allergies, Vegie2, Social, Comments)
    VALUES ('#form.Name#', '#form.Email#', '#form.County#',
    '#form.Title#', '#form.Phone#', '#form.Address1#',
    '#form.Address2#', '#form.PO#', '#form.CityStateZip#',
    '#form.Guests#', '#form.Golfyes#', '#form.Company#',
    '#form.Allergies#', '#form.Vegie2#', '#form.Social#',
    '#form.Comments#')
    </cfquery>
    <!--- @@identity is a built-in variable that holds only
    the most recent autonumber or auto identity value from a table, for
    this reason we wrap the entire section in a cflock so that we do
    not run into "race conditions" where 2 users could get the same
    value or swap values. Once an insert starts everyone else has to
    wait until the lock is finished so you guarantee that the newly
    inserted autonumber is actually correct for that insert --->
    <cfquery name="GetNewID" datasource="DSSurvey">
    SELECT @@identity AS TheNewlyInsertedID
    FROM Conf2007Registration
    </cfquery>
    <cfoutput>
    Your registration number is #GetNewID.TheNewlyInsertedID#
    </cfoutput>
    </cftransaction>
    </cflock>

  • Cfselect and cfloop help

    I am working on an event calender application. What I am
    trying to achieve is to have 2 drop down lists with the months of
    the year in them. I want the selection from the first list field to
    define the starting point for the second list field. For example.
    The first choice from the 12 months is March. So I want the second
    box, located on the same page, to have from March to December as
    options. Then there is a submit button.
    Then, below, on the same page, I would like to have a dynamic
    calender generated for the events between the months selected from
    the form. I have the calender section completed using a db query to
    populate the table with the events.
    I can get this to mostly work by having the form on one page
    submit to the calender on another page though I cannot get the
    second list field to update based on the value passed from the
    first list field, I would really like this to work on a single page
    so that the user can resubmit different date combinatons on the
    fly.
    Any help anyone can provide me with would be greatly
    appreciated. Thanks in advance.

    Ok..i have the page working almost completely right now.
    I used IsDefined("Form.Submit"> in a <CFIF>
    <CFELSE> statement to get the form to submit the results to
    the same page, then i added a second copy of the form to the top of
    the reselts section of the calender so that the form is always
    present for use on the page.
    The only thing I need help with now is making the second list
    box update it's choices from the selection of the first list box in
    the same form. Any ideas?
    I can post code iff it will help any, but it is getting
    rather lengthy.

  • Dynamic query, where clause help

    Hi Folks,
    Using my code below to generate a query.
    When using more than one condition, I'm not sure how to work out where the AND goes.
    Can anyone please help?
    Thankyou
    WHERE
    <cfif stafffilter neq "">
    deviceofficer = #stafffilter#
    </cfif>
    <cfif assetid neq "">
    AND deviceasset = '#assetid#'
    </cfif>
    <cfif isdefined("noasset")>
    AND deviceasset = ''
    </cfif>
      <cfif  isdefined("noserial")>
    AND deviceserial = ''
    </cfif>
    <cfif serial neq "">
    AND deviceserial = '#serial#'
    </cfif>
    <cfif servicearea neq "">
    AND deviceservice = #servicearea#
    </cfif>
    ORDER by locationname

    I do this sort of thing:
    <cfset sWhereAnd = "WHERE">
    <cfif isdefined("colFilter")>
         #sWhereAnd# col = #colFilter#
        <cfset sWhereAnd = "AND">
    </cfif>
    <cfif isdefined("someOtherColFilter")>
         #sWhereAnd# someOtherCol = #someOtherColFilter#
        <cfset sWhereAnd = "AND">
    </cfif>
    [etc]
    (that's pseudocode... I'd never use isDefined() or not use a <cfqueryparam> tag for my parameter values).
    I don't like doing the somewhat popular WHERE 1=1 approach as it can force a full table scan (all rows in the table will match that, and each WHERE filter expression is applied to every row of the table being filtered), unless the DB optimises it out as noise (which is what it is).  To me it's using bad SQL to cut corners.
    To be honest though, I shy away from these generic sort of queries these days.  Most of the genericism never gets used, and more specific requirements are better implemented to meet the precise need.
    Adam

  • Help Inserting a record

    I have a access db and need to insert a record from a formmy
    query isn't working, Can some one help?
    Here is my query;
    <form method=Post Action=doform.cfm>
    <table border=0 cellspacing=5>
    <tr>
    <td valign="top"><span
    class="t15">Issue:</span></td>
    <td><textarea name="Issue" cols="60"
    rows="5"></textarea></td>
    </tr>
    </table>
    </form>
    <CFQUERY NAME="InsertRecord"
    DATASOURCE="AdminServerIssues">
    Insert Into Issue (Issue)
    Values ('#form.Issue#')
    </CFQUERY>

    tracjerian,
    1. Add a "submit" button to the form
    2. If you're using a self-posting form (ie the code is all in
    one page named "doform.cfm"), the FORM.Issue variable only exists
    after the form is submitted. Use IsDefined() to detect if
    the form field exists and if it does, run the insert query.

  • Date field (not required) causing an error...Please assist!

    Hello, I am a beginner when it comes to ColdFusion could someone please assist with this issue?
    I have a date field in my application that is not required, I want users to have the choice to leave this field blank.
    Below is a breakdown of what I have going on:
    On Add/Edit page:
    <cfinvoke component="test"
               method="get"
               ReferenceNumber="#URL.RefIDNum#"
               returnvariable="record">
    <cfset ThisIsTheDateField=DateFormat(record.ThisIsTheDateField, "MM/DD/YYYY")>
    <cfform action="process.cfm">
       <cfinput type="Text"
                name="ThisIsTheDateField"
                value="#ThisIsTheDateField#"
                message="ThisIsTheDateField must be a valid date"
                required="no"
                                            validate="date"
                validateAt="onSubmit"
                size="50"
                maxlength="10">
    On process.cfm:
    <cfinvokeargument name="ThisIsTheDateField"
                       value="#DateFormat(FORM.ThisIsTheDateField)#">
    On CFC Page:
    <!--- Method arguments --->
    <cfargument name="ThisIsTheDateField"
                  type="date"
                  required="no"
                  hint="ThisIsTheDateField field">
    Query Value for this field:
    #CreateODBCDate(ARGUMENTS.ThisIsTheDateField)#,
    The error I get is:
    Error Occurred While Processing Request
    The THISISTHEDATEFIELD argument passed to the add function is not of type date. 
    If the component name is specified as a type of this argument, it is possible that either a definition file for the component cannot be found or is not accessible. 
    The error occurred in E:/site/test.cfc: line 56
    54 :
    55 :  <!--- Add a record --->
    56 :  <cffunction name="add"
    57 :              returntype="boolean"
    58 :              hint="Add a record">
    I need a way to make this field accept blank entries... when I leave it blank I get the above error!
    Thank you!

    The cfif does not surround the cfargument.  Put your cfargument for ThisIsTheDateField the same way you have it for your First/Second/Other Thing cfargument.  Then, understand that even though you have a cfargument tag that is named "ThisIsTheDataField", that the variable "arguments.ThisIsTheDataField" doesn't necessarily exist (because you have defined the argument as optional).  If it doesn't, you can't use it, otherwise you will get
    Element THISISTHEDATEFIELD is undefined in ARGUMENTS.
    So for the parts of your function where you will want to do something specific if the ThisIsTheDataField was passed to your function, you have to check using IsDefined("argument.ThisIsTheDataField") to determine if that variable exists or not.  SO, to summarize using the example you supplied above:
    <cffunction name="add"
                 returntype="boolean"
                 hint="Add a record">
      <!--- Method arguments --->
      <cfargument name="FirstThing"
                  type="string"
                  required="no"
                  hint="First Thing">
      <cfargument name="SecondThing"
                  type="string"
                  required="no"
                  hint="Second Thing">
      <cfargument name="ThisIsTheDateField"
                  type="date"
                  required="no"
                  hint="ThisIsTheDateField field">
      <cfargument name="Fourth Thing"
                  type="string"
                  required="no"
                  hint="Fourth Thing">
    <cfif IsDefined("arguments.ThisIsTheDateField")>
       <!--- operations that happen if ThisIsTheDateField was passed to the function
    <cfelse>
        <!--- operations that happen if ThisIsTheDateField was not passed to the function --->
    </cfif>
    As an example, let us say that you want to have the date be a default value (say, today's date), if the date isn't passed to the function.  You could do:
    <cfif IsDefined("arguments.ThisIsTheDataField")>
        <cfset TheDateField = arguments.ThisIsTheDataField" />
    <cfelse>
        <cfset TheDateField = Now() />
    </cfif>
    At the end of this code, the variable "TheDateField" will be guaranteed to have a date, and the date will be the date passed to the function if one was passed, or otherwise today's date if not.
    I hope that clarifies everything!

  • Testing for abnormal disconnect

    I maintain a VPN between two sites using the VPN Client 5.0.07.0290.
    The clients are running on Windows server 2003.
    The connection is started with a script using the command line.
    I need to know when the connection goes down. Currently I use a timed script that attempts to reconnect the VPN and if the client returns a 200 I assume it remains connected otherwise the client reconnects, if possible, and the connection is maintained. I log the success or failure of the reconnection event.
    This is kind of a kluge. Polling with another process is not a reliable tool in my environment.
    Is there a better way I can monitor the connection?
    Will the client terminate in some manner I can test in a script or some othere more deterministic means to notify a process that the connection has failed?
    Thanks in advance.
    Mike

    my understanding is: if you param something you are actually
    setting a
    default value if no value exists........which in your case is
    "" or rather
    nothing........so if you param with a value of nothing
    .......... than go to
    check its value.......it will be exactly what you set in the
    param.........
    "Karen_Little" <[email protected]> wrote in message
    news:em53f6$507$[email protected]..
    >I need advice on testing for cookies.
    >
    > I want to test for the presence of a cookie. Rather than
    use
    > isdefined("cfcookie.mycookie"), I've been setting a
    <cfparam
    > name="cookie.mycookie" default="" .... for the cookie,
    then testing to see
    > if
    > anything is in it. Since doing that, I seem to whip out
    the real cookie.
    >
    > I just wouldn't think cfparam could do that (but if it
    does, it's the most
    > effective way to get rid of cookie information in the
    world).
    >
    > Anyway, I am now confused. I want to see if a cookie is
    set. Is
    > "isDefined"
    > the way to go?
    >
    >

  • Evaluating dynamically generatedform  field names

    On form submission I need to find out if check boxes exist
    and have values. The field names are generated dynamically &
    there could be many. Here's the code I've been messing with. I am
    able to find out it the field has a value if it exists, but I can't
    figure out how to combine this with isDefined("") to test for the
    field's existence and avoid the "field i not defined in form"
    errors.
    <cfloop index="a" from="1" to="#form.numRows#">
    <cfset thisname = "form." & #a# & "_Clear">
    <!--- how do I use isDefined("") at this point to avoid
    an error on the next line when the field does not exist? --->
    <cfset thisVal= Evaluate("form.#thisname#")>
    <cfoutput> #thisname# #thisVal# </cfoutput>
    </cfloop>
    Thanks in advance for any help!

    run a loop over your field names like: <cfloop index="x"
    list="#form.fieldnames#"> then you have all of your form field
    names that are defined.

Maybe you are looking for

  • Can a non-iPhone stream to Apple TV?

    Just as the headline states, wondering if a non-iPhone, such as the HTC One or Nexus 4 would be able to stream video content to Apple TV? Disappointed with iOS7 so I'm considering switching to HTC One or perhaps the upcoming Nexus 5, and want to see

  • No restore option in the summary page

    hi im trying to restore my ipod's factory setting's but it seem's to be frozon in the summary page .. i have downloaded itune's 7.2 but it can't read the content's of my ipod .. which has been wiped anyway .. any help would be greatly appreciated mac

  • Phone software update Windows 8.1 for lumia 625

    Know me when phone software be updated for nokia Lumia 625 to Windows. 8.1

  • Lost Mountain Lion download

    Hi, just downloaded mountain lion  - had the install page ready to go but restarted the MBP before the install and now it looks like I have to re-download the whole thing again.  Any way I can just carry on the install? Thanks in advance

  • Book dissappeared

    Bought a book through the iBooks app. Went to read it today and it disappeared. Now what?