|
| 1 | +function onChange(control, oldValue, newValue, isLoading, isTemplate) { |
| 2 | + if ( newValue == '') { |
| 3 | + return; |
| 4 | + } |
| 5 | + |
| 6 | + var department = g_form.getValue('u_department'); |
| 7 | + |
| 8 | + // Clear all of the choices from the What needed field choice list |
| 9 | + g_form.clearOptions('u_department'); |
| 10 | + |
| 11 | + // If the value of the Request type field is hr, add |
| 12 | + // two hr choices and other to the department field choice list |
| 13 | + if(newValue == 'hr'){ |
| 14 | + g_form.addOption('u_department','hr','Human Resources'); |
| 15 | + g_form.addOption('u_department','finance','Finance'); |
| 16 | + g_form.addOption('u_department','legal','Legal'); |
| 17 | + } |
| 18 | + // If the value of the Request type field is finance, add |
| 19 | + // two facilities choices and other to the What needed field |
| 20 | + // choice list |
| 21 | + if(newValue == 'finance'){ |
| 22 | + g_form.addOption('u_department",'finance','Budget'); |
| 23 | + g_form.addOption('u_department','finance','Disbursement'); |
| 24 | + g_form.addOption('u_department','other','Other'); |
| 25 | + } |
| 26 | + // If the value of the Request type field is legal, add |
| 27 | + // two legal choices and other to the What needed field |
| 28 | + // choice list |
| 29 | + if(newValue == 'legal'){ |
| 30 | + g_form.addOption('u_department','leg1','Legal issue'); |
| 31 | + g_form.addOption('u_department','leg2','Land issue'); |
| 32 | + g_form.addOption('u_department','other','Other'); |
| 33 | + } |
| 34 | + |
| 35 | + // If the form is loading and it is not a new record, set the u_what_needed value to the |
| 36 | + // value from the record before it was loaded |
| 37 | + if(isLoading && !g_form.isNewRecord()){ |
| 38 | + g_form.setValue('u_department', department); |
| 39 | + } |
| 40 | + } |
0 commit comments