displaying previously entered multiple fields

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    The partscount should be the full field name:
    Code:
    <cfparam name="form.partscount#machinecount#" default="">
    Originally posted by bonneylake
    Are you saying to match the serial number with the ticket number to delete? or are you saying that in the cfloop on my userformedit.cf m page that i need to add it somewhere there to delete?
    For the matching, I mean something like:
    Code:
    <cfset currSerialNo = 1>
    <cfloop ...>
    <cfif ... --match currSerialNo with the serial count value 
      <!--- then loop here till currSerialNo eq serial count --->
      <cfloop ..
        <!--- delete here --->
        <! --- increment currSerialNo --->
      </cfloop>
    </cfif>

    Comment

    • bonneylake
      Contributor
      • Aug 2008
      • 769

      Hey Acoder,

      Alright i tried the parts an well i ran into a problem. Its adding the part to the wrong serial. heres the example i tried

      this is what i resubmitted
      serial 1
      parts 1
      serial 2
      serial 3
      parts 1

      when went back to results it came back as

      serial 1
      parts 1
      serial 2
      parts 1
      serial 3.

      an then i tried the matching but i think i might of got a few things misplaced here is what i have

      Code:
      <CFIF REQUEST_METHOD EQ "POST">
      <!---<CFSET machineListLen = listLen(Form.serialcount)>--->
      <cfset currSerialNo = 1>
      <CFLOOP list="#form.serialcount#" index="machineCount">
      <cfif form.serialcount eq currSerialNo>
       <CFSET serialnum       = Form["serialnum_" & machineCount]>
       <CFSET modelno         = Form["modelno_" & machineCount]>
       <CFSET producttype     = Form["producttype_" & machineCount]>
       <CFSET softhardware    = Form["softhardware_" & machineCount]>
       <CFSET resolution      = Form["resolution_" & machineCount]>
       <CFSET resdate         = Form["resdate_" & machineCount]>
       <CFSET resvertified    = Form["resvertified_" & machineCount]>
       <CFSET vertifidate     = Form["vertifidate_" & machineCount]>
       <CFSET deptvendor      = Form["deptvendor_" & machinecount]>
       <CFSET hardwarefailure = Form["hardwarefailure_" & machineCount]>
      <CFSET thedescription  = Form["thedescription_" & machineCount]>
      
       
      <!--- inserts information into the serial table--->
      <cfquery name="serialinsertupdate" datasource="CustomerSupport">
         exec usp_CS_Updateinsertserial 
           <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
           "#Form.pk_ticketID#",
           <cfqueryparam value="#modelno#" CFSQLType = "CF_SQL_VARCHAR">,
           <cfqueryparam value="#producttype#" CFSQLType = "CF_SQL_VARCHAR">,
           <cfqueryparam value="#softhardware#" CFSQLType = "CF_SQL_VARCHAR">,
           <cfqueryparam value="#resolution#" CFSQLType = "CF_SQL_VARCHAR">,
           <cfqueryparam value="#resdate#">,
           <cfqueryparam value="#resvertified#" CFSQLType = "CF_SQL_VARCHAR">,
           <cfqueryparam value="#vertifidate#">,
           <cfqueryparam value="#deptvendor#" CFSQLType = "CF_SQL_VARCHAR">,
           <cfqueryparam value="#hardwarefailure#" CFSQLType = "CF_SQL_VARCHAR">   
           </cfquery>
         
      <!---Inserts information into notes_descr table.--->
      <cfquery name="description" datasource="CustomerSupport">
          exec usp_CS_Insertdescription
         <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
         '#Form.pk_ticketID#',
         <cfqueryparam value="#thedescription#" CFSQLType = "CF_SQL_VARCHAR">,
         '#Form.fk_addedBy#'
      </cfquery>
      
      <!---Inserts parts information into parts table.--->
      <!---because it is a bit we don't use 'ticks' around defective for parts table--->
      <cfparam name="form.partscount#machinecount#" default="">
      <cfloop list="#form['partscount' & machinecount]#" index="ps">
      <cfparam name="Form.defective_#ps#_#machinecount#" default="0">
      <cfparam name="Form.partsreturn_#ps#_#machinecount#" default="0">
      <CFSET hcpn            = Form["hcpn_" & "#ps#" & "_#machinecount#"]>
      <CFSET partsreturn     = Form["partsreturn_" & "#ps#" & "_#machinecount#"]>
      <CFSET defective       = Form["defective_" & "#ps#" & "_#machinecount#"]>
      <CFSET rma             = Form["rma_" & "#ps#" & "_#machineCount#"]>
      <cfquery name="parts" datasource="CustomerSupport">
          exec usp_CS_Updateinsertparts 
          <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
          '#Form.pk_ticketID#',
          <cfqueryparam value="#hcpn#" CFSQLType = "CF_SQL_VARCHAR">,
          <cfqueryparam value="#partsreturn#" CFSQLType = "CF_SQL_VARCHAR">,
           <cfqueryparam value="#rma#" CFSQLType = "CF_SQL_VARCHAR">,
          <cfqueryparam value="#defective#" CFSQLType = "CF_SQL_BIT">
         
      </cfquery>
      </cfloop>
      </CFLOOP>
      <cfloop>
      <cfquery name="deleteserialparts" datasource="CustomerSupport">
      exec usp_CS_Deleteserialparts '#Form.pk_ticketID#'
      </cfquery>
      </cfif>
      </CFIF>
      Thank you,
      Rach

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        Why have you got an opening cfloop and a delete query at the bottom (lines 66-69)?

        For the parts, check the partscount values for partscount1, partscount2, partscount3. They should be "1", "" and "1" respectively for that example.

        The matching is incorrect, It should be against machinecount, and it's not complete. See the general idea in my previous post.

        Comment

        • bonneylake
          Contributor
          • Aug 2008
          • 769

          Hey Acoder,

          are you meaning something like this

          Code:
          <CFIF REQUEST_METHOD EQ "POST">
           <!---<CFSET machineListLen = listLen(Form.serialcount)>--->
           <cfset currSerialNo = 1>
           <CFLOOP list="#form.serialcount#" index="machineCount">
          <cfif machineCount eq currSerialNo>
           <CFSET serialnum       = Form["serialnum_" & machineCount]>
            <CFSET modelno         = Form["modelno_" & machineCount]>
            <CFSET producttype     = Form["producttype_" & machineCount]>
           <CFSET softhardware    = Form["softhardware_" & machineCount]>
            <CFSET resolution      = Form["resolution_" & machineCount]>
            <CFSET resdate         = Form["resdate_" & machineCount]>
            <CFSET resvertified    = Form["resvertified_" & machineCount]>
          <CFSET vertifidate     = Form["vertifidate_" & machineCount]>
          <CFSET deptvendor      = Form["deptvendor_" & machinecount]>
           <CFSET hardwarefailure = Form["hardwarefailure_" & machineCount]>
           <CFSET thedescription  = Form["thedescription_" & machineCount]>
           
          
           <!--- inserts information into the serial table--->
           <cfquery name="serialinsertupdate" datasource="CustomerSupport">
              exec usp_CS_Updateinsertserial 
               <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
               "#Form.pk_ticketID#",
               <cfqueryparam value="#modelno#" CFSQLType = "CF_SQL_VARCHAR">,
                <cfqueryparam value="#producttype#" CFSQLType = "CF_SQL_VARCHAR">,
               <cfqueryparam value="#softhardware#" CFSQLType = "CF_SQL_VARCHAR">,
               <cfqueryparam value="#resolution#" CFSQLType = "CF_SQL_VARCHAR">,
               <cfqueryparam value="#resdate#">,
               <cfqueryparam value="#resvertified#" CFSQLType = "CF_SQL_VARCHAR">,
               <cfqueryparam value="#vertifidate#">,
              <cfqueryparam value="#deptvendor#" CFSQLType = "CF_SQL_VARCHAR">,
               <cfqueryparam value="#hardwarefailure#" CFSQLType = "CF_SQL_VARCHAR">   
               </cfquery>
          
           <!---Inserts information into notes_descr table.--->
           <cfquery name="description" datasource="CustomerSupport">
              exec usp_CS_Insertdescription
             <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
             '#Form.pk_ticketID#',
              <cfqueryparam value="#thedescription#" CFSQLType = "CF_SQL_VARCHAR">,
             '#Form.fk_addedBy#'
           </cfquery>
            
            <!---Inserts parts information into parts table.--->
            <!---because it is a bit we don't use 'ticks' around defective for parts table--->
           <cfparam name="form.partscount#machinecount#" default="">
           <cfloop list="#form['partscount' & machinecount]#" index="ps">
          <cfparam name="Form.defective_#ps#_#machinecount#" default="0">
            <cfparam name="Form.partsreturn_#ps#_#machinecount#" default="0">
           <CFSET hcpn            = Form["hcpn_" & "#ps#" & "_#machinecount#"]>
           <CFSET partsreturn     = Form["partsreturn_" & "#ps#" & "_#machinecount#"]>
           <CFSET defective       = Form["defective_" & "#ps#" & "_#machinecount#"]>
           <CFSET rma             = Form["rma_" & "#ps#" & "_#machineCount#"]>
          <cfquery name="parts" datasource="CustomerSupport">
             exec usp_CS_Updateinsertparts 
            <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
             '#Form.pk_ticketID#',
              <cfqueryparam value="#hcpn#" CFSQLType = "CF_SQL_VARCHAR">,
              <cfqueryparam value="#partsreturn#" CFSQLType = "CF_SQL_VARCHAR">,
              <cfqueryparam value="#rma#" CFSQLType = "CF_SQL_VARCHAR">,
             <cfqueryparam value="#defective#" CFSQLType = "CF_SQL_BIT">
          
           </cfquery> 
           <cfquery name="deleteserialparts" datasource="CustomerSupport">
           exec usp_CS_Deleteserialparts '#Form.pk_ticketID#'
           </cfquery>
           <cfset currSerialNo = currSerialNo + 1>
          </cfloop>
          </cfif>
          </CFLOOP>
           </CFIF>
          an then with the parts part i am completely confused on what you mean to do.

          i went an redid the examples this is what i have before i submit. for some reason i have no partscount for dynamic2input

          Code:
          for dynamic1input
          <input id="partcounter1" type="hidden" value="1" name="partcounter1"/>
          <input id="partscount1" type="hidden" value="1" name="partscount1"/>
          
          for dynamic2input
          <input id="partcounter2" type="hidden" value="0" name="partcounter2"/>
          
          for dynamic3input
          <input id="partcounter3" type="hidden" value="1" name="partcounter3"/>
          <input type="hidden" value="1" name="partscount3"/>
          Thank you,
          Rach

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            You're missing out the extra loop that you need to add:
            Code:
            <cfloop <!--- loop until currSerialNo eq machinecount --->
                 <!--- delete here by calling stored procedure --->
                 <! --- increment currSerialNo --->
               </cfloop>
            Of course, you need to replace the comments with actual code.

            The second dynamic2input having no partscount is correct because there are no parts.

            Comment

            • bonneylake
              Contributor
              • Aug 2008
              • 769

              Hey Acoder,

              would the cfloop i used below work, and is it in the correct place?

              Code:
              <CFIF REQUEST_METHOD EQ "POST">
               <!---<CFSET machineListLen = listLen(Form.serialcount)>--->
               <cfset currSerialNo = 1>
               <CFLOOP list="#form.serialcount#" index="machineCount">
              <cfif machineCount eq currSerialNo>
               <CFSET serialnum       = Form["serialnum_" & machineCount]>
                <CFSET modelno         = Form["modelno_" & machineCount]>
                <CFSET producttype     = Form["producttype_" & machineCount]>
               <CFSET softhardware    = Form["softhardware_" & machineCount]>
                <CFSET resolution      = Form["resolution_" & machineCount]>
                <CFSET resdate         = Form["resdate_" & machineCount]>
                <CFSET resvertified    = Form["resvertified_" & machineCount]>
              <CFSET vertifidate     = Form["vertifidate_" & machineCount]>
              <CFSET deptvendor      = Form["deptvendor_" & machinecount]>
               <CFSET hardwarefailure = Form["hardwarefailure_" & machineCount]>
               <CFSET thedescription  = Form["thedescription_" & machineCount]>
               
              
               <!--- inserts information into the serial table--->
               <cfquery name="serialinsertupdate" datasource="CustomerSupport">
                  exec usp_CS_Updateinsertserial 
                   <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
                   "#Form.pk_ticketID#",
                   <cfqueryparam value="#modelno#" CFSQLType = "CF_SQL_VARCHAR">,
                    <cfqueryparam value="#producttype#" CFSQLType = "CF_SQL_VARCHAR">,
                   <cfqueryparam value="#softhardware#" CFSQLType = "CF_SQL_VARCHAR">,
                   <cfqueryparam value="#resolution#" CFSQLType = "CF_SQL_VARCHAR">,
                   <cfqueryparam value="#resdate#">,
                   <cfqueryparam value="#resvertified#" CFSQLType = "CF_SQL_VARCHAR">,
                   <cfqueryparam value="#vertifidate#">,
                  <cfqueryparam value="#deptvendor#" CFSQLType = "CF_SQL_VARCHAR">,
                   <cfqueryparam value="#hardwarefailure#" CFSQLType = "CF_SQL_VARCHAR">   
                   </cfquery>
              
               <!---Inserts information into notes_descr table.--->
               <cfquery name="description" datasource="CustomerSupport">
                  exec usp_CS_Insertdescription
                 <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
                 '#Form.pk_ticketID#',
                  <cfqueryparam value="#thedescription#" CFSQLType = "CF_SQL_VARCHAR">,
                 '#Form.fk_addedBy#'
               </cfquery>
                
                <!---Inserts parts information into parts table.--->
                <!---because it is a bit we don't use 'ticks' around defective for parts table--->
               <cfparam name="form.partcounter#machinecount#" default="">
               <cfloop list="#form['partscount' & machinecount]#" index="ps">
              <cfparam name="Form.defective_#ps#_#machinecount#" default="0">
                <cfparam name="Form.partsreturn_#ps#_#machinecount#" default="0">
               <CFSET hcpn            = Form["hcpn_" & "#ps#" & "_#machinecount#"]>
               <CFSET partsreturn     = Form["partsreturn_" & "#ps#" & "_#machinecount#"]>
               <CFSET defective       = Form["defective_" & "#ps#" & "_#machinecount#"]>
               <CFSET rma             = Form["rma_" & "#ps#" & "_#machineCount#"]>
              <cfquery name="parts" datasource="CustomerSupport">
                 exec usp_CS_Updateinsertparts 
                <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
                 '#Form.pk_ticketID#',
                  <cfqueryparam value="#hcpn#" CFSQLType = "CF_SQL_VARCHAR">,
                  <cfqueryparam value="#partsreturn#" CFSQLType = "CF_SQL_VARCHAR">,
                  <cfqueryparam value="#rma#" CFSQLType = "CF_SQL_VARCHAR">,
                 <cfqueryparam value="#defective#" CFSQLType = "CF_SQL_BIT">
              
               </cfquery> 
               <cfloop condition="currSerialNo eq machinecount">
               <cfquery name="deleteserialparts" datasource="CustomerSupport">
               exec usp_CS_Deleteserialparts '#Form.pk_ticketID#'
               </cfquery>
               <cfset currSerialNo = currSerialNo + 1>
               </cfloop>
              </cfloop>
              </CFLOOP>
               </CFIF>
              an then if parts is working correctly then what do i need to do to it to make the part go with the correct serial? because right now if i submit it as so

              serial 1
              part 1 for serial 1
              serial 2
              serial 3
              part 1 for serial 3

              instead of the part 1 being with serial 3 it puts it with serial 2.

              Thank you,
              Rach

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                Trying to get two things working at once is always going to be difficult especially if one can affect the other.

                Try to get one thing working first. First, let's work on the deletion. Move the loop all the way up to the top of the serial loop. Also, the stored procedure called for deletion must only delete one serial at a time, not all serials for that ticket (so you may need to create a new stored procedure).

                Comment

                • bonneylake
                  Contributor
                  • Aug 2008
                  • 769

                  Originally posted by acoder
                  Trying to get two things working at once is always going to be difficult especially if one can affect the other.

                  Try to get one thing working first. First, let's work on the deletion. Move the loop all the way up to the top of the serial loop. Also, the stored procedure called for deletion must only delete one serial at a time, not all serials for that ticket (so you may need to create a new stored procedure).
                  Hey Acoder,

                  Here is what i have now
                  Code:
                  <CFIF REQUEST_METHOD EQ "POST">
                   <!---<CFSET machineListLen = listLen(Form.serialcount)>--->
                   <cfset currSerialNo = 1>
                    <cfloop condition="currSerialNo eq machinecount">
                   <cfquery name="deleteserialparts" datasource="CustomerSupport">
                   exec usp_CS_Deleteserialparts '#Form.pk_ticketID#'
                   </cfquery>
                   <cfset currSerialNo = currSerialNo + 1>
                   </cfloop>
                   <CFLOOP list="#form.serialcount#" index="machineCount">
                  <cfif machineCount eq currSerialNo>
                   <CFSET serialnum       = Form["serialnum_" & machineCount]>
                    <CFSET modelno         = Form["modelno_" & machineCount]>
                    <CFSET producttype     = Form["producttype_" & machineCount]>
                   <CFSET softhardware    = Form["softhardware_" & machineCount]>
                    <CFSET resolution      = Form["resolution_" & machineCount]>
                    <CFSET resdate         = Form["resdate_" & machineCount]>
                    <CFSET resvertified    = Form["resvertified_" & machineCount]>
                  <CFSET vertifidate     = Form["vertifidate_" & machineCount]>
                  <CFSET deptvendor      = Form["deptvendor_" & machinecount]>
                   <CFSET hardwarefailure = Form["hardwarefailure_" & machineCount]>
                   <CFSET thedescription  = Form["thedescription_" & machineCount]>
                   
                  
                   <!--- inserts information into the serial table--->
                   <cfquery name="serialinsertupdate" datasource="CustomerSupport">
                      exec usp_CS_Updateinsertserial 
                       <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
                       "#Form.pk_ticketID#",
                       <cfqueryparam value="#modelno#" CFSQLType = "CF_SQL_VARCHAR">,
                        <cfqueryparam value="#producttype#" CFSQLType = "CF_SQL_VARCHAR">,
                       <cfqueryparam value="#softhardware#" CFSQLType = "CF_SQL_VARCHAR">,
                       <cfqueryparam value="#resolution#" CFSQLType = "CF_SQL_VARCHAR">,
                       <cfqueryparam value="#resdate#">,
                       <cfqueryparam value="#resvertified#" CFSQLType = "CF_SQL_VARCHAR">,
                       <cfqueryparam value="#vertifidate#">,
                      <cfqueryparam value="#deptvendor#" CFSQLType = "CF_SQL_VARCHAR">,
                       <cfqueryparam value="#hardwarefailure#" CFSQLType = "CF_SQL_VARCHAR">   
                       </cfquery>
                  
                   <!---Inserts information into notes_descr table.--->
                   <cfquery name="description" datasource="CustomerSupport">
                      exec usp_CS_Insertdescription
                     <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
                     '#Form.pk_ticketID#',
                      <cfqueryparam value="#thedescription#" CFSQLType = "CF_SQL_VARCHAR">,
                     '#Form.fk_addedBy#'
                   </cfquery>
                    
                    <!---Inserts parts information into parts table.--->
                    <!---because it is a bit we don't use 'ticks' around defective for parts table--->
                   <cfparam name="form.partcounter#machinecount#" default="">
                   <cfloop list="#form['partscount' & machinecount]#" index="ps">
                  <cfparam name="Form.defective_#ps#_#machinecount#" default="0">
                    <cfparam name="Form.partsreturn_#ps#_#machinecount#" default="0">
                   <CFSET hcpn            = Form["hcpn_" & "#ps#" & "_#machinecount#"]>
                   <CFSET partsreturn     = Form["partsreturn_" & "#ps#" & "_#machinecount#"]>
                   <CFSET defective       = Form["defective_" & "#ps#" & "_#machinecount#"]>
                   <CFSET rma             = Form["rma_" & "#ps#" & "_#machineCount#"]>
                  <cfquery name="parts" datasource="CustomerSupport">
                     exec usp_CS_Updateinsertparts 
                    <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
                     '#Form.pk_ticketID#',
                      <cfqueryparam value="#hcpn#" CFSQLType = "CF_SQL_VARCHAR">,
                      <cfqueryparam value="#partsreturn#" CFSQLType = "CF_SQL_VARCHAR">,
                      <cfqueryparam value="#rma#" CFSQLType = "CF_SQL_VARCHAR">,
                     <cfqueryparam value="#defective#" CFSQLType = "CF_SQL_BIT">
                  
                   </cfquery> 
                  
                  </cfloop>
                  </CFLOOP>
                   </CFIF>
                  and with the stored procedure how would i make it delete based on one serial at a time?

                  Thank you,
                  Rach

                  Comment

                  • acoder
                    Recognized Expert MVP
                    • Nov 2006
                    • 16032

                    I meant the top of the loop, i.e. inside it not above it.

                    For the stored procedure, you'd need to pass the ticket id and serial no, then in the stored proc. delete from the serial table where the inputs match (probably similar to what you have now and I vaguely remember you having one that worked earlier). Note that you wouldn't need to do any of this if you just deleted everything at the top and then started afresh with the inserts, but you wanted to avoid that.

                    Comment

                    • bonneylake
                      Contributor
                      • Aug 2008
                      • 769

                      Originally posted by acoder
                      I meant the top of the loop, i.e. inside it not above it.

                      For the stored procedure, you'd need to pass the ticket id and serial no, then in the stored proc. delete from the serial table where the inputs match (probably similar to what you have now and I vaguely remember you having one that worked earlier). Note that you wouldn't need to do any of this if you just deleted everything at the top and then started afresh with the inserts, but you wanted to avoid that.
                      Hey Acoder,

                      Ok so would this be right or does this need to be under the cfset or the cfquery for the serialinsetupda te?

                      Code:
                      <CFIF REQUEST_METHOD EQ "POST">
                       <!---<CFSET machineListLen = listLen(Form.serialcount)>--->
                       <cfset currSerialNo = 1>
                       <CFLOOP list="#form.serialcount#" index="machineCount">
                        <cfloop condition="currSerialNo eq machinecount">
                       <cfquery name="deleteserialparts" datasource="CustomerSupport">
                       exec usp_CS_Deleteserialparts '#Form.pk_ticketID#'
                       </cfquery>
                       <cfset currSerialNo = currSerialNo + 1>
                       </cfloop>
                      <cfif machineCount eq currSerialNo>
                       <CFSET serialnum       = Form["serialnum_" & machineCount]>
                        <CFSET modelno         = Form["modelno_" & machineCount]>
                        <CFSET producttype     = Form["producttype_" & machineCount]>
                       <CFSET softhardware    = Form["softhardware_" & machineCount]>
                        <CFSET resolution      = Form["resolution_" & machineCount]>
                        <CFSET resdate         = Form["resdate_" & machineCount]>
                        <CFSET resvertified    = Form["resvertified_" & machineCount]>
                      <CFSET vertifidate     = Form["vertifidate_" & machineCount]>
                      <CFSET deptvendor      = Form["deptvendor_" & machinecount]>
                       <CFSET hardwarefailure = Form["hardwarefailure_" & machineCount]>
                       <CFSET thedescription  = Form["thedescription_" & machineCount]>
                       
                      
                       <!--- inserts information into the serial table--->
                       <cfquery name="serialinsertupdate" datasource="CustomerSupport">
                          exec usp_CS_Updateinsertserial 
                           <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
                           "#Form.pk_ticketID#",
                           <cfqueryparam value="#modelno#" CFSQLType = "CF_SQL_VARCHAR">,
                            <cfqueryparam value="#producttype#" CFSQLType = "CF_SQL_VARCHAR">,
                           <cfqueryparam value="#softhardware#" CFSQLType = "CF_SQL_VARCHAR">,
                           <cfqueryparam value="#resolution#" CFSQLType = "CF_SQL_VARCHAR">,
                           <cfqueryparam value="#resdate#">,
                           <cfqueryparam value="#resvertified#" CFSQLType = "CF_SQL_VARCHAR">,
                           <cfqueryparam value="#vertifidate#">,
                          <cfqueryparam value="#deptvendor#" CFSQLType = "CF_SQL_VARCHAR">,
                           <cfqueryparam value="#hardwarefailure#" CFSQLType = "CF_SQL_VARCHAR">   
                           </cfquery>
                      
                       <!---Inserts information into notes_descr table.--->
                       <cfquery name="description" datasource="CustomerSupport">
                          exec usp_CS_Insertdescription
                         <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
                         '#Form.pk_ticketID#',
                          <cfqueryparam value="#thedescription#" CFSQLType = "CF_SQL_VARCHAR">,
                         '#Form.fk_addedBy#'
                       </cfquery>
                        
                        <!---Inserts parts information into parts table.--->
                        <!---because it is a bit we don't use 'ticks' around defective for parts table--->
                       <cfparam name="form.partcounter#machinecount#" default="">
                       <cfloop list="#form['partscount' & machinecount]#" index="ps">
                      <cfparam name="Form.defective_#ps#_#machinecount#" default="0">
                        <cfparam name="Form.partsreturn_#ps#_#machinecount#" default="0">
                       <CFSET hcpn            = Form["hcpn_" & "#ps#" & "_#machinecount#"]>
                       <CFSET partsreturn     = Form["partsreturn_" & "#ps#" & "_#machinecount#"]>
                       <CFSET defective       = Form["defective_" & "#ps#" & "_#machinecount#"]>
                       <CFSET rma             = Form["rma_" & "#ps#" & "_#machineCount#"]>
                      <cfquery name="parts" datasource="CustomerSupport">
                         exec usp_CS_Updateinsertparts 
                        <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
                         '#Form.pk_ticketID#',
                          <cfqueryparam value="#hcpn#" CFSQLType = "CF_SQL_VARCHAR">,
                          <cfqueryparam value="#partsreturn#" CFSQLType = "CF_SQL_VARCHAR">,
                          <cfqueryparam value="#rma#" CFSQLType = "CF_SQL_VARCHAR">,
                         <cfqueryparam value="#defective#" CFSQLType = "CF_SQL_BIT">
                      
                       </cfquery> 
                      
                      </cfloop>
                      </CFLOOP>
                       </CFIF>

                      and here is what i had previously for the stored procedure. But just not sure how to do the part where you said delete from the serial table where the inputs match . are you meaning when serial and the ticket number match?


                      Code:
                         1. set ANSI_NULLS ON
                         2. set QUOTED_IDENTIFIER ON
                         3. go
                         4.  
                         5.  
                         6.  
                         7.  
                         8.  
                         9. -- =============================================
                        10. -- Author:        <Author,,Name>
                        11. -- Create date: <Create Date,,>
                        12. -- Description:    <Description,,>
                        13. -- =============================================
                        14. ALTER PROCEDURE [dbo].[usp_CS_Deleteserialparts]
                        15.     -- Add the parameters for the stored procedure here
                        16.       (
                        17.       @pka_serialNo nvarchar(100)
                        18.       @pkb_fk_ticketNo nvarchar(100)) AS
                        19.  
                        20. DELETE FROM dbo.tbl_CS_serial where 
                        21. (pka_serialNo = @pka_serialNo and pkb_fk_ticketNo = @pkb_fk_ticketNo)
                      Thank you,
                      Rach

                      Comment

                      • acoder
                        Recognized Expert MVP
                        • Nov 2006
                        • 16032

                        Originally posted by bonneylake
                        Ok so would this be right or does this need to be under the cfset or the cfquery for the serialinsetupda te?
                        No, that would be correct, though you'll need to change the condition to neq. You also need to pass the serial number too.
                        Originally posted by bonneylake
                        and here is what i had previously for the stored procedure. But just not sure how to do the part where you said delete from the serial table where the inputs match . are you meaning when serial and the ticket number match?
                        Yes, and the stored procedure looks right.

                        Comment

                        • bonneylake
                          Contributor
                          • Aug 2008
                          • 769

                          Originally posted by acoder
                          No, that would be correct, though you'll need to change the condition to neq. You also need to pass the serial number too.
                          Yes, and the stored procedure looks right.
                          Hey Acoder,

                          So is this all correct an ready to try?

                          Code:
                          <CFIF REQUEST_METHOD EQ "POST">
                           <!---<CFSET machineListLen = listLen(Form.serialcount)>--->
                           <cfset currSerialNo = 1>
                           <CFLOOP list="#form.serialcount#" index="machineCount">
                            <cfloop condition="currSerialNo neq machinecount">
                           <cfquery name="deleteserialparts" datasource="CustomerSupport">
                           exec usp_CS_Deleteserialparts '#Form.pk_ticketID#',
                            <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">
                           </cfquery>
                           <cfset currSerialNo = currSerialNo + 1>
                           </cfloop>
                          <cfif machineCount eq currSerialNo>
                           <CFSET serialnum       = Form["serialnum_" & machineCount]>
                            <CFSET modelno         = Form["modelno_" & machineCount]>
                            <CFSET producttype     = Form["producttype_" & machineCount]>
                           <CFSET softhardware    = Form["softhardware_" & machineCount]>
                            <CFSET resolution      = Form["resolution_" & machineCount]>
                            <CFSET resdate         = Form["resdate_" & machineCount]>
                            <CFSET resvertified    = Form["resvertified_" & machineCount]>
                          <CFSET vertifidate     = Form["vertifidate_" & machineCount]>
                          <CFSET deptvendor      = Form["deptvendor_" & machinecount]>
                           <CFSET hardwarefailure = Form["hardwarefailure_" & machineCount]>
                           <CFSET thedescription  = Form["thedescription_" & machineCount]>
                           
                          
                           <!--- inserts information into the serial table--->
                           <cfquery name="serialinsertupdate" datasource="CustomerSupport">
                              exec usp_CS_Updateinsertserial 
                               <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
                               "#Form.pk_ticketID#",
                               <cfqueryparam value="#modelno#" CFSQLType = "CF_SQL_VARCHAR">,
                                <cfqueryparam value="#producttype#" CFSQLType = "CF_SQL_VARCHAR">,
                               <cfqueryparam value="#softhardware#" CFSQLType = "CF_SQL_VARCHAR">,
                               <cfqueryparam value="#resolution#" CFSQLType = "CF_SQL_VARCHAR">,
                               <cfqueryparam value="#resdate#">,
                               <cfqueryparam value="#resvertified#" CFSQLType = "CF_SQL_VARCHAR">,
                               <cfqueryparam value="#vertifidate#">,
                              <cfqueryparam value="#deptvendor#" CFSQLType = "CF_SQL_VARCHAR">,
                               <cfqueryparam value="#hardwarefailure#" CFSQLType = "CF_SQL_VARCHAR">   
                               </cfquery>
                          
                           <!---Inserts information into notes_descr table.--->
                           <cfquery name="description" datasource="CustomerSupport">
                              exec usp_CS_Insertdescription
                             <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
                             '#Form.pk_ticketID#',
                              <cfqueryparam value="#thedescription#" CFSQLType = "CF_SQL_VARCHAR">,
                             '#Form.fk_addedBy#'
                           </cfquery>
                            
                            <!---Inserts parts information into parts table.--->
                            <!---because it is a bit we don't use 'ticks' around defective for parts table--->
                           <cfparam name="form.partcounter#machinecount#" default="">
                           <cfloop list="#form['partscount' & machinecount]#" index="ps">
                          <cfparam name="Form.defective_#ps#_#machinecount#" default="0">
                            <cfparam name="Form.partsreturn_#ps#_#machinecount#" default="0">
                           <CFSET hcpn            = Form["hcpn_" & "#ps#" & "_#machinecount#"]>
                           <CFSET partsreturn     = Form["partsreturn_" & "#ps#" & "_#machinecount#"]>
                           <CFSET defective       = Form["defective_" & "#ps#" & "_#machinecount#"]>
                           <CFSET rma             = Form["rma_" & "#ps#" & "_#machineCount#"]>
                          <cfquery name="parts" datasource="CustomerSupport">
                             exec usp_CS_Updateinsertparts 
                            <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
                             '#Form.pk_ticketID#',
                              <cfqueryparam value="#hcpn#" CFSQLType = "CF_SQL_VARCHAR">,
                              <cfqueryparam value="#partsreturn#" CFSQLType = "CF_SQL_VARCHAR">,
                              <cfqueryparam value="#rma#" CFSQLType = "CF_SQL_VARCHAR">,
                             <cfqueryparam value="#defective#" CFSQLType = "CF_SQL_BIT">
                          
                           </cfquery> 
                          
                          </cfloop>
                          </CFLOOP>
                           </CFIF>
                          Thank you,
                          Rach

                          Comment

                          • acoder
                            Recognized Expert MVP
                            • Nov 2006
                            • 16032

                            If it's test data, it's always ready to try ;)

                            You just need to swap ticket and serial numbers around for the query.

                            Comment

                            • bonneylake
                              Contributor
                              • Aug 2008
                              • 769

                              Originally posted by acoder
                              If it's test data, it's always ready to try ;)

                              You just need to swap ticket and serial numbers around for the query.
                              Hey Acoder,

                              I tried it an its wanting a end </cfif> to go with
                              <cfif machineCount eq currSerialNo> an i looked back at your example an i think i might of had one part wrong. so does this seem more correct?

                              Code:
                              <CFIF REQUEST_METHOD EQ "POST">
                               <!---<CFSET machineListLen = listLen(Form.serialcount)>--->
                               <cfset currSerialNo = 1>
                               <CFLOOP list="#form.serialcount#" index="machineCount">
                               <cfif machineCount eq currSerialNo>
                                <cfloop condition="currSerialNo neq machinecount">
                               <cfquery name="deleteserialparts" datasource="CustomerSupport">
                               exec usp_CS_Deleteserialparts   
                               <cfqueryparam value="#serialnum#" CFSQLType = "CF_SQL_VARCHAR">,
                               '#Form.pk_ticketID#'
                               </cfquery>
                               <cfset currSerialNo = currSerialNo + 1>
                               </cfloop>
                               </cfif>
                               <CFSET serialnum       = Form["serialnum_" & machineCount]>
                                <CFSET modelno         = Form["modelno_" & machineCount]>
                                <CFSET producttype     = Form["producttype_" & machineCount]>
                               <CFSET softhardware    = Form["softhardware_" & machineCount]>
                                <CFSET resolution      = Form["resolution_" & machineCount]>
                                <CFSET resdate         = Form["resdate_" & machineCount]>
                                <CFSET resvertified    = Form["resvertified_" & machineCount]>
                              <CFSET vertifidate     = Form["vertifidate_" & machineCount]>
                              <CFSET deptvendor      = Form["deptvendor_" & machinecount]>
                               <CFSET hardwarefailure = Form["hardwarefailure_" & machineCount]>
                               <CFSET thedescription  = Form["thedescription_" & machineCount]>

                              Thank you :),
                              Rach

                              Comment

                              • acoder
                                Recognized Expert MVP
                                • Nov 2006
                                • 16032

                                Well, you don't need that cfif line at all, and you also need to add a currSerialNo increment line within the main loop, e.g. after parts on line 73.

                                Comment

                                Working...