template_banner.gif Main Index  PREV  NEXT

Valid HTML 4.01!   Valid CSS!

Add / Create Forms

Add 1 - add an occurrence

CT_ADD1.gif

Description

This type of form is used to create a new occurrence of an entity. Only one occurrence can be stored at a time.

This is usually called from a LIST form with no parameters. Upon initial entry the user is presented with a blank screen, although initial values may have been defined for some fields. The user enters the required data, then presses either the OK button or the STORE button to update the database.

If there is the possibility that a foreign key value may be pre-selected in the calling form and therefore may not be changed by the user at runtime then refer to Note #1 below.

Buttons

STORE Will add the current entry to the database, send a message to the parent form, then clear the screen, allowing details for another occurrence to be entered.
OK Will add the current entry to the database, send a message to the parent form, then exit.
CANCEL Will abandon the current entry and exit.

Contents

Bound Objects

Source Entity Source Field Target Entity Target Field
ACTION_BAR.INF CANCEL ACTION_BAR.INF CANCEL
  OK   OK
  STORE   STORE
MAIN FIRST    
  LAST    

Local Constants (Refer to Local Constants)

Name Expression Description
FORM_VERSION 01.000.000 To be incremented each time the component is changed.

Component Variables (Refer to Component Variables)

Name Description
FORM_VERSION  
INIT_VALUES Refer to Menu and Security System User Guide, Appendix I: Initial Values for details.
PARAMS  

Note # 1 - Pre-selected Foreign Keys

If there is the possibility that a foreign key value may be pre-selected in the calling form and therefore may not be changed by the user at run time in this form then follow these steps:

  1. Create a component variable for each foreign key. This will be populated with any value passed down by the calling form with the getlistitems/id/local $params$ statement in the <exec> trigger.
  2. In the <occurrence gets focus> trigger of the main entity insert the following code (after call to LOAD_INIT_VALUES if it exists):
    Call LP_SELECT
    
  3. Create the local proc LP_SELECT with code similar to the following:
    entry LP_SELECT		; look for pre-selected value from parent form
    
    ; was PERSON_ID passed from parent form?
    getitem/id $person_id$, $params$, "person_id"
    if ($person_id$ != "") & (!$dbocc(person))
       person_id.person = $person_id$   ; set the foreign key value
       retrieve/e "person"              ; retrieve the foreign entity
       field_syntax POPUP_BUTTON.PERSON, "NDI,NED,NPR"  ; hide popup button
       field_syntax PERSON_NAME.PERSON, "NED,NPR"       ; make field 'noedit'
       $properties(PERSON_NAME) = "font=fnoeditbox"     ; change font
    endif
    
    ; was COURSE_ID passed from parent form?
    getitem/id $course_id$, $params$, "course_id"
    if ($course_id$ != "") & (!$dbocc(training_course))
       course_id. training_course = $course_id$
       retrieve/e "training_course"
       field_syntax POPUP_BUTTON.TRAINING_COURSE, "NDI,NED,NPR"
       field_syntax COURSE_NAME.TRAINING_COURSE, "NED,NPR"
       $properties(COURSE_NAME) = "font=fnoeditbox"
    endif
    
    return(0)
    
    end LP_SELECT
    
  4. Prevent the popup form from being activated for a foreign key field by disabling the <detail> trigger of that field with code similar to the following:
    if ($person_id$ != "") return(0)   ; not allowed to change
    
    call POPUP_DTL(".....")
    .....
    

Add 2 - add a MANY in a ONE-to-MANY relationship

CT_ADD2.gif

Description

This type of form is used to create a new occurrence of an entity in a ONE-to-MANY relationship. Only one occurrence of the MANY entity can be stored at a time.

This is usually called from a LIST form with a parameter that contains the primary key of the ONE entity. Upon initial entry the ONE entity is pre-retrieved and the MANY entity is shown as empty, although initial values may have been defined for some fields. The user enters the required data for the MANY entity, then presses either the OK button or the STORE button to update the database.

Buttons

STORE Will add the current entry to the database, send a message to the parent form, then clear the screen, allowing details for another occurrence to be entered.
OK Will add the current entry to the database, send a message to the parent form, then exit.
CANCEL Will abandon the current entry and exit.

Contents

Bound Objects

Source Entity Source Field Target Entity Target Field
ACTION_BAR.INF CANCEL ACTION_BAR.INF CANCEL
  OK   OK
  STORE   STORE
ONE FIRST    
MANY FIRST    
  LAST    

Local Constants (Refer to Local Constants)

Name Expression Description
FORM_VERSION 01.000.000 To be incremented each time the component is changed.

Component Variables (Refer to Component Variables)

Name Description
FORM_VERSION  
INIT_VALUES Refer to Menu and Security System User Guide, Appendix I: Initial Values for details.
PARAMS  

copyright.gif http://www.tonymarston.net