- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2024 05:50 AM
As the subject states, I am trying to work on a client-side script. We have a catalog item that creates a case (sn_customerservice_case) with a predefined case type. I have also added a new choice to custom field choice list labeled u_substate
The requirement: There are several choices in this choice list that overlap between the additional choice lists, However, we are looking to present a new choice as an option for the substate field (custom field) based on this predefined case type, as such I believe we would need an OnLoad client-side script, so once the case loads with the predefined case type the script will run and present the additional choice
I am new to coding and javascript but this is what I have so far, I did something similar for OnChange and it seemed to work but having issues with the OnLoad, it doesn't seem work at all. Any guidance would be much appreciated
function onLoad() {
if (g_form.getValue('u_case_type') == 'services') {
g_form.addOption('u_substate', 'ready_for_triage', 'Ready for Triage');
return;
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 05:44 AM
Animesh,
My original code/logic was working, but after further analysis, there was another Client Script that was running and overwriting my changes. I have since updated the aforementioned client script with my code and its now working as intended.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2024 12:43 AM - edited 05-13-2024 12:44 AM
@Gregory Gribben
its very simple try this onChange client script code
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
if (newValue == "services") {
g_form.addOption("u_substate", "ready_for_triage", "Ready for Triage");//this code works for ONLOAD
return;
}
//Type appropriate comment here, and begin script below
if (newValue == "services") {
g_form.addOption("u_substate", "ready_for_triage", "Ready for Triage");// this one will work for onchange .
}
let me know if this works.!!!
Please accept the solution /mark this response as correct or helpful if it assisted you with your question.
Regards,
Animesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 12:29 AM
@Gregory Gribben
did my solution helped you if yes then close the thread
Please accept the solution /mark this response as correct or helpful if it assisted you with your question.
Regards,
Animesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 05:44 AM
Animesh,
My original code/logic was working, but after further analysis, there was another Client Script that was running and overwriting my changes. I have since updated the aforementioned client script with my code and its now working as intended.