- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2024 06:06 AM
have shared u the screenshot please check.
Here the problem is in security group table - I have filled security group name with the help sys_user_group, and owner from sys_user table. I have given some value to both. for example after the form is submitted I have deleted the user in that form. In catalog item if i selected the security name the owner should auto populate. So, if I use same security name then the owner is showing empty but I unable to show error message the form is submitting automatically. So, I got to know later the sys_id is present but the user got deleted with the help of alert and getValue i found it.
This scenario is I am facing in my DEV environment in my project. Can u please guide me how to remove that sy_id if value is empty.
Please help me and explain in detail.
In a table records the user is deleted
ex- security table
application name - reference - sys_group
owner - reference - sys_user -mandatory- here after record is submitted.
the user is deleted in table for some of application name. So, in that place empty field owner sys-id is coming so I unable to show error message on submit client script if owner is empty because of sys id the form is submitting.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2024 07:22 AM
What happens if you replace '.getValue' with '.getDisplayValue'? Value of a reference field is the sysID, so I guess you need that.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2024 09:55 AM
I used this code. But my problem with the owner name is not empty showing after I autopopulated but sys_id is coming in that area. I got know with the help of
var owner = g_form.getValue('owner_name');
alert(owner);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2024 07:26 AM
Hello @Mahesho11 ,
Please give a try to the script below and see how it works for you.
function onSubmit() {
// Type appropriate comment here, and begin script below
var owner_a = g_form.getDisplayValue('owner_name');
// Check if owner_a is empty or undefined
if (!owner_a) {
g_form.addErrorMessage('Owner field cannot be empty');
return false; // Prevent form submission
}
// Additional check to ensure sys_id is not empty
var owner_sys_id = g_form.getValue('owner');
if (!owner_sys_id) {
g_form.addErrorMessage('Owner sys_id is empty. Please select a valid owner.');
return false; // Prevent form submission
}
// Continue with form submission if all checks pass
return true;
}
Let me know your views on this and Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks,
Aniket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2024 09:52 AM
I used this code. But my problem is with the owner name is empty but sys_id is coming in that area. I got know with the help of
var owner = g_form.getValue('owner_name');
alert(owner);