The CreatorCon Call for Content is officially open! Get started here.

Populating information in a single line text variable field from the Reference icon

chenelle
Kilo Expert

I created a   single line text variable for called "application id" but the application id is also available if you hover over the reference icon.   How can i take the application id that was selected and showing from the reference icon and populate it to the variable field on the form i created so the user doesn't have to hover over the reference field.   When I create the variable as a reference...the table is not available to select, but a parent of that table is able to be selected.   Seems like i can use some type of catalog client script or something to populate the info.       See below when you hover or click the more information for the .Net Services and Console App, the Application ID is available, however the users want it to to be directly on the form and not have to hover.   Please advise.   Thanks!

find_real_file.png

find_real_file.png

1 ACCEPTED SOLUTION

guhann
Mega Guru

Cenelle,



Have an onChange catalog client script on the reference variable 'What is the Business Application ID?'. and using the getReference() method you can get the application id and populate the same in the single line text variable you have created.



Code inside the onChange script:


var application = g_form.getReference('<reference_variable_name>',populateAppID);



function populateAppID(application) {


      g_form.setValue('<text_variable_name>',application.<field_name_that_holds_application_id_in_the_record>);


}


View solution in original post

18 REPLIES 18

Just specify the field name of application id. See below,



function populateAppID(application) {


      g_form.setValue('v_app_id_number',application.application_id); //mention the exact field name which holds application id in the table record


}


Guhan, I have one issue now, I had that set on a variable set1 well there


is a variable set 2 that this script needs to be on instead. So i did the


same thing on variable set 2, but it is not working and varaible set 2 is


like an Office Use Only after the user clicks order now. So now the script


doesnt work or pull the app id. Should it still be an " On change" or


should it be OnLoad, or cellEdit, or On Submit? Dont know why it wont work


on this one. i think it has to do with the form has already been load and


information for record keeping is being done and then the Application is


selected......please help if you can






Vstream TV Distributor


Chenelle Stewart


252-544-4404


Absolutely Free TV, Movies, Sports & PPV


<http://nrbuilder.com/i/CS11100/vstream.html>





On Wed, Oct 28, 2015 at 5:36 PM, guhann <community-no-reply@servicenow.com>


You have use onChange script. The variable in which user selects the applciation name is on variable set1 or 2 ?


I originally had it on 1 and it worked great, but they want it on Variable


set 2 which is what the fulfillment group will be seeing and updating


themselves. But the script is no longer working.






Vstream TV Distributor


Chenelle Stewart


252-544-4404


Absolutely Free TV, Movies, Sports & PPV


<http://nrbuilder.com/i/CS11100/vstream.html>





On Thu, Oct 29, 2015 at 12:08 PM, guhann <community-no-reply@servicenow.com>


As long as you have defined the onChange script for the right variable it should work regardless of which ever the var set it is in. there should be some syntax error. Paste your script and both the variable names here. Will check