
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-21-2019 12:25 AM
Hi guys,
I need an help for configuring the Advanced Reference Qualifier in the right way.
In the Time Worker table, I've created a Reference custom field "Account_ref" to the customer_account table.
I would like to fill this field automatically with the account of the selected task, I tried dding with the following Advanced Reference Qualifier...no luck.
javascript:'account='+current.task;
Thanks for your help!!!
Solved! Go to Solution.
- Labels:
-
Best Practices
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2019 12:27 AM
Hi Alberto,
I replicated your config and figured out the issue, real rookie error for which i accept full responsibility 🙂
The function call in the getXMLAnswer() line is in quotes, it shouldn't be! use this:
//client script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax('TestScriptInclude');
ga.addParam('sysparm_name', 'testFunction');
ga.addParam('sysparm_task', g_form.getValue('task'));
ga.getXMLAnswer(getAjaxData);
function getAjaxData(response){
g_form.setValue('u_account_ref', response);
}
}
EDIT: Just noticed Harsh has already picked this up!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2019 01:46 AM
I've found it, so using getXMLAnswer() I must remove the variable answer definition, in this way it works fine.
function getAjaxData(response) {
g_form.setValue('u_account_ref', response);
}
}
Thank you very much for your help, I really appreciated it!!!
Cheers
Alberto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2019 03:54 AM
Glad you got it working 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2019 04:11 AM
Last thing still not clear for me: do you know how to do the same with an onSubmit() client script instead of onChange()?
What do we need to change in these code?
Thanks a lot
Cheers
Alberto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2019 05:45 AM
in an onSubmit script you'll need to use getXMLWait(), this runs the call synchronously so it waits for the response, otherwise the call is asynchronous and your form will submit before the data is returned to the client.
Generally best to avoid synchronous ajax calls if you can, validation can be done onChange or with a before insert/update BR. With this requirement, i don't know why you'd do this onSubmit, tbh i would have put this in a before insert BR.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2019 10:25 AM
Make sense, at first I was thinking to populate the value only when someone change the Task, but make more sense to do a Before BR, as you said...how will be the BR? I'm wondering the code is different in this case, could you give me an example please?
Thanks
Alberto