- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2022 06:18 AM
Hi,
i have two fields the first is a reference on a table , i should once the user select the name in the field Application (1) the second field Refernence cde (2) will be filled automatically by assignment group concerning the name
this the table :
once user select in the field application "name" the filed reference cde should be fill with the assignment group of this name("test");
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2022 06:29 AM
On the form you can do it like below
Add an oncchange client script that runs on change of Application field
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ref = g_form.getReference('<application field name>', getAppl);
}
function getAppl(ref) {
g_form.setValue('<Reference code field name>', ref.<name of field on referenced table>);
}
}
If you want to do it on the list then you have to create a Business Rule.
Condition: <reference code field > is empty
AND
Application changes
Before
Update
Script:
current.<reference code field> = current.<application field>.<reference code field>;
-Anurag
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2022 06:58 AM
I just tried I don't think you can get the value as you want
You an either look into converting this into a glide ajax call, or maybe change reference code to into reference field, pointing to group table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2022 07:12 AM
hi
i tried to use client script and script include but i get null i don't know why
client script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax('SampleUtil');
ga.addParam('sysparm_name','name');
ga.addParam('sysparm_value',newValue);
ga.getXML(getname);
function getname(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
g_form.setValue('u_groupe_d_affectation_bte',answer);
}
}
script include:
var SampleUtil = Class.create();
SampleUtil.prototype = Object.extendsObject(AbstractAjaxProcessor, {
name: function(){
var y= this.getParameter('sysparm_value');
var gr= new GlideRecord('u_applications_bte');
gr.get(y);
gr.query();
while(gr.next()) {
return gr.u_assignement_group_b;
}
},
type: 'SampleUtil'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2022 07:39 AM
Use this script include
var SampleUtil = Class.create();
SampleUtil.prototype = Object.extendsObject(AbstractAjaxProcessor, {
name: function(){
var y= this.getParameter('sysparm_value');
gs.log('passed value = '+ y.toString());
var gr= new GlideRecord('u_applications_bte');
gr.get(y.toString());
return gr.u_assignement_group_b.getDisplayValue();
},
type: 'SampleUtil'
});
if it still doesn't work then check the log to see what value you are getting for Y
-Anurag
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2022 08:08 AM
still don't working o got null when i log i get different sys_id dirffrent to group
gs.log("test1");//work
var y= this.getParameter('sysparm_value');
gs.log("test2");//work
gs.log('test3'+ y.toString()); //i got "345278be71b9909105a26a822604bcb12"
var gr= new GlideRecord('u_applications_bte');
gr.get(y.toString());
gs.log('test4'+ y.toString());// i got "445278be71b9909105a26a822604bcb12"
return gr.u_assignement_group_b.getDisplayValue();
},
the sys_id of the group that i should get is "2064c0b937fabe00449c138943990e74"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2022 08:31 AM
in the background script
run this
var gr= new GlideRecord('u_applications_bte');
gr.get('<sys_id you expecting>'); //2064c0b937fabe00449c138943990e74 but double check
gs.print(gr.u_assignement_group_b.getDisplayValue());