How to fix slow running UI Action?

Paul125
Kilo Guru

Hello, I have a UI Action(related link) which was built on cmdb_hardware table to take care of duplicates. This UI Action is available on each CI in the hardware table. This UI Action checks for tickets, tasks etc  and performs it's action. The issue here is.. Script in the UI Action always looks for incident, task table to find the tickets of the CI each time when user click on the link. I think gliding multilpe larger tables slowing down the UI Action.

When we had the health check with ServiceNow, this specific script came out as slow running script. Is there any way to make this UI Action run faster than before using script include or something. Please suggest, Thanks!

1 ACCEPTED SOLUTION

Script include cannot be used, You can however move the deletion part into an event and script action for its execution.

The script will also require lot of optimization like

1) encodedQuery can be used instead of multiple addQuery()

2) You could use updateMultiple() instead of update() within the while loop. This will process the change in a single run instead of different loops on different tables

3) Separating the logic into 2 different parts: 

a) Identifying the duplicates

b) Replacing the CIs on all task

c) Deleting them all together in an event

Lot of rework!

View solution in original post

8 REPLIES 8

Hello,

Fire an event and let script action do the job what UI action is doing.

That will make it based on user click but the ASYNC transaction and wont block the user,

 

https://docs.servicenow.com/bundle/london-platform-administration/page/administer/platform-events/re...

https://developer.servicenow.com/app.do#!/traindetails/app_store_learn_coding_fuji_c_CodingOnService...

 

Note : Please mark reply as helpful / correct if it answers your question.

Script include cannot be used, You can however move the deletion part into an event and script action for its execution.

The script will also require lot of optimization like

1) encodedQuery can be used instead of multiple addQuery()

2) You could use updateMultiple() instead of update() within the while loop. This will process the change in a single run instead of different loops on different tables

3) Separating the logic into 2 different parts: 

a) Identifying the duplicates

b) Replacing the CIs on all task

c) Deleting them all together in an event

Lot of rework!

Paul125
Kilo Guru

Thanks for your inputs.

Hello Paul,

If your query is answered, request you to mark a correct answer and close this thread. Thanks!