OnLoad Client Script to only show choice depending on CaseType

Gregory Gribben
Tera Guru

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;
    }
}

 

1 ACCEPTED SOLUTION

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. 

View solution in original post

7 REPLIES 7

AnimeshP_96
Tera Guru

@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

@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

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.