Unable to show error message

Mahesho11
Tera Contributor

 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. 

Screenshot 2024-01-21 004923.pngScreenshot 2024-01-21 005053.pngScreenshot 2024-01-21 005404.png

2 ACCEPTED SOLUTIONS

Aniket Chavan
Tera Sage
Tera Sage

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

 

View solution in original post

I would try this:

- make sure the Catalog Client Script is not active.

- modify the Auto-populate configuration so that field Dot walk path points not to Owner, but Owner.Sys ID.

 

In such a configuration the system should not be able to fill in any value because ti will not be possible to get the Sys ID of an Owner that that does not actually exist.

In such a configuration your original script should work (and should display nothing when alert-ing the contents of field Owner name)

View solution in original post

11 REPLIES 11

I would try this:

- make sure the Catalog Client Script is not active.

- modify the Auto-populate configuration so that field Dot walk path points not to Owner, but Owner.Sys ID.

 

In such a configuration the system should not be able to fill in any value because ti will not be possible to get the Sys ID of an Owner that that does not actually exist.

In such a configuration your original script should work (and should display nothing when alert-ing the contents of field Owner name)

Mahesho11
Tera Contributor

Mahesho11_2-1705884141697.png

 

Even I have used getReference method also 

function onChange(control, oldValue, newValue, isLoading) {
  if (newValue == '') {
    return;
  }

  var user = g_form.getReference("security_group", populateManager);//confirm your field name
}

function populateManager(user) {
  g_form.setValue("owner_name", user.owner_name);//confirm your field name and referenced table field name
}  

 Later I also seen in the table of security group that i run a filter condition 

owner_name is empty then it is not showing any value there. and in user table with the empty field sys_id I searched in user table there I cant seen any user there. and in security table the form is mandatory for owner and in form is empty. I have used the correct getreference just for example i am showing this code.