Skip to main content
Skip table of contents

Customizing Examples

Extend the Listbox for Dynamic Grouping

Procedure

  • Create a text constant for the new criterion in the Text Constants module, e.g. for DI005352 Product.
  • In the value range of DI029130, enter the new text constant at position 12.
  • Enter DI005352 Product in listbox category 00000333 analogously to the others.
  • In the ppms_cu.py under groupings 12: add ‘product‘ (…./py/api/ppms/customizing/venus/ppms):
PY
GROUPINGS = {1:'customer', 2:'pr_manager_name', 3:'ht_pr_code_name', 4:'pr_group_1',
             5:'pr_group_2', 6:'pr_group_3', 7:'ou_cctr_name', 8:'calculated_end_date',
             9:'phase_name', 10:'ht_pr_plan_idea', 12:'product'}
  • Enter DI005352 in the value range in DI029160 analogously to the others.
  • Restart server.
  • Enter DI005352 in data area 041023 in W9.
  • Restart client.

Note

  • The procedure applies to alphanumerical data fields. To include the date data fields in the listbox, please contact your PLANTA consultant since new DIs and value ranges must be created for this.

Show Logged-On Users

Objective

  • Customizing a module which displays the logged-on users.

Procedure

  • Create a module with three data areas.
    • Data area 1:
      • Grouped by DI001603 Start date
      • Displayed in window 1: DI001603 Start date
    • Data area 2:
      • Grouped by DI001606 User
      • Displayed in window 1: DI001606 User, DI010670 User name
    • Data area 3:
      • Displayed in window 1: DI001603 Start date (Filter from @15), DI = 004353 Start time (Filter from = 00:00, Window = 9)

Step 1: Create a new module

  • Create a new module with the required name in the Modules module and insert a macro which filters upon module start.

Step 2: Create the Date data area

  • Insert a new data area assignment.
  • Create a new data area with the following parameters:
    • DDI = 001603 Start date
    • Grouping =
  • Insert the following data field:
    • DI = 001603 Start date
  • Save.
  • Assign data area to the module and adjust the following parameters:
  • Save module

Step 3: Create the User data area

  • Insert a new data area assignment.
  • Create a new data area with the following parameters:
    • DDI = 001606 User
    • Grouping =
  • Insert two new data fields in the Data Areas module.
    • DI = 001606 User
    • DI = 010670 User name
  • Save.
  • Assign data area to the module and adjust the following parameters:
    • Pos. = 2
    • Parent area = 1
    • Output =
  • Save module

Step 4: Create the Log-on times data area

  • Insert a new data area assignment.
  • Create a new data area with the following parameters:
    • DDI = 001595 Session
  • Insert the following data fields in the Data Areas module:
    • DI = 001603 start date
    • DI = 004353 start time
    • DI = 004376 end time
  • For the Start date data field, enter @15 in the Filter from parameter
  • Adjust the following parameters for the End time data field
    • Filter from = 00:00
    • Window = 9
  • Save.
  • Assign data area to the module and adjust the following parameters:
    • Pos. = 3
    • Parent area = 2
    • Output =
  • Save module

Step 5: Test Module

  • Click on the Start current module button in the Modules module in order to test the newly created module.
  • With activated tree display as well as with symbols, the result will, e.g., look like this:

Example:

Customizing Solution for Copying Technical Task IDs When Copying Schedules

Procedure

  • Open the customizer and
    • delete the recursive relation in data area 041668 in module 0099J9
    • Move DI001098 to the first position (window 1, if you want it to be visible)
    • set DI008845 and DI008851 to input
    • Save and restart PLANTA.

Display a Graphic from a Hyperlink Data Field in an OLE Data Item

Objective

  • To display a graphic from a hyperlink data field in an OLE data item

Procedure

  • Customize an OLE data item
  • Store the following value range for the newly created DI:
    • Legend: <Python ID> and <Data item ID> serve as placeholders for the Python ID as well as the ID of the hyperlink data item.
PY
def computeOutput(di):
    hl_di = di.get_dtp_record().get_di('<Python-ID>')
    hl = hl_di.get_hyperlink()
    if (hl != None):
        ppms.ui_message_box(hl.get_uid())
        return hl.get_uid()
    else:
        return ""
computeOutput.deps = ('DI<Dataitem-ID>',)

Notes

  • This works for the common image formats jpg, bmp, gif and png.
  • The used hyperlink DI must be a HL: files in the DB.
    • HL: Files in the DB have a subordinate data item with SD function and Option = 1.
  • The OLE is only displayed after the hyperlink has been saved.

See also: OLE Data Item, Hyperlink Customizing

Customize Menu Item for Export in Excel

Objective

  • To customize a customized Excel export

Procedure

  • Create a menu item for opening modules.
  • Create a macro module with the following code for this menu item.
    • If particular parameters, that can be specified in the export dialog, are preset, this macro has to be adjusted individually. If you have any questions, please contact your PLANTA consultant
PY
mod_obj = ppms.get_target_module()
uid = mod_obj.get_uid()

