Link to home
Start Free TrialLog in
Avatar of jcpatterson

asked on

ColdFusion 8: Element PARENTID is undefined in URL

I have an CF8 action page to update a table and am getting the following error:

Element PARENTID is undefined in URL.  
The error occurred in C:\ColdFusion8\wwwroot\PET\Parent\inactParent.cfm: line 6
4 : UPDATE ParentSchoolTbl
5 : SET ActiveYN = '#Trim(frmInact.ActiveYN)#'
6 : WHERE ParentID=#URL.ParentID# and Form.DistrictIDFK = #Session.DistrictIDFK#
7 : </CFQUERY>
8 :

When I use the WHERE ParentID=#URL.ParentID# in a CFINSERT statement it works.  I don't understand why it isn't working in this case.  I'm out of ideas.  I would appreciate some advice on what I am doing wrong.  I have attached the code snippet: Snippet ID=5898270

Thank you.

Form Page:

<input type="hidden" name="UserName" value="#Session.UserName#">
<input type="hidden" name="District" value="#Session.DistrictIDFK#">
<input type="hidden" name="School" value="#Session.SchoolIDFK#">

<CFSET ParentID="#GetParent.ParentID#">
<CFSET SchoolIDFK="#GetParent.ParentSchoolIDFK#">
<CFSET ActiveYN="#GetParent.ActiveYN#">

School List for #GetParent.ParentFirstN# #GetParent.ParentLastN#
<cfform name="frmInact" action="inactParent.cfm">
<cfinput type="hidden" name="ParentID" value="#URL.ParentID#">
<cfinput type="hidden" name="DistrictIDFK" value="#Session.DistrictIDFK#">

<tr><td><cfinput type="hidden" name="SchoolIDFK" value="#SchoolIDFK#"></td><td>#SchoolName#&nbsp;&nbsp;&nbsp;&nbsp;</td>

<CFIF ActiveYN IS "True">
	<CFINPUT TYPE="Checkbox" NAME="ActiveYN" checked>
	<INPUT TYPE="Checkbox" NAME="ActiveYN">
<INPUT TYPE="Submit" name="Submit" title="Submit Update">

Action Page:

<cfparam name="frmInact.ActiveYN" default="" >

UPDATE ParentSchoolTbl
SET ActiveYN = '#Trim(frmInact.ActiveYN)#'
WHERE ParentID=#URL.ParentID# and Form.DistrictIDFK = #Session.DistrictIDFK#

Open in new window

Avatar of Brijesh Chauhan
Brijesh Chauhan
Flag of India image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
In CFINSERT you pass the FORMFIELDS, so it identifies PARENTID, but the is not the case with CFQUERY
    dataSource = "data source name"
    tableName = "table name"
    formFields = "formfield1, formfield2, ..."
Avatar of jcpatterson


Hey B,

Thanks for the info.  I modified it and now I don't get the error.  When the ActiveYN value is initially True, unchecking the checkbox does change it to false in the table.  However, when I check the ActiveYN checkbox, it doesn't change back to true.  Do I need to pose this as a different question?


Yes, Please pose a different question, also just for debugging purpose, just on your action page have <cfdump var ="#form#" />, this would give you a better idea of WHAT form values are passed and how they look, FORM would be a struct.
Also, you can modify the above checking code to

<CFINPUT TYPE="Checkbox" NAME="ActiveYN" <cfif ActiveYN IS "True"> checked="yes" </cfif> >
Check on what does FORM variable for ActiveYN pass to you when checked, intially you are setting it to
<CFSET ActiveYN="#GetParent.ActiveYN#">
but when the form is submitted it becaomes form checkbox variable. If you dump the #form# on you action page, you can see it. You would have to change <cfif ActiveYN IS "True">  condition.