- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2019 09:39 PM
Hi team,
(i have couple of other validations so i am writing client script instead of ui policy)
i am trying below script on onchange on emptype field, it is working fine for both if condition.
- But when i change value to "employee" i am getting alert inside 1st if condition, and form looks like below
- When I change to “consultant” I am getting alert in second if condition but it does not hide the fields still remains same on form please suggest.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var emptype = g_form.getValue('employement_type');
if(emptype=='employee'){
alert('onchange employee'+emptype);
g_form.setDisplay('candidate_id',true);
g_form.setDisplay('u_employee_id',true);
g_form.setMandatory('candidate_id',true);
g_form.setMandatory('u_employee_id',true);
}
if(emptype=='consultant'){
alert('onchange consultant'+emptype);
g_form.setDisplay('candidate_id',false);
g_form.setDisplay('u_employee_id',false);
g_form.setMandatory('candidate_id',false);
g_form.setMandatory('u_employee_id',false);
}
//Type appropriate comment here, and begin script below
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2019 10:34 PM
Just add it like this to simplify
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
g_form.clearValue('candidate_id',true);
g_form.clearValue('u_employee_id',true);
var emptype = g_form.getValue('employement_type');
if(emptype=='employee'){
alert('onchange employee'+emptype);
g_form.setDisplay('candidate_id',true);
g_form.setDisplay('u_employee_id',true);
g_form.setMandatory('candidate_id',true);
g_form.setMandatory('u_employee_id',true);
}
if(emptype=='consultant' || emptype=='none'){
alert('onchange consultant'+emptype);
g_form.setMandatory('candidate_id',false);
g_form.setMandatory('u_employee_id',false);
g_form.setDisplay('candidate_id',false);
g_form.setDisplay('u_employee_id',false);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2019 10:22 PM
Try this
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
var empid = g_form.getValue('u_employee_id');
if(empid==''){
alert('onchange empid is empty'+empid);
g_form.setMandatory('candidate_id',true);
}
if(empid!=''){
alert('onchange empid is not empty');
g_form.setMandatory('candidate_id',false);
}
//Type appropriate comment here, and begin script below
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2019 10:25 PM
i have kept one more onchange on empid also,
in one case this is failing to work.
1. i selected emptype- employee, 2 variables came (cadid & empid) with both mandatory, i have filled candid (empid removed mandatory) till here it is working fine.
2. when i change emptype to consultant and again to "employee" now it is showing as below screen shot,
when i change emptype value and again if i select employee, "empid" is becoming mandatory, idly it should not because candid is filled!
Can we clear value? or any other solution's?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2019 10:29 PM
Yes, On change of Employee type, clear values on Emp Id and Candidate ID.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2019 10:31 PM
i have added clearvalue in emptype onchange script as below, and testing now
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var emptype = g_form.getValue('employement_type');
if(emptype=='employee'){
alert('onchange employee'+emptype);
g_form.setDisplay('candidate_id',true);
g_form.setDisplay('u_employee_id',true);
g_form.setMandatory('candidate_id',true);
g_form.setMandatory('u_employee_id',true);
g_form.clearValue('candidate_id',true);
g_form.clearValue('u_employee_id',true);
}
if(emptype=='consultant' || emptype=='none'){
alert('onchange consultant'+emptype);
g_form.setMandatory('candidate_id',false);
g_form.setMandatory('u_employee_id',false);
g_form.setDisplay('candidate_id',false);
g_form.setDisplay('u_employee_id',false);
g_form.clearValue('candidate_id',true);
g_form.clearValue('u_employee_id',true);
}
//Type appropriate comment here, and begin script below
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2019 10:34 PM
Just add it like this to simplify
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
g_form.clearValue('candidate_id',true);
g_form.clearValue('u_employee_id',true);
var emptype = g_form.getValue('employement_type');
if(emptype=='employee'){
alert('onchange employee'+emptype);
g_form.setDisplay('candidate_id',true);
g_form.setDisplay('u_employee_id',true);
g_form.setMandatory('candidate_id',true);
g_form.setMandatory('u_employee_id',true);
}
if(emptype=='consultant' || emptype=='none'){
alert('onchange consultant'+emptype);
g_form.setMandatory('candidate_id',false);
g_form.setMandatory('u_employee_id',false);
g_form.setDisplay('candidate_id',false);
g_form.setDisplay('u_employee_id',false);
}
}