Using Glide script to update a field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-06-2012 10:35 AM
Hi -
I am trying to use a glide record to updated a field based on the selection from another field.
I have a table that has columns:
field1 field2
chair seat
table cloth
Below is that I have and it's not working: :-((
-------------------------------------------------------------
function onChange() {
var field1 = g_form.getValue('chair');
if(field1 == '') return false;
var FieldTable = new GlideRecord('table_name');
FieldTable.addQuery('field_name',field1);
FieldTable.query();
if(FieldTable.next()){
g_form.setValue('newfield',FieldTable.field2);
}
}
-------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2012 07:11 AM
also the - 'u_target_ndm_machine' - field is referencing the machine list to select a machine name.
-Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2012 01:10 PM
I updated my script to below but Iam still getting an error message when I update the target ndm machine field. I have attached the screen shots to this comment.
- Thanks.
---------------------------------------------
function onChange(control, oldValue, newValue, isLoading, isTemplate){
if (!isLoading){
var machine = g_form.getValue('u_target_ndm_machine');
if(machine == ''){ return false;
}
alert("machine: " + machine);
var targetMachine = new GlideRecord('u_machine_list');
targetMachine.get(machine);
alert("rowCount: " + targetMachine.getRowCount());
if(targetMachine.next()){
g_form.setValue('u_target_ndm_node',targetMachine.u_ndm_node_name);
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2012 06:22 AM
Can someone please help me with this? I tried the script suggested by cwilker10 above but i am still getting error message below:
------------------------------------------------------------------------------------------------------------------------------------------
onChange script error: [object Error]
function onChange_u_it_batch_job_documentation_u_target_ndm_machine_1(control, oldValue, newValue, isLoading, isTemplate){
if (!isLoading){var machine = g_form.getValue('u_target_ndm_machine');
if(machine == ''){ return false;}alert("machine: " + machine);
var targetMachine = new GlideRecord('u_machine_list');
targetMachine.get(machine); alert("rowCount: " + targetMachine.getRowCount());
if(targetMachine.next()){
g_form.setValue('u_target_ndm_node',targetMachine.u_ndm_node_name);}}}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2012 07:42 AM
I don't think client-side GlideRecord has a getRowCount() method. That part is throwing a JavaScript error. Try using the following instead:
alert("rowCount: " + targetMachine.rows.length);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2012 08:59 AM
Hi CapaJC -
The - alert("rowCount: " + targetMachine.rows.length); worked and I am not getting the error any longer 🙂
However, my field is still not populating with the value needed.
Thanks.