Question
Oleksandr Demchenko · Nov 18

Trigger, Insert after

Hi, how do I create a trigger that will only set the value of the "Status" field for new objects, not for all available?

Class CarDealer.Order Extends (%Persistent, %Populate)
{

 Property Title As %String

 Property Status As %String(VALUELIST = ",InProgress,Done,Canceled");

Trigger setStatus [ Event = INSERT, Foreach = row/object, Time = AFTER ]
{
 &sql(update CarDealer.Order set Status = 'InProgress')
}

Product version: IRIS 2022.1
1
0 199
Discussion (1)0
Log in or sign up to continue

Is that what you want to do, or should you be defining your property as:

Property Status As %String(VALUELIST = ",InProgress,Done,Canceled") [ InitialExpression = "InProgress" ];

This makes InProgress the default status when a new CarDealer.Order is created.