- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2017 02:09 PM
Hi ,
I have a requirement on List Collector (on Maintain Item), On selecting one of the option of the list collector , i want description field should be Mandatory.
- If the right collector list has Other option selected then the description field should become mandatory and if i remove the Other option from right collector then description should become optional.
2. And if i choose only Other , then Description field is becoming Mandatory but if i choose different options with Other and it is not working as below screen.In below case the description should be mandatory but its turning to optional.
First scenario is working as expected but second scenario is not working.
Can anyone help me on this issue .
function onChange(control, oldValue, newValue, isLoading) {
// if (isLoading || newValue == '' ) {
// return;
//}
var a1 = [];
var rightBucket = $('u_software_items_select_1');
var leftBucket = $('u_software_items_select_0');
for(i=0; i<rightBucket.options.length;i++){
a1.push(rightBucket.options[i].text);
}
var j=0;
while(j<a1.length){
if(a1[j]=='Other'){
g_form.setMandatory('description',true);
}
else{
g_form.setMandatory('description',false);
}
j++;
}
if(g_form.isMandatory('description') && rightBucket.options.length==0){
g_form.setMandatory('description',false);
}
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
-
Team Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2017 01:46 AM
Hi Shalinipriya,
Please write an onChange catalog client script on change of the List Collector type field with the script below. I hope this will help you in your requirement:
function onChange(control, oldValue, newValue, isLoading) {
if (newValue == '') {
g_form.setMandatory('variable_name_of_Description', false);
return;
}
if (isLoading || newValue != ''){
if (newValue.toString().indexOf("8a590d024f65aa00a766a3b11310c777") >-1) { //pass the sys_id of the record 'Other'
g_form.setMandatory('variable_name_of_Description', true);
}
else
{
g_form.setMandatory('variable_name_of_Description', false);
}
}
}
I hope this helps.Please mark correct/helpful based on impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2017 04:33 PM
Hi,
I guess your onChange script is on the list collector. What you can do is filter the "newValue" parameter you got. That is the result of the "right slushbucket". Only crappy part is that it is sys_id separated by semicolon. But you should look in newValue and see if you sys_id for other is there and then do you thing. Even if I isn't so happy to hardcode sys_ids
//Göran
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2017 01:46 AM
Hi Shalinipriya,
Please write an onChange catalog client script on change of the List Collector type field with the script below. I hope this will help you in your requirement:
function onChange(control, oldValue, newValue, isLoading) {
if (newValue == '') {
g_form.setMandatory('variable_name_of_Description', false);
return;
}
if (isLoading || newValue != ''){
if (newValue.toString().indexOf("8a590d024f65aa00a766a3b11310c777") >-1) { //pass the sys_id of the record 'Other'
g_form.setMandatory('variable_name_of_Description', true);
}
else
{
g_form.setMandatory('variable_name_of_Description', false);
}
}
}
I hope this helps.Please mark correct/helpful based on impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2017 07:05 PM
Thanks Amlan.It worked.