- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2017 10:46 AM
i have the following ui action that is not running
fillComponents2016();
function fillComponents2016(){
var invoices = new GlideRecord('u_invoices');
var total_ytd_fte = 0;
var total_ytd_cre = 0;
var total_ytd_tech = 0;
var total_ytd_tps = 0;
invoices.addQuery('u_service_agreement',current.sys_id);
invoices.addEncodedQuery('u_invoice_date<javascript:gs.beginningOfThisYear()');
invoices.query();
gs.log('Number of lines: ' + invoices.getRowCount(),'10 april ui action');
while(invoices.next()){
total_ytd_fte = total_ytd_fte + (parseFloat(invoices.u_fte.getCurrencyValue()));
total_ytd_cre = total_ytd_cre + (parseFloat(invoices.u_cre.getCurrencyValue()));
total_ytd_tps = total_ytd_tps + (parseFloat(invoices.u_third_party_suppliers.getCurrencyValue()));
total_ytd_tech = total_ytd_tech + (parseFloat(invoices.u_technology.getCurrencyValue()));
}
current.u_fte_previous_cost = total_ytd_fte;
current.u_cre_previous_cost = total_ytd_cre;
current.u_tps_previous_cost = total_ytd_tps;
current.u_tech_previous_cost = total_ytd_tech;
current.update();
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2017 11:23 AM
Hi Joao,
Please check the link below to get some information about how to run server side script in ui action.
https://www.servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/
and by the way in ui action there is a field "client" just checked that then you will see "onClick" if you mention any name for eg:
test();
then use this function in the script section and write your client side scripting .
and if you want to perform server side scripting then mention another function in script section. for eg: test2().
it would be like this.
test1()
{
alert('testing');
}
test2()
{
mention your glide query here and do some sever side code
}
Thanks,
Harshvardhan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2017 10:56 AM
Which part isn't running? Not returning any records from the GlideRecord?
Have you run it as a Fix Script?
JarodM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2017 11:02 AM
the function is not running. the gs.log() is not "printing"
I did not try fix scripts how do i run it on an ui action

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2017 11:23 AM
Hi Joao,
Please check the link below to get some information about how to run server side script in ui action.
https://www.servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/
and by the way in ui action there is a field "client" just checked that then you will see "onClick" if you mention any name for eg:
test();
then use this function in the script section and write your client side scripting .
and if you want to perform server side scripting then mention another function in script section. for eg: test2().
it would be like this.
test1()
{
alert('testing');
}
test2()
{
mention your glide query here and do some sever side code
}
Thanks,
Harshvardhan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2017 02:19 AM
This is what i have now, but still not working
function runFillPrevious(){
gsftSubmit(null, g_form.getFormElement(), 'fill_previous');
}
if(typeof window == 'undefined')
fillComponents2016();
function fillComponents2016(){
var invoices = new GlideRecord('u_invoices');
var total_ytd_fte = 0;
var total_ytd_cre = 0;
var total_ytd_tech = 0;
var total_ytd_tps = 0;
invoices.addQuery('u_service_agreement',current.sys_id);
invoices.addEncodedQuery('u_invoice_date<javascript:gs.beginningOfThisYear()');
invoices.query();
gs.log('Number of lines: ' + invoices.getRowCount(),'10 april ui action');
while(invoices.next()){
total_ytd_fte = total_ytd_fte + (parseFloat(invoices.u_fte.getCurrencyValue()));
total_ytd_cre = total_ytd_cre + (parseFloat(invoices.u_cre.getCurrencyValue()));
total_ytd_tps = total_ytd_tps + (parseFloat(invoices.u_third_party_suppliers.getCurrencyValue()));
total_ytd_tech = total_ytd_tech + (parseFloat(invoices.u_technology.getCurrencyValue()));
}
current.u_fte_previous_cost = total_ytd_fte;
current.u_cre_previous_cost = total_ytd_cre;
current.u_tps_previous_cost = total_ytd_tps;
current.u_tech_previous_cost = total_ytd_tech;
current.update();
action.setRedirectURL(current);
}