- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2019 11:09 PM
Referring to a thread i tried g_form.getDisplayBox('field_name').value;
but it didn't work in onChange Cs whereas in onLoad it worked for some field, not for all.
getValue() -- gives you the value not the name.
getDisplayValue() is not recommended for client side So,
can anyone give me example for both onload and onchange cs , how to get the value of reference/choice field and display in an alert for testing purpose?
no need to use if condition just simply get the the value and display in alert.
Thank You.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2019 03:02 AM
Hello PP,
Missed your previous reply, my bad.
Ok Let me share you a client script and a script include with the same what you wanted to do
Based on your script include code what you are doing is exactly correct. just you need to add a couple of additional parameters to pass the values from the client script to your script include so that it can process and give you back the results
Client Script:
function onLoad(){
var ga = new GlideAjax('clientsidecall');
ga.addParam('sysparm_name','Getvalue');
ga.addParam('sysparm_asg_grp',g_form.getValue('assignment_group');
ga.addParam('sysparm_asg_to',g_form.getValue('assigned_to;);
ga.getXML(val1);
function val1(response){
var answer = response.responseXML.documentElement.getAttribute('answer');
alert(answer);
}
}
Client Script :
var ClientsideCall = Class.create();
ClientsideCall.prototype = Object.extendsObject(AbstractAjaxProcessor, {
Getvalue : function(){
var at = this.getParameter('sysparm_asg_to');
var asg_group = this.getParameter('sysparm_asg_grp');
return at+","+asg_group;
},
type: 'ClientsideCall'
});
Hope that helps
For passing multiple values back to the client script from script include you can also use JSON but the thing you are looking for should work with what i have provided above
Mark this response as correct if that really helps
Thanks,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2019 01:52 AM
Thank you for the response! it was really helpful.
but can you please write the script for this scenario for me just for my understanding and reference.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2019 03:02 AM
Hello PP,
Missed your previous reply, my bad.
Ok Let me share you a client script and a script include with the same what you wanted to do
Based on your script include code what you are doing is exactly correct. just you need to add a couple of additional parameters to pass the values from the client script to your script include so that it can process and give you back the results
Client Script:
function onLoad(){
var ga = new GlideAjax('clientsidecall');
ga.addParam('sysparm_name','Getvalue');
ga.addParam('sysparm_asg_grp',g_form.getValue('assignment_group');
ga.addParam('sysparm_asg_to',g_form.getValue('assigned_to;);
ga.getXML(val1);
function val1(response){
var answer = response.responseXML.documentElement.getAttribute('answer');
alert(answer);
}
}
Client Script :
var ClientsideCall = Class.create();
ClientsideCall.prototype = Object.extendsObject(AbstractAjaxProcessor, {
Getvalue : function(){
var at = this.getParameter('sysparm_asg_to');
var asg_group = this.getParameter('sysparm_asg_grp');
return at+","+asg_group;
},
type: 'ClientsideCall'
});
Hope that helps
For passing multiple values back to the client script from script include you can also use JSON but the thing you are looking for should work with what i have provided above
Mark this response as correct if that really helps
Thanks,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2019 12:21 AM
yeah thanks its working ..... 🙂
can you give me an example of JSON as well, i want to learn how it works
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2019 01:23 AM
Hi - one help
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if( isLoading ){
return;
}
var gr=g_form.getReference('u_assigned_to',callBack);
function callBack(gr){
g_form.setValue('u_assignment_group',gr.group);// what will be the syntax for setvalue of assignment group?i tried gr.group but its not working.--
but when i am trying g_form.setValue('u_assignment_group',"Database");// its working.
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2019 11:45 PM
Hi PP,
Try with this below links:-
Let me know if you have any questions.
Please mark it Correct or Helpful, if it works based on impact....!!!!
Warm Regards,
Priyanka