Auto populate Project number in parent field on New Project Task form while click on Add card in VTB
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 06:32 AM
Hi All,
I have a requirement to Auto populate Project number in parent field on New Project Task form while clicking on Add card in Visual Task Board.
When Project Task is manually created from Project using New UI action, the parent (project number) is populated. However, on VTB it isn't working.
Thanks in Advance
1 REPLY 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2023 11:53 PM
You will need to thoroughly test this on your Project Tasks VTBs and the back-end forms to ensure there's no adverse effects. It's Friday arvo' so I've only done limited testing.
On the pm_project_task table create an onLoad Client Script.
Untick Isolate script.
function onLoad() {
try {
if (window.location.toString().indexOf('vtb.do')) {
var elements = window.document.getElementsByName("sysparm_referring_url");
//you *will* need to add more code here to help ensure you have the correct element
var e = elements[1].value;
var id = e.substring(e.indexOf('sub_tree_root%3D') + 16, e.indexOf('sub_tree_root%3D') + 16 + 32);
if (g_form.getValue('parent') == '' && g_form.isNewRecord()) {
g_form.setValue('parent', id);
}
}
} catch (e) {
console.log('ERROR in Client Script Test populate parent\n' + e);
}
}