- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2024 10:39 AM
Hello Community,
I need an help on this issue with Script Include.
I have created a custom application and one of the requirements is that once a user enters or changes the Amount (Price) field then changes/update the Approver field based on the amount before save/submit the record.
I have been trying to update the Approver field by using Client Script and Script include so user see the Approver changes right away when they change the Amount. But the Script Includes return no data back to the Client Script.
Here are my codes:
Client Script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var requestorId = g_form.getValue('u_prepared');
var gaManager = new GlideAjax('customApp'); //Replaced with the actual Script Include name...
gaManager.addParam('sysparm_name', 'getManagerId');
gaManager.addParam('sysparm_requestorId', requestorId);
gaManager.getXMLAnswer(function(response){
alert(response);
});
}
Script Include
var CustomApp = Class.create();
CustomApp .prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getManagerId: function(){
var requestorId = this.getParameter('sysparm_requestorId');
var result = {};
var user = new GlideRecord('sys_user');
if(user.get(requestorId)){
result.manager = user.manager;
if(user.manager){
var manager = new GlideRecord('sys_user');
if(manager.get(user.manager)){
result.manager_manger = manager.manager;
if(manager.manager){
var manager_manager = new GlideRecord('sys_user');
if(manager_manager.get(manager.manager)){
result.manager_manager_manager = manager_manager.manager;
}
}
}
}
}
return JSON.stringify(result);
},
type: 'CustomoApp'
});
When the user changes the Amount, alert gives me this
{
"manager": {},
"manager_manger": {},
"manager_manager_manager": {}
}
At this point, I am not sure why I all the values are null.
Please help!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2024 10:48 AM
Hi @jyeon110 can you please try updating you script include using getValue('manager'): to Retrieves the sys_id of the manage.
…………………………………………........................................................................................
Mark it helpful 👍and Accept Solution ✅!! If this helps you to understand.
…………………………………………........................................................................................
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2024 10:48 AM
Hi @jyeon110 can you please try updating you script include using getValue('manager'): to Retrieves the sys_id of the manage.
…………………………………………........................................................................................
Mark it helpful 👍and Accept Solution ✅!! If this helps you to understand.
…………………………………………........................................................................................
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2024 11:04 AM
oh man, thanks for the help!! It works
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2024 11:13 AM
@jyeon110 Great!! Happy to help.
please mark the response as helpful and accept the solution if it helped you!