- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2024 10:57 AM - edited ‎02-20-2024 11:00 AM
Hello @all,
I have a requirement to get the list of rejected cases - so for this I have created a new field(Case has been rejected=true) and created a business rule to update the rejected status. But I want the list of rejected HR Case numbers for old cases also.
How the case can be rejected -> we can identify this -> when a state changes from 'awaiting acceptence' to 'work in progress'.
So please help me to get the solution for this to get the list of rejected cases.
Below is the UI Action we are using for rejection -> when a user clicks on Reject Completion -> A dialog will appear -> by providing a reason in dialog box -> a user can reject the case.
function rejectCompletion() {
if (g_form.getValue('state') == 20) {
//if state has not changed
var sysId = typeof rowSysId == 'undefined' || rowSysId == null ?
g_form.getUniqueValue() : rowSysId;
var dialogClass = GlideModal ? GlideModal : GlideDialogWindow;
var dialog = new dialogClass('sn_hr_core_HR Comment Dialog');
var msg = new GwtMessage().getMessage('Provide a reason for reject completion');
dialog.setTitle(msg);
dialog.setPreference('sysparm_task_sys_id', sysId);
dialog.setPreference('sysparm_task_table', 'sn_hr_core_case');
dialog.setPreference('sysparm_ok_method_name', 'rejectCompletion');
dialog.setPreference('sysparm_is_comment', 'true');
dialog.on('hrComentDialogSucess', function() {
//g_form.setValue('u_case_has_been_rejected', true);
dialog.destroy();
gsftSubmit(null, g_form.getFormElement(), 'sysverb_update_and_stay');
});
dialog.render();
return;
} else {
//if state has changed show error message
g_form.addErrorMessage(getMessage("The state of the case has been updated recently. Please refresh the page."));
}
}​
Kindly help me with your suggestions - @Rob Sestito @Eswar Chappa @Ankur Bawiskar
Thank you in advance.
kind regards
bhuvana
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-21-2024 02:12 AM - edited ‎02-21-2024 02:13 AM
@bhuvana7, I have made some modifications to the script. Could you please check the changes?
Additionally, I would like to ask that you run the "fix script" within the HR Core scope to ensure that HR cases are accessible.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2024 07:32 PM - edited ‎02-20-2024 07:35 PM
Typically, for cases that have been rejected, updates are done in the comments section, making it challenging to retrieve specific data. However, utilizing the audit trail allows us to access the most recently rejected cases. To do so, please visit the following link:
This link grants access to the history of state changes, enabling us to identify and review recent rejections based on the historical data your instance retains. The field set within will provide information about which record has been rejected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2024 09:56 PM - edited ‎02-20-2024 11:10 PM
Thank you @Srinivasa1 ,
It helped me, but can you help with the script for this?
Below is the history I can see - I can see the HR Case number, so based on this I need to update a new rejected field with true value in the HR Case Table.
Somehow, I tried below script, but it is going out to else condition - working till 'gs.info('test');'
var gr = new GlideRecord('sys_history_line');
gr.addQuery('label=State^old=Awaiting Acceptance^new=Work in Progress');
gr.query();
while (gr.next()) {
var historyId = gr.getDisplayValue('set');
gs.info('history id:' +historyId);
var hrCaseGr = new GlideRecord('sn_hr_core_case');
hrCaseGr.addQuery('number', historyId);
hrCaseGr.query();
gs.info('test');
if (hrCaseGr.next()) {
gs.info('test1');
hrCaseGr.setValue('rejected_field', true);
hrCaseGr.update();
gs.info('HR Case Updated - Rejected: ' + hrCaseGr.getValue('case_number'));
} else {
gs.error('HR Case Not Found for History ID: ' + historyId);
}
}
Kindly help me with the script, I will be thankful.
@Srinivasa1 @Rob Sestito @Eswar Chappa @Ankur Bawiskar @
Kind Regards
Bhuvana
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-21-2024 02:12 AM - edited ‎02-21-2024 02:13 AM
@bhuvana7, I have made some modifications to the script. Could you please check the changes?
Additionally, I would like to ask that you run the "fix script" within the HR Core scope to ensure that HR cases are accessible.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-21-2024 04:29 AM
Hi @Srinivasa1 ,
Thank you for your support on this issue, it is working and I executed it in 'fix script'.
Kind Regards,
Bhuvana