How to create associated table

Document created by cdtj Champion on Jul 12, 2016
Version 1Show Document
  • View in full screen mode

Out of the box Configuration Items are extended with associated tables, this is looking good when you need to extend general factory with some attributes but they should be appended only for specified situation.

In our environment Workflow Task's factory extended with 100+ custom attributes but most of them are left blank for most of workflows, this is why I want to append those attributes only then they are needed - solution was to create associated table.

 

For example I have workflow task named Approvment (code: APP) that should contain flag1 and flag2 string attributes. Assoicated table will be created in this way:

 

New table creation

Using WSP I have created new table named z_wf_assoc with followed attributes:

     wf SREL: to wf table;

     attr1 string(32);

     attr2 string(32);

 

Triggers manage

To manage associated table we need to create maj file, for ease of use I'm calling it as table: z_wf_assoc.maj.

OBJECT wf {
    ATTRIBUTES Workflow_Task {
        wf_assoc BREL z_wf_assoc wf DYNAMIC { UI_INFO "dtlTextbox"; };
    };
    TRIGGERS {
        POST_VALIDATE z_create_assoc() 9000 FILTER(EVENT("INSERT") && (type == "APP"));
    };
};

Where wf_assoc is BREL attribute that will be used on forms to access data and trigger to create new entry in associated table when specified task is being created, for this purpose we need to create z_wf_assoc.spl file with followed code:

wf::z_create_assoc(...) {
    send_wait(0, top_object(), "call_attr", "api", "insert_object", (uuid)"", "z_wf_assoc", NULL, 0,
            "wf", persistent_id
    );
}

 

Form usage

From now attributes could be used as regular:

<PDM_IF "$args.type" == "APP">
<PDM_MACRO name=dtlTextbox hdr="attr1" attr="wf_assoc.attr1">
<PDM_MACRO name=dtlTextbox hdr="attr2" attr="wf_assoc.attr2">
</PDM_IF>

 

Any feedback are welcome!

2 people found this helpful

Attachments

    Outcomes