# Problem with invokeLater

**URL:** <https://forum.inductiveautomation.com/t/problem-with-invokelater/20709>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [November 9, 2018, 12:47pm UTC](https://forum.inductiveautomation.com/t/problem-with-invokelater/20709 "2018-11-09T12:47:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrea.montresor](https://avatars.discourse-cdn.com/v4/letter/a/5f9b8f/32.png) [@andrea.montresor](https://forum.inductiveautomation.com/u/andrea.montresor)\
**Post date:** [November 9, 2018, 12:47pm UTC](https://forum.inductiveautomation.com/t/problem-with-invokelater/20709/1 "2018-11-09T12:47:17Z")

</div>

Hi,

we have actually a problem with the function invokeLater.  
We are trying to call a GLOBAL SCRIPT called "Reader" with the function "readAll" that is like this:

> def readAll(ip,db):   
> dtNow = system.tag.read("[System]Gateway/CurrentDateTime").getValue();  
> minutes= dtNow.getMinutes();
> 
> def later():  
> now = system.tag.read("[System]Gateway/CurrentDateTime").getValue()  
> call = system.db.createSProcCall("usp\_Write\_Log\_Ignition", db)
> 
> ```
> procedure_name= "Ignition_Log"
> call.registerInParam("ID_PROCEDURE_NAME", system.db.VARCHAR, procedure_name)
> message_type = 0
> call.registerInParam("ID_MESSAGE_TYPE", system.db.INTEGER, message_type)
> call.registerInParam("DS_MESSAGE", system.db.VARCHAR, 'test1')
> call.registerInParam("DT_PROCEDURE_TIMESTAMP", system.db.TIMESTAMP, now)
>  
> system.db.execSProcCall(call)  
> 
> ```
> 
> system.util.invokeLater(later,10000)

When we call the global script from a Tag value changed (with shared.Reader.readAll("", "dbscada")), we have this error:  
**AttributeError: 'com.inductiveautomation.ignition.common.script.Scr' object has no attribute 'invokeLater'**

We need to log a string, but we need to wait 10 seconds after the tag changed, so we used the invokeLater.

Could you please help us to solve this problem?

Thanks  
Andrea

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [November 9, 2018, 12:52pm UTC](https://forum.inductiveautomation.com/t/problem-with-invokelater/20709/2 "2018-11-09T12:52:22Z")

</div>

`invokeLater` is only available in the client and designer scopes because it is specifically for launching a task on the EDT, the thread that runs the UI.

You probably need to use `invokeAsynchronous` and a call to `sleep` (yuck):  
[https://docs.inductiveautomation.com/display/DOC79/system.util.invokeAsynchronous](https://docs.inductiveautomation.com/display/DOC79/system.util.invokeAsynchronous)
