Clearing a field when related field is cleared (same principle as user id & location) or (category & classification)

germc
Giga Expert

Hi guys,
One of our guys here has set up a new field on the incident form called 'Configuration item' where it links in the users asset info. The thing they are struggling with is how to get this field to blank out when the Caller is blanked out. I was looking at the script for the 'Location' field on the Incident form, as that does blank out like it should and then re-populate when a different Caller is added. I want this same result with the CI field as well. Can't figure it out though... I looked at the wiki and found info on Cascade Delete Rules (http://wiki.servicenow.com/?title=Reference_Fields) but tried that and it didnt work. Not sure if I am on the right track or not! Is a script needed or is there an attribute we can add to the dictionary?

10 REPLIES 10

david_legrand
Kilo Sage

Hi Ger,

1) What is the color of your field? (light gray or dark gray) ==> IE : Do you use dot-walking to display this field into your form?
2) Do you want to clear this field while your user is on the form or when you save the record? (i think when the user is on the form)

If the field is "light gray" (without dot-walking so), and if you want the user seeing the field be blank while is editing, the "client script" onChange like "(BP) Set Location to User" should be working.
Unless if your target field is protected by an ACL or by a data policy (read only or mandatory) of course but if you can populate at a moment, you should be able to clear it.

I don't think the "Cascade Delete Rules" is the right approach, you probably should let it blank as by default.

If you have more information (maybe a screenshot of these fields), it could be easier to help you.

Best regards,


Tom Alday
Mega Guru

I do something similar to this to clear and hide a field if the Assigned To field is cleared.

Create a UI Policy on the Incident table

On Load - Checked
Run Scripts - Checked
Active - Checked

Condition - Caller is empty

Execute if True script:
function onCondition() {
g_form.clearValue('FIELD YOU WANT CLEARED');
}


Thank you so much for your reply. That worked a treat.
I seem to have ran into another strange problem with the Config item field.
The field was only being populated when someone was manually entering the Caller in the Incident. However, I believe we would want this to populate automatically based on the caller for Emails and Self Service calls, just like the 'Location/Division' field populates automatically for users.
So when a call comes in from either email or Self Service with the users name it does not generate the config field. Mot sure if I should create a new topic for this or not..


david_legrand
Kilo Sage

For that, you'll need a business rule as well.
The OOB "Company Projection" (business rule on incident table) could help you to find what you need to do.

1) Pay attention to the conditions (you don't want to erase a value someone pushed manually)
2) In your documentation, try to have somehow the information that the fields are populated with 2 different ways

A little reminder in case it's useful for other people, the client script works when "a real human see the form" (so the real human will see the form be populated automatically when he/she'll modify something) while the business rule runs "only on the server where the real human can't see" (he/she will see only the result). In case of "email / self-service / web services...", as we don't have human watching the incident form, the client script doesn't work so the business rule take the relay.

Best regards,

ps:Once your questions will be answered, could you mark the topic answered? 🙂