ppms.client_exec("""
env = get_Env()
mod = env.ActivePanel.ModuleManager.__getitem__('%s')
doc = mod.CreateExcelExportDocument()
env.GenerateExcelFile(doc)
""" % uid)
See also: IronPython Api

Example of Individual Listbox Customizing

Objective

  • To build a listbox that directly selects a combined key.

Note

  • get_listboxvalue() from the Customizing Helper module only implements a mapping between actual values in data tables and the IDs of fixed listbox values in the corresponding table. However, it cannot read any arbitrary value from a listbox record.
    • Approach: Assemble and disassemble key values via a Python value range.

Procedure

  • A new DI of the X type / ALG is created as a Python value range.
  • In the incarnation, this DI is used as an ID field, and in the data area of the listbox it is used for LB selection.
  • The computeOutput method reads the corresponding key DIs and concatenates them with a pipe "|" as a separator, which can be done by using the format method of the string class in Python.
  • The processInput method separates the values analogously and writes them in individual key DIs.
  • In order for this procedure to work properly, it is forbidden to use the pipe sign in key values.
  • Upon their composition, the example implementation does neither check the existence of pipes in key values nor that of redundant separators or values upon their separation.
PY
def computeOutput(di):
    record = di.get_dtp_record()
     
    key0 = record.get_di_by_id(<key0_numeric_di_no>).get_value()
    # etc. für weitere DIs

    multicol_key_template = '{0}|{1}|{2}'
    multicol_key_value = multicol_key_template.format(key0, key1, key2)

    return multicol_key_value 

computeOutput.deps = ('DI<key0_textual_di_no>', 'DI<key1_textual_di_no>', ) # etc. für weitere DIs
PY
def processInput(di, oldvalue):
    record = di.get_dtp_record()

    key0_di = record.get_di_by_id(<key0_numeric_di_no>)
    # etc. für weitere DIs

    new_value = di.get_value()
    key_values = new_value.split('|', 3)

    key0_di.set_value(key_values[0])

    return new_value

processInput.deps = ('DI<key0_textual_di_no>', 'DI<key1_textual_di_no>', ) # etc. für weitere DIs

Notes

  • A textual_di_no is, for example, string 000123; a numeric_di_no, however, is the number 123
  • Further documentation can be found under PythonValueRange as well as in the Python reference: http://docs.python.org/py3k/ or http://docs.python.org/py3k/library/stdtypes.html#str.split

Open E-mail Client

Objective

  • To customize hyperlink data fields in order to open an e-mail client via Python
    • For data fields with data items that possess the AM DF type

Procedure

PY
subject_text = "" body_text = ""
  • subject_text = subject of the e-mail
  • body_text = content of the e-mail

Adjustment options of the values: Subject and content:

  • In the customizing shown above, subject and content are not filled. Manual input is required in the e-mail.
  • In order to fill subject or content, you can use the PythonAPIReference .
    • To do so, set the subject_text and body_text variables in the Data Field Configuration data field via Python.
    • In order to access the values of the records, you can use the _Record_ object which is an instance of the MTSRecord class.
PY
subject_text = record.name.get_raw_value()

Facilitate the Reporting of External Hours

Objectives

  • To switch from a newly created module for the resource overview to a shortened Employee Board panel.
    • The shortened Employee Board panel is to be opened with the Time Recording module.

Procedure

  • Create a copy of the Employee Board (MOD0099GU). (Here: MOD100003).
  • Delete unwanted submodules in the newly created module (here: My Activities, Week Calendar, Infos, My Planning Objects) or deactivate the checkboxes for these submodules in the Display field.
  • Adjust the order of the remaining submodules so that the Time Recording (MOD009ABV) submodule is opened first. For this purpose, edit the following parameters for this module:
    • For reporting to unplanned tasks, listboxes may have to be individualized
  • Adjust the call_resource() function in the macro of the copied employee board as follows:
PY
from ppms.text_constant import get_text_constant

def call_resource(resource_id=ppms.get_target_module().get_current_L_var()[5]):
    resource_record = ppms.search_record(467, [resource_id[0]], ['resource_type'], True)
    if not resource_record :
        message = get_text_constant("001247")
        ppms.ui_message_box(message.replace("@user_id", resource_id[0]), blocking=1)
        mod_obj.menu(49)
    elif resource_record.resource_type.get_value() == "2":
        ppms.ui_message_id("0860")
        mod_obj.menu(49)
    else:
        mod_obj.set_current_L_var(5, [resource_id[0]])
  • Create the Python ID for the new module (MOD100003) in the Python ID field in the Global Settings module, here: L100_employee_board_for_reporting
  • Create a macro (here: 100004) which calls the shortened employee board which contains the select (@L5).
PY
from ppms.global_setting import get_global_setting_value

mod_obj = ppms.get_target_module()

rm_modul = get_global_setting_value("L100_employee_board_for_reporting", 'alpha120')

inv_rec = ppms.get_context_df().get_record()
res_id = inv_rec.res_id.get_raw_value()
mod_obj.set_new_L_var(5, [res_id])

