Getting Value of a field in Record Producer form

Sergio Gadelha
Tera Contributor

Hi, I've a Reference field and I want to use dynamic reference qualifier in him. So I've to create a Dynamic Filter Option, and a Script include that return a string query.

My problem is I can't get the value of a field in record producer called "u_hotel_spirit_code". That field is Reference too.

current.u_hotel_spirit_code --> Don't work

producer.u_hotel_spirit_code --> Don't work

g_form.getValue('u_hotel_spirit_code') --> Don't work

Someone could help me?

Script Include:
scriptInclude.jpg

Dynamic Filter:

dynamicFilter.jpg

The second must be filtered by the first:

relationalThings.jpg

1 ACCEPTED SOLUTION

Sergio Gadelha
Tera Contributor

I found here the answer: https://community.servicenow.com/message/760842#760842




To access the variables on server-side, you've to use "current.variables.variableName".




In my case: "current.variables.u_hotel_spirit_code".




My Dynamic Filter Option now:
dynamicFilter.jpg






My Script Include now:



scriptInclude.jpg


View solution in original post

16 REPLIES 16

filterDynamic.jpg


Why you are using dynamic here, use advance here and add same line in Refernce Qualifier.


prithvirajchaud
Mega Expert

Hi,



Try gs.addInfoMesage(producer.u_hotel_spirit_code) and see what it returns.   Since its a reference field it should return the sys_id of the record it is refering to.



Thanks


The message not show. If I try "gs.addErrorMessage(current.u_hotel_spirit_code);" it shows "undefined".


Hello Sergio,



From the script, I can understand that you are just calling the script include without any parameters.



try like this, in the dynamic reference qualifier: javascript: new CompanyFilter().byLocationAndVendorType(producer.u_hotel_spirit_code);


On the script include end: Change the function name like this



byLocationAndVendorType: function(obj){


gs.print(obj);


//obj is your hotel spirit code.


},