- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2020 11:12 AM
Hi,
I have written the onChange client script on "time_machine_name" variable to add and remove the option from the select box variable.
script:
function onChange(control, oldValue, newValue, isLoading) {
// if (isLoading || newValue == '') {
// return;
// }
var tmName = g_form.getDisplayBox('time_machine_name').value;
var addDB = g_form.getReference('tmName', addOptionInDBType);
function addOptionInDBType(addDB) {
alert('inside function');
if (addDB.type == 'oracle_database')
alert('insideif'+addDB.type);
g_form.addOption('databaseType', 'oracle_database_clone', 'Oracle');
g_form.removeOption('databaseType', 'saphana_database_clone');
g_form.removeOption('databaseType', 'sqlserver_database_clone');
g_form.removeOption('databaseType', 'postgres_database_clone');
g_form.removeOption('databaseType', 'mysql_database_clone');
g_form.removeOption('databaseType', 'mariadb_database_clone');
}
}
Could you please help me where i am doing wrong?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2020 02:37 AM
Hi Anu,
Is time_machine_name a reference field?
If so, you need to use below.
var addDB = g_form.getReference('time_machine_name', addOptionInDBType);
instead of
var addDB = g_form.getReference('tmName', addOptionInDBType);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2020 11:15 AM
getReference won't work in scoped app.you can use script include to get the details.
Example
Script Include
var HelloWorld = Class.create(); HelloWorld.prototype = Object.extendsObject(AbstractAjaxProcessor, { helloWorld:function() { return "Hello " + this.getParameter('sysparm_user_name') + "!"; } , _privateFunction: function() { // this function is not client callable } });
Client Script
var ga = new GlideAjax('HelloWorld');
ga.addParam('sysparm_name', 'helloWorld');
ga.addParam('sysparm_user_name', "Bob");
ga.getXML(HelloWorldParse);
function HelloWorldParse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer); }
Regards
Pranav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2020 11:27 AM
Hi,
Can you try changing:
var tmName = g_form.getDisplayBox('time_machine_name').value;
var addDB = g_form.getReference('tmName', addOptionInDBType);
to
var addDB = g_form.getReference('time_machine_name', addOptionInDBType);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2020 02:34 AM
Could you please help me to do this.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2020 02:37 AM
Hi Anu,
Is time_machine_name a reference field?
If so, you need to use below.
var addDB = g_form.getReference('time_machine_name', addOptionInDBType);
instead of
var addDB = g_form.getReference('tmName', addOptionInDBType);