File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
Server-Side Components/Business Rules/Sync Integer Field Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change 1212 tableRecord . query ( ) ;
1313
1414 while ( tableRecord . next ( ) ) {
15- projectList . push ( tableRecord . sys_id . toString ( ) ) ;
15+ recordList . push ( tableRecord . sys_id . toString ( ) ) ;
1616 }
1717
18+ //Condition check to make sure the record has a value to add to the arry in the correct spot, otherwise no reason to splice the array
19+ if ( current . { { insert name of integer field you want to sync } } != '' ) {
20+ var index = current . { { insert name of integer field you want to sync } } - 1 ; //Making this one less so it will get added first
21+ recordList . splice ( index , 0 , current . sys_id . toString ( ) ) ; //This will insert our record into the correct position it needs to be in the list
22+ }
1823
19-
24+ //Reassigning the integer sequentially
25+ for ( var i = 0 ; i < recordList . length ; i ++ ) {
26+ if ( recordList [ i ] == current . sys_id . toString ( ) ) {
27+ current . { { insert name of integer field you want to sync } } = i + 1 ;
28+ } else {
29+ var updatedTableRecord = new GlideRecord ( tableName ) ;
30+ if ( updatedTableRecord . get ( recordList [ i ] ) ) {
31+ updatedTableRecord . { { insert name of integer field you want to sync } } = i + 1 ;
32+ updatedTableRecord . setWorkflow ( false ) ; //Setting the workflow false since we dont want the flow to get triggered since all we are doing is updating the integer field
33+ updatedTableRecord . update ( )
34+ }
35+ }
2036
2137
2238} ) ( current , previous ) ;
You can’t perform that action at this time.
0 commit comments