How can I get the value of a field from the parent form in a catalog client script?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2024 10:04 AM
Hi all!
I have a OnSubmit Catalog client script that applies to a Variable Set. The type of the catalog client script is Service Portal / Mobile. I need to get the value of a field from the parent form but this line of code is not working. Any idea why it doesn't work?
var fieldName = g_service_catalog.parent.getValue('u_field_name');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2024 10:30 AM
This code will work to get the value of a variable that is defined on the Catalog Item. Add an alert on 'fieldName' to your script. If you are not getting the expect result then confirm your 'u_field_name' value exactly matches the name of a Catalog Item variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2024 10:34 AM
Hi @Community Alums,
In a Service Portal or Mobile client script, the approach to accessing values from the parent form is slightly different compared to traditional catalog client scripts. Instead of using g_service_catalog.parent, you should utilize spModal to interact with the parent form. Here's the corrected code: