Triggers: Difference between revisions

121 bytes added ,  10 November 2016
m
no edit summary
mNo edit summary
mNo edit summary
Line 395: Line 395:
The user will enter the value in PriceUSD and the value in Euros will appear in PriceEUR according to the current exchange rate.
The user will enter the value in PriceUSD and the value in Euros will appear in PriceEUR according to the current exchange rate.


We will create a Trigger on Event '''Create an entry to Add''' and Phase '''After saving the entry'''.
:; Add new trigger: Set Event '''Create an entry to Add''' and Phase '''After saving the entry'''. It will run asynchronously.


:<small>'''Trigger script:'''</small>
:'''Trigger script:'''
<source lang="javascript">
<source lang="javascript">
result = http().get("http://api.fixer.io/latest?base=USD"); // Use http://fixer.io/ for
result = http().get("http://api.fixer.io/latest?base=USD"); // Use http://fixer.io/ for
Line 407: Line 407:
                                                             // for value for PriceEUR
                                                             // for value for PriceEUR
</source>
</source>
 
<br/>
-----
-----
==== Creating a Task in the Todoist App ====
==== Creating a Task in the Todoist App ====
Line 413: Line 413:
In the following example of task creation, text will be taken from the Memento library entry.
In the following example of task creation, text will be taken from the Memento library entry.


:<small>'''Trigger script:'''</small>
:; Add a new trigger: Set Event to '''Creating a new entry''' or perhaps '''Update an entry'''. Set Phase as appropriate.
:'''Trigger script:'''
<source lang="javascript">
<source lang="javascript">
// Create a JSON command for Todoist task creation
// Create a JSON command for Todoist task creation