Customizing Examples
Outdated: only for internal use
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.
- Add ‘product‘ in ppms_cu.py under groupings 12 (…./py/api/ppms/customizing/venus/ppms):
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)
- Data area 1:
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:
- Insert the following data field:
- DI = 001603 Start date
- Save.
- Assign data area to the module and adjust the following parameters:
- Pos. = 1
- 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: Module test
- 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.
- Legend:
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.
- 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 consult your PLANTA consultant.
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: Combine and separate the 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.
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. for further DIs
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. for further DIs
Notes
- A
textual_di_no
is, for example, string 000123; anumeric_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
- Open the Data Area module
- Create a new data area
- Insert a data field with the following properties:
- For this data field you have to set the following parameters:
- DF behavior = e4
- Action ID = 009AAK
- Symbol ID = 001807
- DF Python ID = email_id
- Open the tree structure of the data field and enter the following parameters in the Data field configuration field:
subject_text = "" body_text = ""
subject_text
= subject of the e-mailbody_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. You have to fill them manually.
- In order to fill subject or content, you can use the PythonAPIReference .
- To do so, set the
subject_text
andbody_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.
- To do so, set the
subject_text = record.name.get_raw_value()
Embed Customer Logo
Objective
- The customer logo is to be displayed in modules (as a product logo), in the print header, and as a splash screen.
Step 1: Providing customer logos as graphic files
- PLANTA supports the .png and .jpg formats.
- The maximum picture size can vary depending on the Windows settings.
- If you use the default Windows settings, the image sizes of the PLANTA logos stored by default can serve as an orientation (height * width).
- Product logo: 49 px * 458 px
- Print header 32 px * 32 px
- Splash screen: 478 px * 475 px
- If you use the default Windows settings, the image sizes of the PLANTA logos stored by default can serve as an orientation (height * width).
Step 2: Using the logo in modules (as a product logo)
- Open Customizer → Layout Objects → OLEs → Product Logos module variant.
- Insert a blank record.
- Allocate a name in the Name field.
- The OLE number is generated automatically.
- Select the Product logos value from the listbox in the Category field.
- Insert the provided file for the modules in the Standard OLE field.
- Save.
-
Click on the Use system-wide as logo button for the newly created OLE.
- The Do you want to embed the required graphic as a product logo system-wide? The product logo of all modules will be replaced by this logo. dialog message will be displayed.
- Confirm this message with Yes.
- Restart the program.
- All existing modules of the system now have the new product logo.
- For new modules, the new product logo is automatically set as the default product logo.
Step 3: Using the logo in the print header
- Open Customizer → Layout Objects → OLEs.
- Allocate a name in the Name field.
- The OLE number is generated automatically.
- Insert the provided file for the print header in the Standard OLE field.
- Save.
- Open Customizer → Layout Objects → Skins.
- Memorize the ID number for the module for print areas in the Module for Print Areas field or copy it via CTRL + C.
- Open Customizer → Module Customizer → Modules
- Create the individual print module by copying the Module for print areas.
- Enter the ID number of the module to be copied in the Copy from data field.
- After you have pressed ENTER, a new module number is generated in the MOD data field.
- Enter a new title in the Module data field.
- Save. When you save, all the parameters of the source module as well as its subobjects (submodules, data areas, module variants) are copied to the new module.
- Open the Print header data area in the individual print module.
- Enter the OLE ID (DBOLE (ID) in the Default value field.
- Adjust the position if necessary.
- Save.
- Open Customizer → Layout Objects → Skins.
- Select the required skin from the listbox.
- In the Module for Print Areas field, enter the ID number of the individual module.
- Save.
Step 4: Using the logo as a splash screen
- Replace the splash.png file under %client_folder%/Resources/ by the provided file.
See also: Splash Screen, Use Product or Company Logo |
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 submodule is opened first.
- Edit the following parameters in the Time Recording submodule:
- Enter the value 3 in the Positioning field.
- Enter the value 0.869 in the Module size field.
- Activate the Foreground checkbox.
- For reporting to unplanned tasks, listboxes may have to be individualized
- Edit the following parameters in the Time Recording submodule:
- Adjust the
call_resource()
function in the macro of the copied employee board as follows:
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 opens the shortened employee board with the required resource (@L5).
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 data item as follows:
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
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
PATH = r'C:\Program Files (x86)\Application\anwendung.exe'
# The string which represents the path to the application is preceeded by an "r",
# otherwise, the backslash \ would be interpreted as escape character.
# See http://docs.python.org/reference/lexical_analysis.html#string-literals
ARGS = 'argument1=PLANTA argument2=Nocheins'
# Simply declare the arguments which are to be transferred to the application as a
# continuous string.
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 Color Preview Field
Objective
- To customize a color preview field, here by the example of DI028197 Highlighting color in DT030 Skin
Details
- In the Skins module, a preview for the selected color is missing for DI028197 Highlight color:
Create DI
- Open DT 030 with source DI 028197 in the Data Dictionary.
- Create a new DI and set the following parameters:
- Data item = Highlighting color
- DI Python ID = highlighting_color_incarnation
- Class = 4
- virtual =
- Column type = Alpha
- This column type is only required for the creation of the DI ID. can be deleted afterwards.
- Symbol ID = 000188
- Save.
- Update system customizing (via the Tools → Restart PLANTA Service menu item).
- Note: If you click on the menu item, all open client connections (sessions) are closed. During restart, new client connections are not possible.
Assign subordinate data item
- Right-click on the DI you have just created and select the Edit data item context menu command.
- Right-click on DI → Insert → Subordinate data item.
- Insert the ID of the source DI (028197) in the SUBDI field.
- Select value C (color) from the Function listbox.
- Save.
Insert DI in data area
- Now, assign the created DI to the data area which contains the source DI.
- Set the DF behavior to o (output).
- Save.
- In order for the data field to be displayable, the following fields must be adjusted:
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 in the Process Rules module with the code shown below.
- Adjust the following parameters in this code:
- <Process model ID>: process model ID containing the copied phase
- < Phase ID >: ID of the phase to be copied
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.
- 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 in the Process Rules module with the code shown below.
- Adjust the following parameters in this code:
- <Process model ID>: process model ID containing the process steps to be copied in
- < Phase ID >: ID of the phase the process steps of which are to be copied
- <Target phase ID>: ID of the future phase for which you want the rule to take effect
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=<Phase ID>,
forced_phase=<Target phase ID>)
return True
ppms.get_session_dict()["planta_functions"]=[executeProcessAction]
- Create a new process step in the Process Model Templates module.
- 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 with a macro that contains the following code:
- Specify the
ppms.get_target_module().on_save_check_person_resource()