party::new (public)

 party::new [ -form_id form_id ] [ -variable_prefix variable_prefix ] \
    [ -creation_user creation_user ] [ -creation_ip creation_ip ] \
    [ -party_id party_id ] [ -context_id context_id ] [ -email email ] \
    party_type

Defined in packages/acs-tcl/tcl/community-core-procs.tcl

Creates a party of this type by calling the .new function for the package associated with the given party_type. This function will fail if there is no package.

There are now several ways to create a party of a given type. You can use this Tcl API with or without a form from the form system, or you can directly use the PL/SQL API for the party type.

Examples:


    # OPTION 1: Create the party using the Tcl Procedure. Useful if the
    # only attribute you need to specify is the party name

    db_transaction {
        set party_id [party::new -email "joe@foo.com" $party_type]
    }


    # OPTION 2: Create the party using the Tcl API with a templating
    # form. Useful when there are multiple attributes to specify for the
    # party

    template::form create add_party
    template::element create add_party email -value "joe@foo.com"

    db_transaction {
        set party_id [party::new -form_id add_party $party_type ]
    }

    # OPTION 3: Create the party using the PL/SQL package automatically
    # created for it

    # creating the new party
    set party_id [db_exec_plsql add_party "
      begin
        :1 := ${party_type}.new (email => 'joe@foo.com');
      end;
    "]

    

Switches:
-form_id (optional)
The form id from templating form system (see example above)
-variable_prefix (optional)
-creation_user (optional)
-creation_ip (optional)
-party_id (optional)
-context_id (optional)
-email (optional)
The email of this party. Note that if email is specified explicitly, this value will be used even if there is a email attribute in the form specified by form_id.
Parameters:
party_type (required)
The type of party we are creating
Returns:
party_id of the newly created party
Author:
Oumi Mehrotra <oumi@arsdigita.com>
Created:
2001-02-08

Partial Call Graph (max 5 caller/called nodes):
%3 packages/acs-subsite/www/admin/parties/new.tcl packages/acs-subsite/ www/admin/parties/new.tcl party::new party::new packages/acs-subsite/www/admin/parties/new.tcl->party::new db_0or1row db_0or1row (public) party::new->db_0or1row package_instantiate_object package_instantiate_object (public) party::new->package_instantiate_object

Testcases:
No testcase defined.
Source code:

    # We select out the name of the primary key. Note that the
    # primary key is equivalent to party_id as this is a subtype of
    # acs_party

    if { ![db_0or1row package_select {
        select t.package_name, lower(t.id_column) as id_column
          from acs_object_types t
         where t.object_type = :party_type
    }] } {
        error "Object type \"$party_type\" does not exist"
    }

    set var_list [list  [list context_id $context_id]   [list $id_column $party_id]  [list "email" $email]]

    return [package_instantiate_object  -creation_user $creation_user  -creation_ip $creation_ip  -package_name $package_name  -start_with "party"  -var_list $var_list  -form_id $form_id  -variable_prefix $variable_prefix  $party_type]
Generic XQL file:
packages/acs-tcl/tcl/community-core-procs.xql

PostgreSQL XQL file:
packages/acs-tcl/tcl/community-core-procs-postgresql.xql

Oracle XQL file:
packages/acs-tcl/tcl/community-core-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: