Computed filed is not returning value

yandp
Tera Guru

Hi all, 

I have a reference filed that reference to a custom lookup table.

the Reference qual is working good, but user need to select the return value manually.

yandp_0-1728749433304.png

 

javascript:'u_active=true^u_key=TEST Fees^u_dependent='+current.u_test_name.u_value

 

so i think of to make it as computed field, so using the script, however the value is not returned to the computed field, it shown empty. 

yandp_2-1728749602747.png

 

Is there something wrong? pls help me if any idea, or computed filed cannot be use like that?

how can do this to lookup the value automatically ?

 

Thank you very much.
1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

You can use a script like this in a calculated field.  Know that if this works, the value will be selected, and the field read-only.  If this is what you want, check a list view of your custom table, manually filtering by this criteria to see if the intended record is displayed.  If it is, ensure that u_value is the field you want to from this lookup table, and that the field type matches the field type of the calculated field.  If this is still a reference, u_value needs to be a sys_id of the lookup table, so that doesn't seem like it makes sense.  Maybe you want to change this field type?

 

If you are just looking to populate the reference field when a u_test_name is populated, then use an onChange Client Script that calls a Script Include via GlideAjax to do this GlideRecord and return the desired value or record from the lookup table.

View solution in original post

4 REPLIES 4

Bert_c1
Kilo Patron

Seems you're trying to use two methods to achieve your desired result. The script looks good, same logic as used in the OOB disctionary for 'definition' defined on the 'sys_generative_ai_prompt_config'.  Try setting the 'Use reference qualifier' value to "Simple" (not "Advanced") and no Condition. then test.

 

You have access to the Script Debugger on that script, you can set a breakpoint and then test with that.

Brad Bowman
Kilo Patron
Kilo Patron

You can use a script like this in a calculated field.  Know that if this works, the value will be selected, and the field read-only.  If this is what you want, check a list view of your custom table, manually filtering by this criteria to see if the intended record is displayed.  If it is, ensure that u_value is the field you want to from this lookup table, and that the field type matches the field type of the calculated field.  If this is still a reference, u_value needs to be a sys_id of the lookup table, so that doesn't seem like it makes sense.  Maybe you want to change this field type?

 

If you are just looking to populate the reference field when a u_test_name is populated, then use an onChange Client Script that calls a Script Include via GlideAjax to do this GlideRecord and return the desired value or record from the lookup table.

@Brad Bowman  
Thank you very much for your advice, it is working after i change the computed field type to string.

Appreciate your help so much. 

Great to hear!  I am happy to help!