Allow user to enter non-existing value to Catalog Item reference variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2024 06:03 PM
I'm working with catalog item and I have a variable called 'city', which is a reference variable to the 'cmn_location' table. The requirements are:
- As user typing in the 'city', it should have autocomplete (which can be achieve with the built-in autocomplete feature).
- If the value they type in does not exist in the 'cmn_location' table, do not show the error "Invalid Reference", but create a record for it in the 'cmn_location' table.
I know in the regular form, this can be done by turning on Dynamic Creation on the form's reference field, but this is not offered in Service Catalog Item. Is there a workaround to achieve the requirements I listed above?
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2024 10:21 PM
Hi @huyentp ,
This is not a best practice to do so, user may enter incorrect value by mistake multiple times and dummy data are created which will never be used.
Instead, create a new Select box variable with label "City" with 2 options: "Existing City" (show 'City' reference field) and "New City" (show 'New City' single line text field).
Then use the onSubmit client script to create new location based on the "New City" field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2024 09:37 AM
Thank you for your response! I was thinking if it's possible, I'd want to let user enter a new value and handle it either using an onChange or onSubmit script.
(Sorry I should be more clear) I think the main goal I wanted to achieve is: when user enter a value in the City field, there should be autocomplete to suggest them the name of the existing cities, if not, accept their input as it is. If I make the 'city' field a String Text Field, is there a way to implement autocomplete in that String Text Field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2024 10:18 AM
hello @huyentp295 I got your requirement , To meet your requirement of implementing a string field for 'city' with autocomplete functionality based on existing values or allowing creation of new city names if not found, you can implement a script within the city table. This script will verify whether the entered city value already exists in the table. If the city is not found (indicating it's a new city), the script will create a new city record in the table and automatically populate the city field with this new value. This approach ensures that the city field is seamlessly managed and populated with existing or newly created city names as needed. Please make a helpful if it helps for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2024 05:48 PM
Thank you for your response! Could you please clarify more on this approach? So I can create a 'city' String text field variable in the catalog item, how would I implement the autocomplete (i.e: as user is typing, it suggests the city that exists in the city table, just like reference field autocomplete), but let user enter a new value if the value does not exist?