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. In the Properties window click on the Data tab.
  3. Select Text for the Data Type property.
  4. In the Properties window click on the 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 PHP, you should see the tasks_maint_events.php file, with the following lines of code:
    //Custom Code @28-73254650
    //-------------------------
       //Write your own code here.
    //-------------------------
    //End Custom Code
    Replace the text:
    // Write your own code here.
    with the following:
    global $tasks;
    global $DBIntranetDB;
    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(CCGetUserID(), 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