@@ -86,6 +86,7 @@ public class TriggerScriptTest extends BaseWebDriverTest
8686
8787 private static final String COMMENTS_FIELD = "Comments" ;
8888 private static final String COUNTRY_FIELD = "Country" ;
89+ public static final String PEOPLE_LIST_NAME = "People" ;
8990
9091 protected final PortalHelper _portalHelper = new PortalHelper (this );
9192
@@ -171,6 +172,7 @@ public static void projectSetup()
171172 init .doSetup ();
172173 }
173174
175+
174176 protected void doSetup ()
175177 {
176178 _containerHelper .createProject (getProjectName (), null );
@@ -188,10 +190,11 @@ protected void doSetup()
188190
189191 _listHelper .createList (getProjectName (), LIST_NAME , "Key" , columns );
190192
191- log ("Create list in subfolder to prevent query validation failure " );
192- _listHelper .createList (getProjectName (), "People" , "Key" ,
193+ log ("Create the People list " );
194+ _listHelper .createList (getProjectName (), PEOPLE_LIST_NAME , "Key" ,
193195 new FieldDefinition ("Name" , ColumnType .String ).setDescription ("Name" ),
194196 new FieldDefinition ("Age" , ColumnType .Integer ).setDescription ("Age" ),
197+ new FieldDefinition ("FavoriteDateTime" , ColumnType .DateAndTime ).setDescription ("Favorite date time. Who doesn't have one?" ),
195198 new FieldDefinition ("Crazy" , ColumnType .Boolean ).setDescription ("Crazy?" ));
196199
197200 importFolderFromZip (TestFileUtils .getSampleData ("studies/LabkeyDemoStudy.zip" ));
@@ -301,7 +304,38 @@ public void testListImportTriggers()
301304 cleanUpListRows ();
302305 }
303306
307+ /** Issue 52098 - ensure trigger scripts have a chance to do custom type conversion with the incoming row */
304308 @ Test
309+ public void testListAPITriggerTypeConversion () throws Exception
310+ {
311+ Connection cn = WebTestHelper .getRemoteApiConnection ();
312+
313+ // Insert a row with a value that can only be handled by the trigger script to make sure it gets a chance
314+ // to do the conversion. People.js should strip the "RemoveMe" prefix from Age and FavoriteDateTime
315+ InsertRowsCommand insCmd = new InsertRowsCommand (LIST_SCHEMA , PEOPLE_LIST_NAME );
316+ insCmd .addRow (Map .of ("Name" , "Jimbo" , "Age" , "RemoveMe25" , "FavoriteDateTime" , "RemoveMe2025-06-11 11:42" , "Crazy" , "true" ));
317+ SaveRowsResponse insResp = insCmd .execute (cn , getProjectName ());
318+ List <Map <String , Object >> insertedRows = insResp .getRows ();
319+ Assert .assertEquals (1 , insertedRows .size ());
320+
321+ Map <String , Object > insertedRow = insertedRows .get (0 );
322+ Assert .assertEquals ("Jimbo" , insertedRow .get ("Name" ));
323+ Assert .assertEquals (25 , insertedRow .get ("Age" ));
324+ Assert .assertEquals ("2025-06-11 11:42:00.000" , insertedRow .get ("FavoriteDateTime" ));
325+
326+ // Validate update too
327+ UpdateRowsCommand upCmd = new UpdateRowsCommand (LIST_SCHEMA , PEOPLE_LIST_NAME );
328+ insertedRow .put ("Age" , "RemoveMe26" );
329+ upCmd .addRow (insertedRow );
330+ SaveRowsResponse upResp = upCmd .execute (cn , getProjectName ());
331+ List <Map <String , Object >> updatedRows = upResp .getRows ();
332+ Assert .assertEquals (1 , updatedRows .size ());
333+
334+ Map <String , Object > updatedRow = updatedRows .get (0 );
335+ Assert .assertEquals (26 , updatedRow .get ("Age" ));
336+ }
337+
338+ @ Test
305339 public void testListAPITriggers () throws Exception
306340 {
307341 String ssn1 = "111111112" ;
0 commit comments