want to do Work notemandatory within a PTASK when Due date & Follow up date are updated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 07:13 PM
Hi can anyone help me with the code for making the work notes mandatory when due date and follow up date is updated in p task form.
When a user inserts a value within the "Due date' and "Follow up date" field of a PTASK, on save or update of the form, make "Work notes" field mandatory
Throw out a message that reads:
"Work notes field requires a values to save the form"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 07:36 PM
Hi raj
I would checkout the UI policy route for this, you could do something like
When Due Date Changes AND follow up date changes make work notes mandatory
within the scripting section you can add you g_form.addInfoMessage (“”)
cyevk out this link on UI policies https://sn.jace.pro/getting-started/UI_Policies/
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response helped in any way
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 07:39 PM
i cannot see changes in the ui policy when i select due date field, it is showing everything else like
between, trends, is less than, is greater than etc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 08:43 PM
My apologies, you are correct I also don't see changes() as an option for filtering date fields.
Plan B would be client scripts, and if 2 fields are involved you will need on change client scripts for each field. and could use !g_form.isNewRecord() to ensure the script only runs for updates.
You could also use 1 before update BR and abort the update but this could result in data loss\rework and client script(s) to set the work_notes field mandatory before save would be a better end user experience.
Exactly what depends on your requirement, but maybe something like
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
//may need to tweak this condition if you need to make work_notes mandatory when field is empty
if (isLoading || newValue === '') {
return;
}
//we can assume the focus field has changed otherwise the script wouldn't be running
//so no need to validate again
if (!g_form.isNewRecord()) {
//do you need to check another field if yes wrap setMandatory method in another condition
var check2 = g_form.getValue('anotherField');
if (check2 == 'something') {
g_form.addInfoMessage('testing works');
g_form.setMandatory('work_notes', true);
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 07:58 PM - edited 07-26-2023 07:59 PM
Hi you need to have 2 onchange client scripts on due date field and follow up field, sample below for due date field. Create another script for follow up field
script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var getDueDate = g_form.getValue('due_date');
if(getDueDate != oldValue)
{
alert("worknotes Mandatory");
g_form.setMandatory('work_notes',true);
}
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 08:04 PM
this is not working for new records