I am trying to set a read only reference variable to info from the locations table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2022 02:18 PM - edited ‎12-13-2022 09:13 AM
I'm trying to set up an onChange client script that will populate four variable on the ServicePortal form. I want them to be read only which I have setup in the variables themselves. But basically when a user selects a location I want these four variables populated with data that I pull from the cmn_location table. I'll paste what I have below. It's not working. I'm sure there is something I'm missing but I'm not sure what. I also want the variables to clear if the location is set back to empty. Could someone help me out? Thank you.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
if (newValue == '') {
g_form.setValue('address', '');
g_form.setValue('city', '');
g_form.setValue('state', '');
g_form.setValue('zip_code', '');
}
//Type appropriate comment here, and begin script below
g_form.getReference('new_store_number', function(store) {
g_form.setValue('address', store.street);
g_form.setValue('city', store.city);
g_form.setValue('state', store.state);
g_form.setValue('zip_code', store.zip);
}
);
}
The script actually worked fine. I had one thing out of place.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2022 04:11 PM - edited ‎11-01-2022 04:17 PM
If new_store_number is a reference variable which is referencing cmn_location table, and onchange catalog client script is on this variable, then it should work.
Some of Catalog Client Script Configuration Would Be Something Like Below.
Active = Checked/True
UI Type = All
Variable name = new_store_number
Applies on a Catalog Item view = Checked/True