In this topic Hide
This help page provides sample trigger scripts to create or update Significant Events for some common scenarios. You can use these as a reference when defining your own rules in JavaScript. Dates are provided as an example; change these to suit your needs.
This script will create a Significant Event when the project Status is changed to Approved. Dates are only an example, you should change these to suit your scenario.
Sample script:
if(Core.Status == 'Approved') { var SigEvent = {Action_Date:'03/11/2022', Event_Type:'Custom', Event: 'Application sent to Sponsor', Name: 'Sample Event Name', Status: 'Active', Est_Complete_Date: '31/10/2022', Act_Complete_Date: '28/10/2022', Status2: 'Draft', Completion_Percentage: '10' Event_Details: 'Sample Event Details', Interval_Type: 'Fortnightly', Num_Of_Times: 4, Responsibilty: 'Committee', Completion_Details: 'Not yet Completed' }; SIGEVENT.Create(SigEvent); } if(Core.Status == 'Completed') { SIGEVENT.Update({Event_Type:'Custom', Event: 'Application sent to Sponsor', Name: 'Test Event Name', },{ Status: 'Complete'}); } |
This script will create a Significant Event when the project Type is Grant and the Status is changed to Approved. The date is only an example, you should change it to suit your scenario.
Sample script:
if(Project.Project_Status_Code == 'APPROVED'
&& Project.Project_Type_Code == 'GRANT') { var SigEvent = {Action_Date:Project.Date_Start, Event_Type:'C1', Event: 'APPSPONSOR', Name: 'Test Event for proj type and status before update', Status: 'Active', Est_Complete_Date: '31/10/2022', Status2: 'Draft', Completion_Percentage: '10', Event_Details: 'Sample Event Details', Responsibility: 'ASSESSOR' }; SIGEVENT.Create(SigEvent); } |
This script will create a Significant Event when the project Type field in a core record is Grant with an old Status of Draft, and a new Status of Approved. The date is only an example, you should change it to suit your scenario.
Note that this script will not work
for an eForm as the old status cannot be identified.
Sample script:
if(Projectold.Project_Status_Code == 'DRAFT'
&& Project.Project_Status_Code == 'APPROVED' &&
Project.Project_Type_Code == 'GRANT') { var SigEvent = {Action_Date:Project.Date_Start, Event_Type:'C1', Event: 'APPSPONSOR', Name: 'Test Event for proj type and status before update', Status: 'Active', Est_Complete_Date: '03/10/2022', Status2: 'Draft', Completion_Percentage: '10', Event_Details: 'Sample Event Details', Responsibility: 'ASSESSOR' }; SIGEVENT.Create(SigEvent); } |
This script will create a Significant Event when the project Type is either Grant or Consultancy. This is done using the OR condition (||). The date is only an example, you should change it to suit your scenario.
Sample script:
if(Project_Type_Code == 'GRANT ' || Project.Project_Type_Code
== 'CONSULTANC') { var SigEvent = {Action_Date:Project.Date_Start, Event_Type:'C1', Event: 'APPSPONSOR', Name: 'Test Event for proj type with or cond before update', Status: 'Active', Est_Complete_Date: '03/10/2022', Status2: 'Draft', Completion_Percentage: '10', Event_Details: 'Sample Event Details', Responsibility: 'ASSESSOR' }; SIGEVENT.Create(SigEvent); } |
This script will create three separate Significant Events when the project Type is Grant and the Status is Approved. The dates are only an example, you should change them to suit your scenario.
Sample script:
if(Project.Project_Status_Code == 'APPROVED'
&& Project.Project_Type_Code == 'GRANT') { var SigEvent = {Action_Date:Project.Date_Start, Event_Type:'C1', Event: 'APPSPONSOR', Name: 'Test Event 1 for proj type and status before update', Status: 'Active', Est_Complete_Date: '03/10/2022', Status2: 'Draft', Completion_Percentage: '10', Event_Details: 'Sample Event Details', Responsibility: 'ASSESSOR' }; var SigEvent2 = {Action_Date:Project.Date_Start, Event_Type:'C1', Event: 'APPSPONSOR', Name: 'Test Event 2 for proj type and status before update', Status: 'Active', Est_Complete_Date: '03/10/2022', Status2: 'Draft', Completion_Percentage: '10', Event_Details: 'Sample Event Details', Responsibility: 'ASSESSOR' }; var SigEvent3 = {Action_Date:Project.Date_Start, Event_Type:'C1', Event: 'APPSPONSOR', Name: 'Test Event 3 for proj type and status before update', Status: 'Active', Est_Complete_Date: '03/10/2022', Status2: 'Draft', Completion_Percentage: '10', Event_Details: 'Sample Event Details', Responsibility: 'ASSESSOR' }; SIGEVENT.Create(SigEvent); SIGEVENT.Create(SigEvent2); } |
This script will find projects records that have not had any activity of a particular event type and will create a Significant Event. For example, if a project does not have student leave events, create them. The date is only an example, you should change it to suit your scenario.
Sample script:
var sigEvent = { Event_Type:'C1' }; var result = SIGEVENT.find(sigEvent); if(result == null) { var SigEvent = {Action_Date:Project.Date_Start, Event_Type:'C1', Event: 'APPSPONSOR', Name: 'Test Event create if no record found before update', Status: 'Active', Est_Complete_Date: '03/10/2022', Status2: 'Draft', Completion_Percentage: '10', Event_Details: 'Sample Event Details', Responsibility: 'ASSESSOR' }; SIGEVENT.Create(SigEvent); } |
This script will create a Significant Event when the action date is three months after the project Start Date, and the project Type is Consultancy and the Status is Grant. The date is only an example, you should change it to suit your scenario.
Sample script:
if(Project.Project_Status_Code == 'GRANT'
&& Project.Project_Type_Code == 'CONSULTANC') { var mydt = new Date(Project.Date_Start); mydt.setMonth(mydt.getMonth() + 3); var SigEvent = {Action_Date:mydt, Event_Type:'C1', Event: 'APPSPONSOR', Name: 'Test Event 1 for proj type and status before update', Status: 'Active', Est_Complete_Date: '03/10/2022', Status2: 'Draft', Completion_Percentage: '10', Event_Details: 'Sample Event Details', Responsibility: 'ASSESSOR' }; SIGEVENT.Create(SigEvent); } |
This script will find all Significant Events for specified criteria and for events that match it will perform an action based on a field property. In this sample case, it will look for all events of the Type C1 for a project and if any do not have the Completed status it will create an event. The date is only an example, you should change it to suit your scenario.
Note: If you want to change the Status to Cancelled for an event with scheduled emails, a Confirmation popup is normally displayed in the user interface to inform the user that future scheduled emails will not be sent and asks the user to confirm the update. In the case of the trigger, a response will be automatically added to allow the update to continue.
Sample script:
var sigEvent = { Event_Type:'C1' }; var results = SIGEVENT.FindAll(sigEvent); results.forEach(function(signevnt) { if(signevnt.Status != 'COMPLETED') { var SigEvent = {Action_Date:Project.Date_Start, Event_Type:'MILESTONE', Event: 'APPSPONSOR', Name: 'Test Event for EACH before update', Status: 'ACTIVE', Est_Complete_Date: '03/10/2022', Status2: 'Draft', Completion_Percentage: '10', Event_Details: 'Sample Event Details', Responsibility: 'ASSESSOR' }; SIGEVENT.Create(SigEvent); } } ); |
This script will find all Significant Events for specified criteria (in this case, Type = C1) and for the matching events it will perform an update action based on a field property. In this case, it will look for project events that do not have the Status = Completed and update them to be Completed.
Note: If you want to change the Status to Cancelled for an event with scheduled emails, a Confirmation popup is normally displayed in the user interface to inform the user that future scheduled emails will not be sent and asks the user to confirm the update. In the case of the trigger, a response will be automatically added to allow the update to continue.
Sample script:
var sigEvent = { Event_Type:'C1' }; var results = SIGEVENT.FindAll(sigEvent); results.forEach(function(signevnt) { if(signevnt.Event_Type == 'C1') { var SigEvent = { Status: 'COMPLETED', }; var sigold = signevnt; SIGEVENT.Update(SigEvent,sigold); } } ); |
This script will find all Significant Events and perform an update action based on a field property (in this case, Status = Completed) to them all.
Sample script:
var results = SIGEVENT.FindAll(); results.forEach(function(signevnt) { if(signevnt.Event_Type == 'C1') { var SigEvent = { Status: 'COMPLETED', }; SIGEVENT.Update(SigEvent,signevnt); } } ); |
This script will create Significant Events with emails (in this case, specify the actual email template eCode for "TemplateECODE"). The dates are only an example, you should change them to suit your scenario.
Sample script:
var varSigEvent = {Action_Date:'03/10/2022', Event_Type:'MILESTONE', Event: 'APPOUTCOME', Name: 'Event for project type and status before update', Status: 'Active', Est_Complete_Date: '31/10/2022', Completion_Percentage: '10', Event_Details: 'Sample Event Details', Responsibility: 'ASSESSOR', Email_Template_Code: 'TemplateECODE', Interval_Type: 'WEEKLY', Num_Of_Times: 4 } ; SIGEVENT.Create(varSigEvent); |
This script will create Significant Events and automatically link to a known parent Significant Event based on defined criteria, such as date.
Sample script:
var _Action_Date = new Date(null); var _Est_Complete_Date = new Date(null); var _Event_Type = ''; var _Child_Event_Type = ''; var _Event = ''; var _Name = ''; var _Child_Event_Name = 'First Review'; var _Status = 'ACTIVE'; var _Email_Template = ''; var ParentEvent = null; var ChildEvent = null; _Action_Date = new Date(CourseEnrolment.Enrolment_Date); _Est_Complete_Date = new Date(_Action_Date); _Email_Template = 'HDR PR COC - Final Email Reminder'; _Event_Type = 'ProgReview' _Event= 'Pre-COC'; _Name = 'Pre-Confirmation of Candidature Review'; _Child_Event_Type = 'MILESTONE'; var SigEvent = { Action_Date:_Action_Date, Event_Type:_Event_Type, Event: _Event, Name: _Name, Status: _Status, Est_Complete_Date: _Est_Complete_Date, Event_Details: _Name, Email_Template_Code: _Email_Template }; ParentEvent = SIGEVENT.Create(SigEvent); _Child_Event_Type = 'MILESTONE'; var SigEventChild = { Action_Date:_Action_Date, Event_Type:_Child_Event_Type, Event: _Event, Name: _Child_Event_Name, Status: _Status, Est_Complete_Date: _Est_Complete_Date, Event_Details: _Child_Event_Name, Parent_Event: ParentEvent.Name, Parent_Event_Action_Date: ParentEvent.Action_Date, Email_Template_Code: _Email_Template }; ChildEvent = SIGEVENT.Create(SigEventChild); |
This sample script will change a Project Significant Event Status as Completed and update the Completed Date field with the current date when the Status is not Completed and either a) Status2 = Sent or Requirements Completed? = Yes.
Sample script:
if (SIGEVENT.Status!="COMPLETED" SIGEVENT.Act_Complete_Date=SystemDate; |
Note that you cannot add a script using the above objects and items in another type of application trigger (one triggered by a change to a core record field). These are exclusively for use in triggers based on changes in a Significant Event (Module = Contracts or Projects, Page = Significant Events).
This sample script will change a Contract Significant Event Status to Completed and update the Completed Date field with the current date when either the Invoice Status = Sent or Requirements Completed? = Yes.
Sample script:
if (SIGEVENT.Status!="COMPLETED" SIGEVENT.Act_Complete_Date=SystemDate; SIGEVENT.UpdateSigEvent(); |
Note that you cannot add a script using the above objects and items in another type of application trigger (one triggered by a change to a core record field). These are exclusively for use in triggers based on changes in a Significant Event (Module = Contracts or Projects, Page = Significant Events).
This sample script will change a Contract Significant Event Status to Completed and update the Completed Date field with the current date when the Status was not Completed and either a) Invoice Status was previously not Sent and was then changed to Sent, or b) Requirements Completed? was previously No and was then changed to Yes.
Sample script:
if (SIGEVENT.Status!="COMPLETED" |
Note that you cannot add a script using the above objects and items in another type of application trigger (one triggered by a change to a core record field). These are exclusively for use in triggers based on changes in a Significant Event (Module = Contracts or Projects, Page = Significant Events).
Product Key: Modules - Application Trigger
Page ID: Application_trigger_samples.htm