How to populate choice field on form when form is loading (not using default value)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2024 08:36 AM
Hello all,
I want to populate 'case type' field which is OOTB field with default value "none" which has 5 choices and I want to populate the field with 'Statement' (which is one of the choice) when we are try to creating the case when form is loading. I don't want to use default
Is there any way using script Include and client script ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2024 09:08 AM
Hi @Vijay7 ,
if you don't want to update the default value of the field you can create an onload client script which only runs on new records
function onLoad() {
if (g_form.isNewRecord()) {
g_form.setValue('case_type'/*bakend value of the field*/, 'statements'/*bakend value of the choice*/); //replace with backend values
}
}
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2024 10:27 PM
Hi @Vijay7 ,
Just write a OnLoad Client script for Case type field table.
Sample script:
(function() {
// Check if the form is being loaded for a new case (optional)
if (g_form.isNew()) {
// Set the 'case type' field value to 'Statement' on form load
g_form.setValue('case_type', 'Statement'); //adiust the backend values of choice accordingly
}
})();
Thanks,
Pradeep
Regards,
Pradeep