]project-open[ : @This Wiki
Portrait

Welcome, Unregistered Visitor

Contact ·  Index · Login · Register
 

Contents

Remote Training
Support
SaaS Service

6 registered users
 in last 24 hours

Dynfields

Creating Dynfields using PL/pgSQL

Example: Update Script

-- upgrade-4.0.0.0.7-4.0.0.0.8.sql
SELECT acs_log__debug('/packages/intranet-cust-company01/sql/postgresql/upgrade/upgrade-4.0.0.0.7-4.0.0.0.8.sql','');

create or replace function inline_0 ()
returns integer as $BODY$
declare
        v_category_id_1           integer;
        v_category_id_2           integer;

begin
        -- Note that the Category Type ('Intranet Brown Company Affiliation') does not ned to be created separately.

        select im_category_find_next_free_id_in_sequence(10000000,99999999) into v_category_id_1;
        PERFORM im_category_new (v_category_id_1,'Brown','Intranet Brown Company Affiliation',null);

        select im_category_find_next_free_id_in_sequence(10000000,99999999) into v_category_id_2;
        PERFORM im_category_new (v_category_id_2,'Brown Frankfurt','Intranet Brown Company Affiliation',null);

        return 1;
end;
$BODY$
language 'plpgsql';
select inline_0 ();
drop function inline_0 ();

-- --------------------------------------------------------------------------------------------------------------------------------

create or replace function inline_0 ()
returns integer as $BODY$
declare
        v_dynfield_id           integer;
begin

        PERFORM im_dynfield_widget__new (
                null,
                'im_dynfield_widget',
                now(),
                0,
                '0.0.0.0',
                null,
                'brown_affiliation',                                                    -- p_widget_name
                'Company Affiliation',                                                 -- p_pretty_name
                'Company Affiliation',                                                 -- p_pretty_plural
                10007,                                                                  -- p_storage_type_id (10007: Table Column, 10005: Multi-Select Mapping Table)
                'integer',                                                              -- p_acs_datatype
                'im_category_tree',                                                     -- p_widget
                'integer',                                                              -- p_sql_datatype
                '{custom {category_type "Intranet Brown Company Affiliation"}}'        -- p_parameters
        );

        return 1;

end;
$BODY$
language 'plpgsql';
select inline_0 ();
drop function inline_0 ();

-- --------------------------------------------------------------------------------------------------------------------------------

create or replace function inline_0 ()
returns integer as $BODY$
declare
        v_dynfield_id           integer;
begin

        -- function im_dynfield_attribute_new returns
        --      id of new dynfield when creation was successful
        --      '1' when dynfield already existed

        SELECT im_dynfield_attribute_new (
                'person',                               -- p_object_type
                'affiliation_id',                       -- p_column_name
                'Affiliation',                          -- p_pretty_name
                'brown_affiliation',                    -- p_widget_name
                'integer',                              -- p_datatype
                'f',                                    -- p_required_p
                 0,                                     -- p_pos_y
                'f',                                    -- p_also_hard_coded_p
                'im_employees'                          -- p_table_name
        ) into v_dynfield_id ;

        RAISE NOTICE 'upgrade-4.0.0.0.7-4.0.0.0.8.sql: Created Dynfield ''Affiliation'' -  v_dynfield_id: %',v_dynfield_id;

        -- 'Edit' Permissions are automaticllay granted by im_dynfield_attribute_new for all users, in some cases you might want to revoke them
        -- PERFORM acs_permission__revoke_permission(v_dynfield_id, (select group_id from groups where group_name='HR Managers'), 'write');

        -- since im_dynfield_attribute_new does not support creation of table columns other than the DEFAULT table, we add it manually
        begin
                alter table im_employees add column affiliation_id integer;
        exception when others then
                raise notice 'upgrade-4.0.0.0.7-4.0.0.0.8.sql: Could not create column affiliation_id';
        end;

        return 1;

end;$BODY$ language 'plpgsql';
select inline_0 ();
drop function inline_0 ();

­Adding Dynfields to a Form 

set field_cnt [im_dynfield::append_attributes_to_form \
    -object_subtype_id "" \
    -object_type "person" \
    -form_id $form_id \
    -object_id $employee_id \
]

 

 


Please take a moment to complete this form to help us improve our service.

Note:
Please only provide feedback in regards to content this page shows. For support inquiries please refer either to the Community Support forum at Sourceforge or check out our 'Professional Support'

Did this page help you to achieve your goal?

 Yes  No  Don't know

Please provide us with comments to improve this page:

How useful is the information?

 1  2  3  4  5
Not
useful
      Extremely
useful
 
  

Explore

Installers
Demo Server
Modules & Functionality
Packages
Business Processes supported
FAQ's

Help

Getting started
User Manuals
Configuration Manuals
Community Support
Professional Support

News

News
Twitter
RSS Community / Sourceforge
Register for Newsletter

Get in touch

Contact
Register



Creative Commons License This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.0 Generic License - Privacy Policy