Display info message on field that how many leave balance they have for that selected type?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2024 09:57 PM
Hi All,
Actually we have record producer to submit a leave request , in that there is field "Leave category"(casual, annual, sick leave), so my requirement was like whenever user select leave type there need display info message on field that how many leave balance they have for that particular selected type
Please help me to achieve this
Thanks
Deepika
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2024 09:23 PM - edited 02-21-2024 09:24 PM
Hi @Deepika61,
Let's try printing some logs to identify where it's going wrong.
var leavebalanceinfo = Class.create();
leavebalanceinfo.prototype = Object.extendsObject(AbstractAjaxProcessor, {
leaveinfo: function () {
var type = this.getParameter('sysparm_type');
gs.info("Type of leave is " + type);
var user = this.getParameter('sysparm_user');
gs.info("User is " + user);
var leave = new GlideRecord('u_yearly_leave');
leave.addQuery('u_leave_type', type);
leave.addQuery('assigned_to', user);
leave.query();
gs.info("Query is " + leave.getEncodedQuery());
if (leave.next()) {
gs.info("Found leave record " + leave.getDisplayValue());
gs.info("User's remaining balance is " + leave.getValue('u_remaining_leave_days'));
return leave.getValue('u_remaining_leave_days');
}
gs.info("No record found");
},
type: 'leavebalanceinfo'
});
Update your script include similar to the above and see where the issue is coming from.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 12:27 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 01:35 AM
Right, so looks like you are using a reference for the type field. You might want to change that to another variable type but be cautious as it can impact other processes.
In regards to the user, you should use the below in your client script
var userId = g_form.getValue('requested_for');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 01:38 AM
I have used this also , then its also getting sys_id instead of value , now both type and user displaying sys_id ,but i need display value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 10:31 AM
You should be getting a sys_id for the name field and a string/text for the type field. So you should change the 'type' variable type to a non-reference field.
