- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2022 01:31 AM
Hi all,
I have a record producer on which I want to show the assignment group the HR case will be assigned to.
SO I have a script include within which I am calling a function and then using a onchange client side script to call the script include and display the group in the item.
This is the code for the getAG function in the script include.
getAG: function(){
//var current = this.getParameter('sysparm_current');
gs.debug('HR AG');
var subjectPerson = this.getParameter('sysparm_req_for');
var prodID = this.getParameter('sysparm_prodID');
var contactType = 'Self Service';
//var source = '[producer.source]';
var AG = '';
var grHrService = new GlideRecord('sn_hr_core_service');
grHrService.get('producer', prodId);
var currentServiceTable = grHrService.getValue('service_table');
var currentTopicCategory = grHrService.topic_detail.topic_category.getDisplayValue();
var currentTopicDetail = grHrService.topic_detail.getDisplayValue();
var currentHRServiceName = grHrService.getDisplayValue('name');
var grSubjectPerson = new GlideRecord('sys_user');
grSubjectPerson.get(subjectPerson);
var currentLocation = grSubjectPerson.getValue('location');
var grCase = new GlideRecord(currentServiceTable);
grCase.setValue('hr_service', HrService);
grCase.setValue('contact_type', contactType);
grCase.setValue('source', source);
grCase.setValue('subject_person', subjectPerson);
grCase.setValue('location', currentLocation);
var grAssignmentRule = new GlideRecord('sysrule_assignment');
grAssignmentRule.addActiveQuery();
grAssignmentRule.addQuery('table', '=', currentServiceTable);
grAssignmentRule.orderBy('order');
grAssignmentRule.query();
var filter;
var found = false;
while ( grAssignmentRule.next() && found == false ) {
filter = grAssignmentRule.getValue('condition');
if ( filter == '' ) {
continue;
}
found = GlideFilter.checkRecord(grCase, filter, true);
if ( found ) {
gs.info('HR AG match: ' + grAssignmentRule.getDisplayValue('group'));
gs.log('HR AG match: ' + group);
AG = grAssignmentRule.group;
return AG;
}
}
if ( found == false) {
gs.info('HR AG: no match');
}},
and then this is the client script that is calling the script include function:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('sn_hr_core.HRCaseAccessRP');
ga.addParam('sysparm_name', 'getAG');
ga.addParam('sysparm_req_for', producer.requested_for);
ga.addParam('sysparm_prodID', g_form.getUniqueValue());
ga.getXMLAnswer(getResponse);
function getResponse(response){
var answer = JSON.parse(response);
g_form.addInfoMessage(answer.AG);
g_form.setValue('assignment_group', answer.AG);
}
//Type appropriate comment here, and begin script below
}
so the onchange client script works in the sense it displays the showfield message banner so the blue bit under the field. But there is no data or group shown in the field message. it is blank.
I have added some gs.logs within the script include function I am calling but they are not displaying in the logs at all.
So looks like script include is not being called.
The script include is in the HR core app scope and the client script is in the employee center core scope.
The script include caller access is set to none so that should not restrict and accessible from is all app scopes.
Can someone help me on this please.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2022 02:41 AM
Hi Khalnayak,
I suppose your code is failing at below highlighted lines as the variable defined is different one here, please make corrections.
Hope this helps.
If my answer resolves your issue, please mark my answer as ✅ Correct & Helpful based on the validations.
Thank You!
Regards,
Kailash
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2022 02:12 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2022 02:41 AM
Hi Khalnayak,
I suppose your code is failing at below highlighted lines as the variable defined is different one here, please make corrections.
Hope this helps.
If my answer resolves your issue, please mark my answer as ✅ Correct & Helpful based on the validations.
Thank You!
Regards,
Kailash
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2022 03:00 AM
Thank you
But issue is still same, nothing in logs too.
There is one log in the logs though related to my script include.
The source script is the script include I am using. This log is created every time I am trying to trigger it from the record producer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2022 05:52 AM
Hi Khalnayak,
Could you please create a record on table "sys_scope_privilege".
Please refer below screenshot for same. Application should be the scope you are trying to access script include from.
e.g. I'm trying to access Global scope SI from Task for Mobile scope.
Hope this helps.
If my answer resolves your issue, please mark my answer as ✅ Correct & Helpful based on the validations.
Thank You!
Regards,
Kailash
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2022 06:55 AM
Just one last thing left, the group I can see in the logs so the match is being found, but not showing in the field on client side.
in my client script I am using glideajax, and assigning the answer to the field, but I need to assign the value of AG which is within the answer? how do I do this please?