mod_obj.open_module(rm_modul)
  • Create a module with resource overview.
  • If you want to open the module via a link on the resource ID,
    • enter the number of the new macro (here: 100004) in the Action ID field of the required resource DI and e4 in the DF behavior field.
  • If you want to open the module via a context menu,
    • add DI 004336 Button/IronPython_ and enter the number of the new macro in its Action ID field (here 100004) and m4 in the DF behavior field.

Refresh Fields Upon Saving if a Value Has Been Changed

Objective

  • To refresh the individual Forecast from and Forecast by fields if the forecast value has been changed.

Procedure

  • Open Customizer → System Customizer → Data Dictionary.
  • Create Individual Data Items (here: DI100102 and DI100103).
  • Open Customizer → System Customizer → Data Items.
  • Adjust the value range of the Forecast (DI006530) data item as follows:
PY
def processInput(di, oldvalue):
    rec = di.get_dtp_record()
    rec.L100_prognose_vom.set_value(ppms.uvar_get("@15"))
    rec.L100_prognose_von.set_value(ppms.uvar_get("@1"))
    return di.get_value()
processInput.deps = ("L100_prognose_vom", "L100_prognose_von")

Example of Drag & Drop Copying via Python

Objective

  • The value from the Planned effort field is to be transferred to the Planned effort fix field.

Example

PY
mod_obj = ppms.get_target_module()
mod_obj.menu(12)

for rec in mod_obj.get_da ("Python_ID_DA_name").get_records():
    rec.DF_Python_ID_planned_load_fixed.set_raw_value(rec.DF_Python_ID_planned_load.get_raw_value())

mod_obj.menu(34)
mod_obj.menu(49)

Example of Opening an External Application With Python

Objective

  • To open an application from within PLANTA and include a specific parameter that is to be sent along

Example

PY
PATH = r'C:\Program Files (x86)\Applikation\anwendung.exe'
# Der String, der den Pfad zur Applikation darstellt, wird mit "r" vorangestellt,
# weil sonst der Backslash \ als Escape-Zeichen interpretiert werden würde.
# Siehe http://docs.python.org/reference/lexical_analysis.html#string-literals
ARGS = 'argument1=PLANTA argument2=Nocheins'
# Die Argumente, die an die Applikation übertragen werden sollen, einfach als
# einen fortlaufenden String deklarieren.

def execute_client_script(path, args):
    ppms.client_exec("""import clr
clr.AddReference('System')
from System.Diagnostics import Process

Process.Start(r'{path}', r'{args}')""".format(path=path, args=args))

execute_client_script(PATH, ARGS)


Customize a Process Rule for Copying a Phase

Objective

  • To customize a process rule that you can use to copy a phase of another process model

Procedure

  • Create a new process rule with the following code in the Process rules module (MOD0099X6) under PM Administration → Master data → Process models
  • Adjust the following parameters in this code:
    • <Process model ID>: The ID of the process model which contains the phase to be copied
    • < Phase ID >: The ID of the phase which is to be copied
PY
def executeProcessAction(mts_rec=None,object_id=None):
    from ppms.processrules import copy_phase_into_model
    phase = mts_rec.phase.get_raw_value()
    copy_phase_into_model(object_id, mts_rec, <Prozessmodell-ID>, <Phasen-ID>, phase)
 
    return True
 
ppms.get_session_dict()["planta_functions"]=[executeProcessAction]
  • Create a new process step in the Process Model Templates module (MOD0099TY) under PM Administration→ Master Data →Process Models
  • Select this rule in the Process rule name field

Customize a Process Rule for Copying Process Steps to a Future Phase

Objective

  • To customize a process rule with which a future phase of a process model can be extended by existing process steps of another process model.

Procedure

  • Create a new process rule with the following code in the Process rules module (MOD0099X6) under PM Administration → Master data → Process models
  • Adjust the following parameters in this code:
    • <Process model ID>: The ID of the process model which contains the rocess steps to be copied
    • < Phase ID >: The ID of the phase the process steps of which are to be copied
    • <Target phase ID>: ID of the future phase to which the rules are to apply
PY
def executeProcessAction(mts_rec=None,object_id=None):
        from ppms.processrules import replace_phase_in_model
        replace_phase_in_model(project_id=object_id, 
                               prozess_templ_id=<Prozessmodell-ID>,
                               phase=<Phasen-ID>,
                               forced_phase=<Zielphasen-ID>)
        
        return True
ppms.get_session_dict()["planta_functions"]=[executeProcessAction]
  • Create a new process step in the Process Model Templates module (MOD0099TY) under PM Administration→ Master Data →Process Models
  • Select this rule in the Process rule name field

Customize an Individual Module for Editing Resources

Information

  • If the parent resources or the start and end periods are to be adjusted in an individual module, the following adjustments must be made in this module:
    • Specify the ppms.module_subclasses.resource.ResourceDatasheet Python module subclass in the Python module subclass parameter in the Modules module.
    • Overwrite the Save menu item (34) with a macro that contains the following code:
PY
ppms.get_target_module().on_save_check_person_resource()
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.