The CreatorCon Call for Content is officially open! Get started here.

Set record counter

tanz
Tera Expert

I have a customised table u_audit which inserts the INC record number whenever the INC is updated.For this I have created a customised string field(u_number) which captures INC number and I have created a customised field (u_count) on the audit table and I want to insert the counter(1,2,3,4,5...) on basis of insertion of INC record. For examples: when INC record is updated for 1st time a record should be inserted in u_audit table which populates u_number as INC number and u_count should be 1 and so on. Please can you let me know how to achieve this.

 

1 ACCEPTED SOLUTION

If my answers helped you to resolve your queries then please mark them as correct or helpful based on the impact.

Thanks and Remarks

Abhijit

By marking my response as correct or helpful, you contribute to helping future readers with similar issues.
Regards,
Abhijit
ServiceNow MVP

View solution in original post

30 REPLIES 30

Maik Skoddow
Tera Patron
Tera Patron

Hi @tanz 

can you please explain why you want to rebuild the auditing feature of ServiceNow? What is the underlying requirement for that? Or what was not possible to implement that you decided to create a custom table for auditing?

Kind regards
Maik

I want to track the number of times the Incident is updated in a day for reporting purposes and what the number is...

Hi,

You can use flow or business rule to increment count. Use trigger condition so that BR/Flow will execute on every update and update the count  for associated record in custom table.

Please try this logic by yourself and let us know if you stuck anywhere.

 

Thanks,

Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Abhijit4
Mega Sage

Hi,

I would suggest to check for HistoryWalker API, this API helps us to get all updated details for any record. It stores all the updates happened to the record.

You can find more details below,

https://community.servicenow.com/community?id=community_article&sys_id=741a871ddb8de8106621d9d968961...

https://developer.servicenow.com/print_page.do?release=paris&category=null&identifier=c_HistoryWalke...

 

If you still want to go for your solution then you would need to write on update/insert BR on incident table with below pseudo code.

if current.operation()=="insert" then insert new record in audit table with incident number and count =1

else if(current.operation()=="update") then get current incident record from audit table and increment count.

Let me know if you have any further queries.

Please mark this as Correct or Helpful if it helps.

Thanks and Regards,
Abhijit

By marking my response as correct or helpful, you contribute to helping future readers with similar issues.
Regards,
Abhijit
ServiceNow MVP