- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2024 05:22 AM
How do I clear a variable value using an onLoad Client Script?
The catalog item auto fills a variable (employee type) based on the requested for. Requested for auto fills when the submitter opens the catalog item.
Using an onChange script, the employee type does not populate unless the requested for is changed.
Using an onLoad script, the employee type populates but if I change the 'requested for' the employee type does not change.
What can I do to get this to populate correctly?
Thank you for any help you can offer...
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2024 06:06 AM
Use the onchange client script and remove the isloading check on it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2024 06:40 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2024 05:34 AM
Here is the onLoad script:
function onLoad() {
//Type appropriate comment here, and begin script below
}
//getReference for Project Number, then callback and populate
// autoPopulate is our callback function
g_form.getReference('requested_for', autoPopulate);
function autoPopulate(et) {
//set values after getting reference
g_form.setValue('employee_type', et.getValue('u_employee_type'));
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2024 05:42 AM
Hi @rachelconstanti ,
So if u manually change the requested for value u want the employee type to populate. am i correct?
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2024 05:48 AM
If yes, then simply create 1 onChange script for variable requested for & copy the same code given below in on change script it should work.
g_form.getReference('requested_for', autoPopulate);
function autoPopulate(et) {
//set values after getting reference
g_form.setValue('employee_type', et.getValue('u_employee_type'));
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2024 05:57 AM - edited 01-05-2024 06:00 AM
Using the above does not fill the employee type.
When the catalog item is loaded, employee type needs to populate based on requested for. If the requested for is changed, the employee type needs to change.
If I use onChange, the employee type does not populate when the catalog item is opened.
If I use onLoad, the employee type does not change if the requested for is changed