How to create temporary table in servicenow?

Gokulraj1
Kilo Contributor

Hi All,

I am having script to get "sys_audit" table data by passing the incident sys_id.

I need to populate the temporary table and want to store that data. How to do that?

If anybody have any ideas/thoughts kindly share with me.

Thanks,

Gokulraj

1 REPLY 1

William Busby
Tera Guru

Your question is vague on several points:

- What is the intended purpose of this temp table? Most of the time the intended use will drive the implementation.

- How long is the retention period?

- Is the data shared with needed for multiple processes?

- How is the lifecycle of the table determined (what triggers the need and identifies when it's no longer needed)?

So, this may not be helpful w/o the info above but I'll start with one assumption - a useful solution to one situation often grows into multiple use cases and the next case is close but not quite the same.

I'd consider a table with a reference field to [incident] or [task] if you want the solution to be more flexible with a large 'content' attribute. Large is subjective and eventually inefficient. Take the temp table content to be stored and JSON.stringify() it before insert then JSON.parse() it for use into a object structure. This is a terrible solution for many (most?) cases but is flexible. A better question would get a better response.