Passing the value of a field in a Table to Service Portal

Diogo Lemos
Tera Contributor

Hi guys,

 

I need a simple thing (it´s seems i guess) but right now is not working.

 

Basically i have a form that is part of a catalog item that contains different variables (see the image below).

 

DiogoLemos_0-1696005844725.png

In this form we have Agreed rate and i just want that this field to be fulfill like i have in the workspace (see the image below)

DiogoLemos_1-1696005988358.png


The client script that i did is like this: (the table that cointains the information is x_cioa2_hcx_t_engagement_hcx)
----------------------------------------------------------------------------------

function onChange(control, oldValue, newValue, isLoading) {
     if (isLoading || newValue == '') {
        return;
    }
    
    var hcxTable = new GlideRecord('x_cioa2_hcx_t_engagement_hcx');
    var agreedRate = hcxTable.addQuery('suggested_rate');
    hcxTable.query();
    var teste = g_form.getValue('final_travel_expenses');
    g_form.setValue('suggested_rate', agreedRate);
}
----------------------------------------------------------------------------------
Can someone help me with this?





 

5 REPLIES 5

@Diogo Lemos Are you running this client script on Service Portal, if it is the case then please note that GlideRecord queries are not supported in Client script on the Service portal. You need to replace your query with a GlideAjax call here. Please know more about GlideAjax here https://snprotips.com/blog/2016/2/6/gliderecord-client-side-vs-server-side#from-client.

 

Also, you can try to run the query in a background script 

var hcxTable = new GlideRecord('x_cioa2_hcx_t_engagement_hcx');
    hcxTable.addQuery('suggested_rate', '10');//add rate here
    hcxTable.query();
    if(hcxTable.next()){
gs.info('Record found');
}

and check if it prints any logs in system logs.