CodeCharge Studio

Use the Before Show Event to Alter a Label's Value

  1. Select the Label user_id_assign_by in the Project Explorer.
  2. Click on the Data tab in the Properties window.
  3. Select Text as the Data Type.
  4. In the Properties window click on Events tab.
  5. Right-click on Before Show event and select Add Code.... .

    CodeCharge Studio should then automatically switch to Code view.

  6. Once in Code view, if you generate Perl, you should see the tasks_maint_events.pl file, with the following lines of code:
    # -------------------------
    # Write your own code here.
    # -------------------------

    Replace the text:

    # Write your own code here.

    with the following:

    $DBIntranetDB = clsDBIntranetDB->new();
    if ( $tasks->{EditMode} )
    {
      $tasks->{user_id_assign_by}->SetValue(CCDlookUp("emp_name", "employees", " emp_id=" .
               $DBIntranetDB->ToSQL($tasks->{user_id_assign_by}->GetValue(), $ccsInteger),$DBIntranetDB));
    }
    else
    {
      $tasks->{user_id_assign_by}->SetValue(CCDlookUp("emp_name", "employees", " emp_id=" .
               $DBIntranetDB->ToSQL(CCGetSession("UserID"), $ccsInteger), $DBIntranetDB));
    }

    The above code consists of the following elements:


    The whole code reads approximately as follows:


Next: Add a Hidden "Assigned By" Field to Auto-Update New Tasks


On-line, printable versions and updates