Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Add work_notes when affected CI's got deleted

sry
Giga Guru

Hi, could someone help for the below requirement.

we have "Affected CIs" related list which is of table TASK_CI for Change request(change_request). people can add and remove CIs, the requirement is we can't audit if someone delete CIs or Added. we are thinking to put some work_notes at change_request level when someone deletes or add CIs. appreciate if anyone has worked on same scenario or any help.

thanks,

sry

1 ACCEPTED SOLUTION

Abhinay Erra
Giga Sage

Write a business rule on task_ci table


When: before delete


Conditions: Task.task type is change request


Script:


var chg= new GlideRecord('change_request');


  chg.get(current.getValue('task'));


  chg.work_notes=current.ci_item.getDisplayValue()+' is no more affected due to this change';


  chg.update();


View solution in original post

13 REPLIES 13

Abhinay Erra
Giga Sage

Write a business rule on task_ci table


When: before delete


Conditions: Task.task type is change request


Script:


var chg= new GlideRecord('change_request');


  chg.get(current.getValue('task'));


  chg.work_notes=current.ci_item.getDisplayValue()+' is no more affected due to this change';


  chg.update();


Hi Abhinay, thank you so much for the prompt reply. your solution worked   perfectly however i find the worknotes getting too many if i have lots of CIs added. suppose if i have added like 100 CIs and if i remove 50 of them the work_notes really adding 50 entries. can we add just a single worknote entry if i delete multiple CIs!



thanks,


sry


drjohnchun
Tera Guru

I remember the days when I had to do what you're describing to meet compliance requirements. But capturing audit trails in Work Notes is no longer needed as ServiceNow provides the features OOB. To enable it,



  1. Navigate to System Definition > Dictionary and turn on Audit for the task_ci table (btw, this is a many-to-many table)
    find_real_file.png
  2. Configure Activities to make sure Configuration item (this is the one CI on the main form) and Relationship Changes (this will show the Affected CIs from the Related List) are selected:
    find_real_file.png
  3. Then you'll see deletions like below (only deletions are shown since what got added are still in the Affected CIs Related List):
    find_real_file.png
  4. You can also see these events via the form menu > History > List like below (the Calendar view won't show the changes to Affected CIs):
    find_real_file.png


Hope this helps.



Please feel free to connect, follow, mark helpful / answer, like, endorse.


John Chun, PhD PMP see John's LinkedIn profile

visit snowaid


ServiceNow Advocate

Winner of November 2016 Members' Choice Award


Hi John Chun, your solution is also working. but i couldn't find the entries in History--> List.