CodeCharge Studio

Programmatically Control Field's Value

Once you add Custom Code to the Event, you will see the code-editing window with the appropriate place to enter the new code.

  1. Replace this line of code:
    <!---   write your own code here --->

    with the following lines (ColdFusion):

    <CFPARAM Name="Session.UserLogin" Default="">
    <CFIF flduser_id_assign_to EQ Session.UserLogin AND Session.UserLogin NEQ "">
      <CFSET fldtask_name= '<b><font color="blue">' & fldtask_name & '</font></b>'>
    </CFIF>

The following is how the above code works:

<CFPARAM Name="Session.UserLogin" Default="">

This code checks the existence of the UserLogin session variable. If the variable does not exist, it is created and its values set to an empty string.

<CFIF fldtask_name EQ Session.UserLogin AND Session.UserLogin NEQ "">

This is a conditional statement that is true only if the value of the fldtask_name field is equal to the login name of the employee that is currently logged into the system. The employees1_emp_login database field provides the value for the fldtask_name field in the grid form. Once you login to the system, the program will recognize your tasks by comparing your login name to the emp_login value of the person that a task is assigned to. UserLogin is one of the session variables used by CodeCharge-generated programs, and it holds the Login name of the currently logged in user until the session expires.

Note:

The following are all default session variables created by CodeCharge Studio:


<CFSET fldtask_name= '<b><font color="blue">' & fldtask_name & '</font></b>'>

This code is executed if the previous if condition is met. It modifies the value of the task_name field. The field value is replaced with its database value wrapped within HTML code that specifies the font color as blue, and adds HTML <b> tag to make the font bold as well.

</CFIF>

This line marks the end of the if condition, so that the execution of the remaining code is not affected by this condition.

Next: Preview Tasks List Page


On-line, printable versions and updates