Fixed reference field value

jimpaige
Giga Contributor

Hi all,

I'm using a reference field to the user table for a 'name'.   I need to fix the value so if an object in AD is deleted, the username value in the reference field is not removed.   Anyone know how to achieve this?

Thanks all!

1 ACCEPTED SOLUTION

Brian Dailey1
Kilo Sage

Hi Jim,



Arnab's answer will almost get you there... but not quite.



You can change the cascade rule to "None" (note this is not the same as "--None--"), however this will only maintain the value of the sys_id after the referenced record gets deleted.   To store the value of the name field instead, set it (name) as the Reference Key for your reference field in addition to changing the cascade rule.



The thing you have to be aware of is that if you have any duplicate values stored in the 'name' field, this could cause it to point to an incorrect record.   However if your usernames are required to be unique, this shouldn't be a problem.




Give that a try,


-Brian


View solution in original post

4 REPLIES 4

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Jim,



Please refer section 7 "Cascade Delete Rules" for more info.


Reference Fields - ServiceNow Wiki



Please let me know if you have any questions.


arnabwa
Giga Guru

Hi Jim,



You can do this to restrict the deletion of a value in reference field when the user is deleted from AD :


Right click on the reference field >> Click on Configure Dictionary >> Find the section "Reference Specification - Additional Customization" (if you can't locate it, click on advanced view) >> you will get a drop down field "Reference cascade rule" >> Select the option "None" inside the drop down box (note that by default you might be seeing the "--None--" option but this not the "None" I'm talking about. Inside the drop down you'll get another "None" option. Select this) >> Save/Update. See the screen shot below :



comm3.PNG



Thanks,


Arnab



Please mark Helpful/Correct if my solution was of any worth to you !


Brian Dailey1
Kilo Sage

Hi Jim,



Arnab's answer will almost get you there... but not quite.



You can change the cascade rule to "None" (note this is not the same as "--None--"), however this will only maintain the value of the sys_id after the referenced record gets deleted.   To store the value of the name field instead, set it (name) as the Reference Key for your reference field in addition to changing the cascade rule.



The thing you have to be aware of is that if you have any duplicate values stored in the 'name' field, this could cause it to point to an incorrect record.   However if your usernames are required to be unique, this shouldn't be a problem.




Give that a try,


-Brian


Thanks for the light Brian. Appreciate your help !