• PeterP
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

Hi,

 

I struggle with a trigger that needs to create new records in an object called POSITION. The records should be created when a record in another object called TRANSACTION are updated or inserted. Then in POSITION I want the field INSTRUMENT to automatically create a record for all instruments that are in the object TRANSACTION (but no duplicates).

 

Can anyone help me with as exemplary code for a trigger? Mine is definitely wrong ;-(

 

trigger UpdatePosition on TRANSACTION__c (after insert, before update, after update) {

Map<ID, TRANSACTION__c> updateMap = new Map<ID, TRANSACTION__C>();

List<POSITION__c> itemList;

set<Id> AllItems = new set<id>();

for(POSITION__c i :itemList){

AllItems.add(i.TRANSACTION__c);

List<TRANSACTION__C> AllTransactions = [SELECT id, INSTRUMENT__c

                   FROM TRANSACTION__C where id in :AllItems];

Hi,

 

I struggle with a trigger that needs to create new records in an object called POSITION. The records should be created when a record in another object called TRANSACTION are updated or inserted. Then in POSITION I want the field INSTRUMENT to automatically create a record for all instruments that are in the object TRANSACTION (but no duplicates).

 

Can anyone help me with as exemplary code for a trigger? Mine is definitely wrong ;-(

 

trigger UpdatePosition on TRANSACTION__c (after insert, before update, after update) {

Map<ID, TRANSACTION__c> updateMap = new Map<ID, TRANSACTION__C>();

List<POSITION__c> itemList;

set<Id> AllItems = new set<id>();

for(POSITION__c i :itemList){

AllItems.add(i.TRANSACTION__c);

List<TRANSACTION__C> AllTransactions = [SELECT id, INSTRUMENT__c

                   FROM TRANSACTION__C where id in :AllItems];