How to set default value on Reference variable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2023 11:28 AM
Hello everyone,
I have two variables (Requested For and Asset Tag).
Based on the user name, asset tag will automatic populate the assets that the user currently have.
1. When the form load, the Asset Tag is showing empty.
2. When I clicked on the Asset Tag, it showing all the Assets that belonging to the user.
Here is what I would like to accomplish:
When form load.....
If user has 1 asset, then default the asset tag in the Asset Tag field
else if user has more then 1 asset, then don't default to the first asset, just list them so that user have an option to select from the dropdown.
Thank you so much,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2023 12:14 PM
I'm still trying to get it to works.
Here are the steps I have done:
1. Created an OnLoad function in the Catalog Client Scripts
2. Pasted your suggestion code in the Script Area
3. Replaced the "requested_for" with "who_is_this_request_for" which is Requested For type name (see below picture)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2023 04:22 PM
Hi Radhika,
Can you please try like this?
If your requested_for is autopopulating, then use onLoad, if its changing then use on_change client script.
Please change the variable name accordingly.
Kind Regards,
Swarnadeep Nandy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2023 10:38 PM
Hello @SwarnadeepNandy
Thank you for continuing helping!
1. Currently, Miranda Hammitt has 1 asset in her possession.
2. Login as Miranda, the Asset Tag is showing blank. Since she has only 1 asset, it should populate that asset number in the Asset Tag field.
3. Here is the entire code. Did I made a typo somewhere in the code?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2023 01:44 AM
Hello,
Try putting console.log() statements to debug the code.
Maybe change the onLoad to onChange - field (who is this request for).
Kind Regards,
Swarnadeep Nandy

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2023 01:29 AM
Hi,
You can simpy pass below qualifier on the Asset Tag field as below.
javascript: 'assigend_to='+current.variables.who_the_request_is_for;
Replace who_the_request_is_for with the variable name where you select the user name.