- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2024 02:06 AM
Hello Developers,
I wanted to make few fields mandatory while closing the stask.
I used below script & it is working fine.
But I also want to add few things like, If user is in a different view where these fields are not visible on form then these should not be mandatory.
Do we have any line of code which check, If these fields are on the form?
If yes, then fill them(mandatory)
If No, ignore (non-mandatory)
function onSubmit() {
//Type appropriate comment here, and begin script below
var state = g_form.getValue('state');
var solution = g_form.getValue('u_solution');
var assign = g_form.getValue('assigned_to');
if ((state == 3 || state == 10) && (solution == '')) {
g_form.showFieldMsg('u_solution', 'Please fill solution before closing the Task', 'error');
// alert('Please fill solution field before closing the Task');
return false;
}
if ((state == 3 || state == 10) && assign == '') {
g_form.showFieldMsg('assigned_to', 'Please fill Assigned to before closing the Task', 'error');
return false;
}
}
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2024 02:35 AM
You can use the below like to check if the field is present on the form(current view)
g_form.hasField('<your field name>') //returns true fi field is present, false if it is not
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2024 02:35 AM
You can use the below like to check if the field is present on the form(current view)
g_form.hasField('<your field name>') //returns true fi field is present, false if it is not
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2024 03:20 AM
@Naveen87 did you see this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2024 03:59 AM
Oh yeah.
Looks like this worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2024 03:59 AM
Thank you.
I have another question if you can suggest.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2024 03:40 AM
I tried this but did not work.