3 Replies Latest reply on Jun 26, 2008 8:57 AM by (shane_mosier)

    Another custom trigger Question...

      Sorry guys and gals. You probably went over this already, but I copied the following code from the ADDT manual and replaced what was required or so I thought. Well I don't receive an error message or an update to the column in my dbase. I am trying to update the "lstatus" from "e" to "d" where the project id is equal to a form post "proj". I will change the error msg once I get it working.

      Here is the code.

      $query = "UPDATE logo_design_table SET lstatus = ".KT_escapeForSql($tNG>getPrimaryKeyValue("d"),
      $tNG>getColumnType($tNG>getPrimaryKey("lstatus")))." WHERE lrec_id = ".$tNG>getPrimaryKeyValue($_POST['proj']);
      $update_result = $tNG>connection>execute($query);
      if(!$update_result) {
      $updateError = new tNG_error("Error setting the initial message ID",array(),array());
      return $updateError;
      } else {
      return NULL;
      }

      I'm learning to work with ADDT and PHP, I used to be able to use the command function when working with ASP to do the update.

      As always, your helpful knowledge is appreciated.
      Charles J.
        • 1. Re: Another custom trigger Question...
          Level 1
          Charles,

          I think your problem is this line:

          $tNG>getPrimaryKeyValue($_POST['proj'])

          I think you just need $tNG->getPrimaryKeyValue()

          Also, you cannot use $_POST variables using ADDT forms. ADDT posts all form variables to the same form page, and so $_POST variables from ADDT forms are not accessible by calling $_POST['proj']

          To get a value from an ADDT form variable, use the following code in the Custom Trigger:

          $proj = $tNG->getColumnValue("proj");

          I think you are incorrectly using $tNG->getPrimaryKeyValue() and I don't think any of your values are getting passed correctly. You probalby need to do some trouble shooting in the trigger.

          Use the following code for testing:

          echo "TEST D: " . $tNG>getPrimaryKeyValue("d");
          echo " TEST lstatus: " . $tNG>getPrimaryKey("lstatus");
          echo " TEST proj: " . $tNG>getPrimaryKeyValue($_POST['proj']);
          exit;

          Put this at the beginning of the trigger to see what values(if any) are generated. I'm pretty sure that one, if not all, of these variables is not being set.

          Shane
          • 2. Re: Another custom trigger Question...
            Level 1
            Thank you Shane, I'm sorry I failed to tell everyone that I wasn't using a ADDT form from the previous page, I am just using a simple form to send the variable over to the page where the custom trigger resides. I am hoping that when the page loads that the variable is saved in the trigger and after posting the ADDT form on that page it would set the trigger off supplying the needed data.

            Is my thinking wrong on this? Also, the code that you are telling me to use, should i also insert it inside the custom trigger interface?

            Once again, thank you for your assistance.
            Charles J.
            • 3. Re: Another custom trigger Question...
              Level 1
              Charles J,

              You can put that code inside the trigger at the top. All this code does is echo the values you are trying to use to the browser. This will let you know if those values are being passed to the trigger.

              The variable will not be saved in the trigger upon loading the page as the trigger is not even executed until the ADDT form is posted. In order to pass values to the trigger, you would have to do something else.

              Try this...

              Put this code at the top of your ADDT form php page(inside the