How do i hide variables on a catalog item depending on a selection of another variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2017 12:17 PM
I have a Service Catalog item that i am working on . I am adding variables to this item which are checkboxes, radio buttons, multivalue drop down selections, text values, date items etc.
If i select a particular check box like "New Contract" , i need to display a couple of date variables and a comments variable.
What is the best way to achieve this ? Any suggestions?
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2017 10:54 AM
Hi Balaji,
This is my script in the onChange event of the item. But no luck. What am i doing wrong?
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
g_form.setDisplay('CRE_ContractStartDt',false);
g_form.setDisplay('CRE_NewContractEnd',false);
g_form.setDisplay('CRE_BC_Description',false);
g_form.setDisplay('CRE_AddCmts',false);
return;
}
if (newValue == 'true'){
g_form.setDisplay('CRE_ContractStartDt',true);
g_form.setDisplay('CRE_NewContractEnd',true);
g_form.setDisplay('CRE_BC_Description',true);
g_form.setDisplay('CRE_AddCmts',true);
}
else{
g_form.setDisplay('CRE_ContractStartDt',false);
g_form.setDisplay('CRE_NewContractEnd',false);
g_form.setDisplay('CRE_BC_Description',false);
g_form.setDisplay('CRE_AddCmts',false);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2017 11:49 AM
Hi Amol,
The problem is not with the script, because of variables mandatory at dictionary level. Because of that issue variables are not hiding for your scenario.
To workaround do like this way,
1) remove the mandatory of all fields.
go to configure dictionary of the "new contract date, end date and description" uncheck the mandatory false.
2) Now write a UI Policy or client script, when ever "new contact" is true, make visible and mandatory
if you want to go with client script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading ) {
g_form.setMandatory('CRE_ContractStartDt',false);
g_form.setDisplay('CRE_ContractStartDt',false);
g_form.setMandatory('CRE_NewContractEnd',false);
g_form.setDisplay('CRE_NewContractEnd',false);
g_form.setMandatory('CRE_BC_Description',false);
g_form.setDisplay('CRE_BC_Description',false);
g_form.setDisplay('CRE_AddCmts',false);
return;
}
if (newValue == 'true'){
g_form.setDisplay('CRE_ContractStartDt',true);
g_form.setMandatory('CRE_ContractStartDt',true);
g_form.setDisplay('CRE_NewContractEnd',true);
g_form.setMandatory('CRE_NewContractEnd',true);
g_form.setDisplay('CRE_BC_Description',true);
g_form.setMandatory('CRE_BC_Description',true);
g_form.setDisplay('CRE_AddCmts',true);
}
else{
g_form.setMandatory('CRE_ContractStartDt',false);
g_form.setDisplay('CRE_ContractStartDt',false);
g_form.setMandatory('CRE_NewContractEnd',false);
g_form.setDisplay('CRE_NewContractEnd',false);
g_form.setMandatory('CRE_BC_Description',false);
g_form.setDisplay('CRE_BC_Description',false);
g_form.setDisplay('CRE_AddCmts',false);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2017 12:36 PM
Tried this too. No luck. Haven't done the updated script yet. I am no able to understand what is wrong with this. I have tried everything but haven't been able to make it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2017 12:41 PM
Did you removed mandatory at the dictionary level?
If you are doing this one in your personal instance, share your instance name and credentials. I will look at once.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2017 10:58 AM
I think you ened to change this line from
if (newValue == 'true'){
to
if (newValue == true){