- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2023 06:22 AM
Hi,
I am trying to write an onSubmit Client Script so that when a field value is changed and the form is submitted, a confirm alert is returned which will state 'Expected Closure Date has changed. Approval must be attached once this has been updated.'
The script I have so far is below:
function onSubmit() {
var u_risk_close_date=g_form.getValue('u_risk_close_date');
if(u_risk_close_date.modified){
return confirm("Expected Closure Date has changed. Approval must be attached once this has been updated.");
}
}
Many thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2023 06:56 AM
Hi @NathanHaywood ,
Please try below on submit client script
function onSubmit() {
var risk_close_date = g_form.getControl('u_risk_close_date'); //Get the field control
//See if the 'changed' attribute on field is true
if(risk_close_date.changed){
return confirm("Expected Closure Date has changed. Approval must be attached once this has been updated");
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2023 06:56 AM
Hi @NathanHaywood ,
Please try below on submit client script
function onSubmit() {
var risk_close_date = g_form.getControl('u_risk_close_date'); //Get the field control
//See if the 'changed' attribute on field is true
if(risk_close_date.changed){
return confirm("Expected Closure Date has changed. Approval must be attached once this has been updated");
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2023 07:12 AM
Hello @Manmohan K
Thank you for your reply.
I have made the changes but when going back to the form and amending the u_risk_close_date field, I get this error in red at the top of the page:
Error MessageonSubmit script error: TypeError: g_form.Control is not a function:
function () { [native code] }
I have copied your script exactly, see below:
function onSubmit() {
var u_risk_close_date = g_form.Control('u_risk_close_date'); //Get the field control
//See if the 'changed' attribute of field is true
if(u_risk_close_date.changed){
return confirm("Expected Closure Date has changed. Approval must be attached once this has been updated.");
}
}
Thanks again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2023 07:15 AM - edited 06-02-2023 07:16 AM
Correct this line,
var risk_close_date = g_form.getControl('u_risk_close_date'); //Get the field control
You wrote var u_risk_close_date = g_form.Control('u_risk_close_date'); //missing get before control
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2023 07:25 AM
Ah, I wasn't paying enough attention clearly. Thank @Manmohan K that's done it!