- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
18m ago
When you access the menu item named “Scripted Extension Points”
The following item is provided out of the box:
sn_pw.preSaveHandelrExtension
The description provided for this item is :
“This extension invokes from the ProjectWorkspaceSaveApi script include. Write an implementation to modify or validate the project workspace updates.”
From the screen above, when you choose to “Create Implementation” a new Script Include is created
The SI has 4 items passed to it
- Data
- Columns
- baseTable
- topTask
To examine the content of these 4 items, add the following logging to the SI
gs.info("Value for Basetable is :" + baseTable);
gs.info("Value for topTask is :" + topTask);
gs.info("Content of DATA is :" +JSON.stringify(data));
gs.info("Content of COLUMN is :" +JSON.stringify(columns));
By doing this, when a task is added or updated in the Project Workspace Gantt console, the following entries can be seen in the System Log:
- The parent table of the record being edited– pm_project
- The SysId of the project
- The data being edited by the user. Here we get 1 entry for the task that the user is editing and 1 entry for the project (summary task)
- The columns present
Usage Example
Scenario : we want to force the user to select a value in a specific column on the Workspace before a task can be saved
The field in question is a String value with a default value (Select) and 3 additional values (A, B, C)
In this scenario we want to prevent the user from saving the task with the value of ‘Select’
This sample SI was created to address the requirement
var alm2_preSaveHandelrExtension = Class.create();
alm2_preSaveHandelrExtension.prototype = {
initialize: function() {},
process: function(data, columns, baseTable, topTask) {
gs.info("Basetable is :" + baseTable);
gs.info("topTask is :" + topTask);
gs.info("DATA SOURCE is :" +JSON.stringify(data));
gs.info("COLUMN SOURCE is :" +JSON.stringify(columns));
var tasks = data.tasks || [];
for (var i = 0; i < tasks.length; i++) {
var task = tasks[i];
gs.info("This is the Value of the Category Field"+ task.u_ac.value);
if ((task.u_ac.value == 'Select' || task.u_ac.value=='') && task.parent!=null) {
gs.info("Blocked field edit: ");
return {
data: data,
status: 'error',
message: 'A value for "Category" is required for: ' +task.short_description.displayValue+ '. Please refresh the page and try again'
};
}
else{
return {
data: data,
status: 'success', //success or error
message: '', //if status is error then return the error message also
};
}
}
type: 'alm2_preSaveHandelrExtension'
}
};
When this SI is active, the following will be the outcome when a user creates a task but does not set a value in the column we want to be filled
To correct this situation the user should refresh the page and add the task once more with the correct values selected.