Use Case
An event is the click on a particular button or menu; the opening and closing of an estimate are events of their own.
The event management enables you to
▪auto-adapt to the estimate the Automation bar, i.e. to add buttons generally on the opening
▪define the actions triggered on clicking these buttons
▪redefine the actions triggered on clicking some standard buttons
▪run requests, macros or methods before/after predefined events.
Predefined Events
Some predefined events can be paired off to distinguish:
1.The user action (Before or Start)
2.The end of the successful process triggered by the user action (After or End).
This appears in the following tables where the names are strings of chars:
Triggering button/menu |
or File/Close |
File/Save |
Data>Insert reference |
+ Create |
Reporting PDF |
Reporting |
|||
1st-event name |
On_Macro_Button_x |
On_Open_Estimate |
On_Before_Save_Estimate |
On_Before_Insert_Article_Reference |
On_Start_Compute_Costs |
On_Start_Compute_SP |
On_Start_Produce_Word_Document |
On_After_ Create_PDF |
On_Report_Paste_Image |
2nd-event name |
– |
On_Close_Estimate |
On_After_Save_Estimate |
On_After_Insert_Article_Reference |
On_End_Compute_Costs |
On_End_Compute_SP |
On_End_Produce_Word_Document |
– |
– |
Commonly associated verb |
Run_Request Run_Macro Run_ExcelMacro |
Set_Macro_Button |
|
|
Compute_Costs_Only |
Compute_All(1,0) Set_Use_Target_Value_Flag(1) |
|
|
|
Note |
x=1 ... 10: icon position in the Macro Buttons special group |
This event can trigger a message in the status bar (Refer to General Interface.) |
|
See How to Insert an Article or a Set Using its Reference. In case of a selection of rows, the event is called only once at the end. Refer to Code Samples |
|
SP=Selling Price These events can trigger a message in the status bar (Refer to General Interface.) |
|
Le nom est donné par Context.CallingContextReportGenerator.FileName |
Refer to Reports |
For management (Custom Management: for second column, see 1st Demo sample WBS_BOQ_Planner):
Triggering button/menu |
|
Custom Management |
Compute All / / Save |
|
Event name |
On_Open_Estimate_After_Read_Management |
|
On Custom Read From Management |
On Custom Write To Management |
Commonly associated verb |
|
Run_Macro Connect Cancel_Operation |
Run_Macro: Custom Read From Management |
Run_Macro: Custom Read From Management, <Compute All> then Custom Write To Management |
Note |
Alternative to On_Open_Estimate. Event=synchro end with ProMo+ or the Management module. Refer to How to Update an Estimate. On_After_Apply_User_Profile is invoked just before, therefore you can joint the two codes for this one. |
The button invokes the macro Connect_To_Management_Database. It is used to connect to/disconnect from an Excel file used for management. See ~/SDK/ Custom Mgt/How _To _Custom_Management.pdf |
See ~/SDK/ Custom Mgt/How _To _Custom_Management.pdf
|
How to Manage the Versions (for Progress, see sample Sample_Call_Off_Contracts in Progress Statements):
Triggering button/menu |
View>Version index>Delete |
View>Version index>Make active |
|
View>Version index>Freeze version |
1st-event name |
On_Before_Delete_Version/Progress/Estimate |
On_Before_Delete-Restore _Version/Progress/Estimate |
On_Before_Push_Version/ Progress/Estimate |
On Before Freeze |
2nd-event name |
On_After_Delete_Version/Progress/Estimate |
On_After_Delete-Restore _Version/Progress/Estimate |
On_After_Push Version/ Progress/Estimate |
On After Freeze |
Commonly associated verb |
|
|
Compute_All (0,1). .Set_Value_To_Minute_Column .Set_Value_To_WBS_Column |
|
Note |
Verbs to set up the invoice: Remove_Rows_With_No_Selling_Price (before make sure the selling prices are properly calculated), Make_Groups_Sets, Copy_WBS_Column_Values Other verbs: Set_WBS_Column_Copy_To_Quantity, Set_WBS_Column_Visible_Mode, Set_Minute_Column_Visible_Mode, Remove_Total_Mode_Everywhere Set_Value_To_Minute/WBS_Column to empty the WBS_Quantity column |
For Task Sharing:
Triggering button/menu |
Automation>Sharing> Create estimate for |
Automation>Sharing> Create file for parent |
Event name |
On Open Sharing Dialog |
On_Before_Create_File_For_Parent |
Commonly associated verb |
|
|
Note |
Time to remove database of the estimate feature (not compatible with partial transparency), to post message ... |
In non-transparent mode, you can use is to populate the columns you want to return to the parent and avoid complex formulas |
For Analytical Reports:
Triggering button/menu |
View>Analytics>Create Data Source>Build Data Source |
View>Analytics>View Reports>Select Report |
Event name |
On_After_Create_Data_Source |
On_Before_Create_Analytic_Report |
Commonly associated verb |
Run_Macro |
Run_Macro |
Note |
Used to modify a source on the fly by API when it is created by clicking a button (not from a macro) or breakdown a metric over time (macro). See Planner with Sample_With_Planner |
Used at run-time to simplify too big data with a lot of pivot tables to save processing time and render only the data of interest. Refer to Code Samples |
When you get some data in a macro associated with an On_Before_xxx event and have to process it in a macro associated with an On_After_xxx event, call the macro named Shared data for inter-macro communication' ; it is available in the Multi-languages sample. It works like a clipboard.
Encoding
The first tab in the dialog box lists out all the predefined events. The events which an action is associated to appear in bold typeface.
To compose the code, tap by double-clicking various tabs' items:
▪Macros: the tab lists out all the created requests and macros proper (they differ in the pictogram); insert them as strings of chars in the first argument of the verb Run_ corresponding to their species
▪Conditions, as in Requests
▪Verbs
▪Variables, as in Requests.
To read the code executed after an event, select the event name in the first tab.
Verbs
A verb invokes requests, macros or methods.
Some verbs require arguments.
Set_Macro_Button is used to create buttons in a special group called Macro Buttons. It is usually put in the event On Open Estimate. The arguments are as follows:
▪<Number> position in Macro buttons (1 ... 10); if it is used two times, the latest overwrites the preceding one; default value: 1
▪<Visible: boolean>; default value: 1
▪<Name: caption in Macro buttons>; default value: blank; to handle several languages, refer to Multilingualism
▪<Tooltip>; default value: blank; to handle several languages, refer to Multilingualism
▪<Full path to png image> between double quotes, where ..\ refers to the installation folder; QDV7 comes with three pictures (generic picture overlaid with warning, script and Excel pictograms) in ..\Samples\Stuff_4_Macros\; if the path is missing, the overlay is the position number ("0" for 10); to use a custom image, embed it in the estimate thru Data>Insert files, and enter "<INTERNAL>filename with extension"
▪<Size>: 0 means 48x48 px, 1=thumbnail without caption, 2=thumbnail with caption; default value: 0
The code associated to a button MUST be put in the event "On Macro Button <Number>". Due to this matching, the maximum count of buttons is 10.
You can include this verb in the code invoked by the On_After_Apply_User_Profile event so that the button and function be adapted to the profile (refer to Global Variables):
Other verbs:
▪Run_ExcelMacro(<Excel Macro Name>, <Is Hosted in Estimate?>. Default: Run_ExcelMacro("", 0)
▪Run_Macro("<Macro Name>"); if the macro is not stored in the estimate or the management database, specify the full path (that can include the variables <USER_NAME>, <PROFILE_PATH>,<TEMP_PATH>,<DESKTOP_PATH>, <MY_DOCUMENTS_PATH>, <INSTALL_PATH>, <INTERNAL> if inserted thru Data>Insert files)
▪Run_Request("<Macro Name>", <UseWBS>, <UseDatabaseOfEstimate>, <UseOverheadMinute>). Default: Run_Request("", 1, 0, 0)
▪Refresh_Current_View()
▪Check_And_Repaint_All() used to check and repaint all the estimate
▪Activate_Tab(x) where x = 0 for Expanded WBS, 1 for Condensed WBS, 2 for Minutes, 3 for Nomenclatures, 4 for Overhead, 5 for Planner. Used to force the activation of a tab after an estimate is fully loaded (e.g. with On_Estimate_After_Read_Management)
▪Set_Value_To_Minute_Column(<Column ID>, <Value>) and Set_Value_To_WBS_Column(<ID of Column>, <Value>, <Also_Branches?>) force all the values in the column to the specified value; if the last attribute equals 0, the verb does NOT apply to the WBS branches
▪Copy_WBS_Column_Values(<Source Column ID>, <Target Column ID>, <0=Don't copy to branches, 1=Copy to branches at top, 2=Copy to branches at bottom>) used to calculate what is yet to invoice the branch totals can be empty or above/below the tasks)
▪Remove_Rows_With_No_Selling_Price used to keep only rows with selling prices, e.g., to build the invoice of a IDIQ-contract (make sure the selling prices are computed beforehand)
▪Remove_Total_Mode_Everywhere() used to take away Total Mode; invoke Check_And_Repaint_All afterwards, except if you push a progress or a version
▪Remove_All_WBS_Links(<0 = empty slave tasks, 1 = copy contents of master tasks>); refer to Links Between Tasks; if it is called from QDV7 while the estimate is open, repaint the WBS with the CheckAndRepaint() verb
▪Remove_All_Links_From_Db_Of_Estimate(<1=Remove db of estimate, 0= Keep db of estimate>, <1=Show error messages, 0=Don't show error messages>): isolates the estimate from the Database of the Estimate
▪Make_Groups_Sets used to turn groups into sets in order to adapt all underlying rows, when you change a quantity in the header of a group, e.g., to build an invoice of a IDIQ-contract; use its argument Keep Sets Definitions to avoid dismantling sets:
1: all sets underlying a group are dismantled
0: all sets underlying a group are erased before the group is converted into a set
▪Set_WBS_Column_Visible_Mode(<Column ID>, <Visible in Estimate>, <Visible in Progress>) defines if a WBS column is visible in estimate mode or/and in progress statements (check boxes described in Free Fields); 0 (hide) or 1 (show); WBS is repainted each time you push a progress: if you want your changes to be reflected before you push a progress, invoke the CheckAndRepaint_All() verb
▪Set_Minute_Column_Visible_Mode(<Column ID>, <Visible in Estimate>, <Visible in Progress>) defines if a Minute column is visible in estimate mode or/and in progress statements (attributes in the column manager) where 0 = hide, 1 = show; this alters the attribute described in How to Create Free Columns with Custom Behavior or How to Create Specific Set of Columns with Custom Behavior- MT/WF
▪Set_WBS_Column_Copy_To_Quantity(Column ID, Set Copy To Quantity flag?) used to paste the values of a WBS free column to WBS_Quantity column in the Minutes view when running progress statements; the flag Return value to Quantity column is described in How to Compare Several Versions (WBS)
▪Set_Use_Target_Value_Flag(<1=use Target to equal totals on calculation, 0= ignore the target if any>)
▪Compute_All(<Force Computation>, <Synchronize with management>), usually put at the request end, replaces the icon in the right lower corner, but features boolean arguments; without exiting the editor, the #N/A marks disappear from the WBS and the Minutes view
▪Refresh_Variables_And_Layout() refreshes global variables and column layout (after applying the Compute_All verb, they may be out-of-date)
▪Compute_Costs_Only(): as preceding item
▪Change_Calculation_Mode(<Mode>, <Use of latest factors>)
▪Mode: Overhead only (0), Overhead + Factors (1), Fixed Factors (2), Calculated Factors (3)
▪Use: Overwrite factors (0), Restore factors and formulas (1), Restore only formulas (2)
▪Force_Selling_Prices(): Force prices at WBS level (0), Force incidences at WBS level (1), Force prices at minute level (row based) (2), Force prices at minute level (group based) (3)
▪Cancel_Operation(): this stops the processing; the subsequent statements are not executed
▪Get_Error_Message(): this shows the returned error message (in the UI language)
▪Get_Error_Number(): this shows the returned error number (it is more understandable than the preceding one in an international environment); the list of error codes shows in the topic on the macro API
▪Display_Message(<Message>, <Icon>) Icon number: see table below; a specific sound is heard
Icon number |
0 |
1 |
2 |
3 |
Other |
Value |
Information |
Warning |
Stop |
Question |
Other |
Pictogram in the message |
nil |
METHOD
The show method can be applied to the MessageBox object; the arguments enable you to custom the window popping up on test and on execution.
Syntax: MessageBox.show("<Displayed Message>", "<Window Title>", MessageBoxButtons.OK, MessageBoxIcon.<Value>)
"OK" is the acknowledgment button caption.
The shown pictogram (and the heard sound) depend on the value as per the table above.
Put this line BEFORE the Run_.
NOTE <Column ID> can be either the mnemonic or the number that show in the Properties. It is sure that the number is unique.
To test an event code:
1.At any point, click Proceed; the list of events shows in a window
2.Select the event and click Test (alternative: double click)
3.In case of error, messages are posted; the debug pane is auto-filled; you can request to paste the native VB code in the clipboard; the button square turns magenta.
To receive right away the result of a test, insert the code that follows:
Get_Error_Message()
Cancel_Operation()
To create the button in the Automation bar, test the event, usually On Open Estimate.
To delete such a button, delete the invoked request if any.
To create the button in the Quick Access Toolbar, refer to Ribbon. There the button does not depend on the estimate.
NOTE A button that invokes a request where a window pops up executes this action even during a test.
Run-Time
To execute an event code to which a button is assigned by Set_Macro_Button, click once the button in the 'Macros buttons' group.