Clear values on a reference field using catalog client script?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2015 12:00 PM
Hi all,
I'm facing an issue with a catalog client script to clear the values of a field when another one is selected... In the catalog item, I have two options that the user can select: 1) Hardware, 2) Software. Based on this selections, other fields appear for the user to select an item and an issue. For example, if a user selects Hardware option, and select a hardware item and issue but then decide that they need to select the Software option instead, once they click on Software, the other fields should be cleared of the data entered and hidden.
I have a UI policy that shows and hides the fields when conditions are met but the data is not being cleared out. I tried writing a client script but no luck, it doesn't erase the data that was entered previously... Below are some screen shots of what I have done. Any suggestions? Please help!!
This screen shot is looking at the "issue_type" field which is a multiple choice field to select Hardware or Software. The onChange script is supposed to look at the field and if it changes, then set the "sw_ci" to empty which is the reference field for software items (CIs). The sane would be vice versa... I don't have to have the questions there but I just added to see what would happen... and nothing happens.
I also tried this one, but still no results.
This is how the item looks, and depending on the selection for hardware or software, should there be any data in the item or issue field, it should be cleared out when another option is selected. For example, if I select 'Software Item', then the information for hardware should be cleared out...
Any ideas/ suggestions would be greatly appreciated!
Thank you,
Yeny Garcia.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2015 08:30 PM
Hi Yeny,
Keep alert inside if condition and check either its going inside or not.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2015 09:23 PM
Hi Yeny,
Try using g_form.clearValue('sw_ci'); instead....
as Harish suggested, put alerts on the script to see the flow.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2015 09:20 AM
Hi Anurag and Harish,
Thank you both for your replies!
I have been working on this script all morning but I can't figure out another issue that came up. On the second screen shot of the script that I posted, I got that one to do just what I wanted as far as clearing out the fields when the selection changes... but now, for some reason, another field keeps popping up that shouldn't be coming up because it goes against the UI policy that I have in place for it.
For example, on the catalog item, I have selected 'hardware' as my issue and fill in the required fields, but then I select 'software', and the fields are cleared as the client script runs (which is expected) and if I switched back to the 'hardware' selection, the 'symbol units' field keeps appearing. I have tried to code it in the client script to 'hide' it but it is not working. The UI policy says that this field should only be visible and mandatory when the 'hardware item' is "Symbols", but that is not being the case... any ideas of how I can make this field not show up unless it matches the conditions in the UI Policy?
in this example, I am selecting 'Training room PC' and selected PC 'C'.
When I switch my selection to "software issue', i get this message and then it changes to the software field when I click OK, which is what i want to happen.
But if I switch back to 'hardware issue', the other field has appeared out of nowhere... and i'm not sure how I can make it go away and only appear when the hardware item is "symbol" as the condition in the UI Policy states.
Any help/suggestions is truly appreciated!
Thank you,
Yeny Garcia

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2015 09:23 AM