Triggers: Difference between revisions

395 bytes added ,  10 November 2016
m
no edit summary
mNo edit summary
mNo edit summary
Line 236: Line 236:
===== New entry in one library triggers new entry in another =====
===== New entry in one library triggers new entry in another =====
Suppose that after a new application for membership is validated, a new member should be created. We have libraries Applications & Members. After a new Applications entry is entered and before it is saved, we want to validate the application, and if it passes, we want to create a new entry in Members.
Suppose that after a new application for membership is validated, a new member should be created. We have libraries Applications & Members. After a new Applications entry is entered and before it is saved, we want to validate the application, and if it passes, we want to create a new entry in Members.
:; Note: The Applications library must be permitted to access other libraries. Within Triggers, press the shield icon to view Permission settings.
:; Note — Set library permission: The Applications library must be permitted to access other libraries. Within Triggers, press the shield icon to view Permission settings.
:; Note — Add new trigger: Add a new trigger to the Applications library. Set Event '''Creating a new entry''', Phase '''Before saving the entry'''. (A similar script could be set for Event '''Updating an entry''' Phase '''Before saving the entry''', but only if a change in a field value is to trigger the add of the new member.)


:    '''Trigger script:'''
<source lang="javascript">
<source lang="javascript">
// Get the application entry that's being saved and call it e
// Get the application entry that's being saved and call it e