Advanced Reference Qualifier Work Both Ways - Parent and Child
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 08:00 AM
I have 2 reference fields displayed on a form, "Service" and "Service Offering". There is a parent-child relationship between these 2 fields. One Service can have many Service Offerings, Service Offering will only ever be associated with 1 Service.
I currently have an advanced reference qualifier restricting the list of Service Offerings depending on the "Service" selected (working fine):
javascript: 'service= + current.service;
The requirement I've been given is to allow users to make a selection at the service offering and have the service field back fill. But some users will first select a service and then proceed to select from the narrowed down list of Service Offerings so I want it to account for both scenarios.
Can anyone help with how I can write an advanced reference qualifier that can work "both ways" ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 11:36 AM
Assuming that the names of your fields are "business_service" and "service_offering", you could use the following code in the reference qualifier of the Service field:
javascript: var ref_qual = ''; var service = current.service_offering.parent; if (service) ref_qual = 'sys_id=' + service; ref_qual;
You could also define it as a function in a Script Include and call it from the reference qualifier.
For the Service Offering field, I think you can do without a reference qualifier. Instead, you can configure Service Offering to be dependent on Service by putting "business_service" into the Dependent field in the dictionary entry of the Service Offering field.
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/