• Ryan-Haire
  • NEWBIE
  • 25 Points
  • Member since 2013

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 8
    Replies
This is probably a very basic question. I'm new to programming and have spend 2 hours on this.
I'm trying to do a cross object field update trigger stamping one object with the CreatedDate of the other object.
The update field on the object I'm trying to update is of type Date.
trigger UpdateQSOCreatedDate on FRLS_Round__c (after insert) {
  	List<ID> QSOTargetIds = New List<ID>();

  for(FRLS_Round__c r : Trigger.new){
    if(r.QSO_Target__c!=null){
      QSOTargetIds.add(r.QSO_Target__c);
    }
  }

  List<QSO_Target__c> QSOTargetList = [SELECT id, Date_Last_Round_Created__c FROM QSO_Target__c WHERE id in :QSOTargetIds];
  for(integer i = 0 ; i < QSOTargetList.size(); i++){
  QSOTargetList[i].Date_Last_Round_Created__c = FRLS_Round__c.CreatedDate;
  }
  update QSOTargetList;
}


How do you convert CreatedDate to a Date field?

I'd like to write a trigger so when an opportunity get's submitted it creates a new record on a custom object for suppression/tracking purposes.

 

The custom object is suppression__c

 

Client-  Master-Detail with Account
Company name-  (pull from Account on Op)
Email domain- (Pull from main contact on Op)
Opportunity-  (Link to Opportunity)
Website- (Pull from Account on Op)
Source- (Picklist- Will always be "QSO")
Type- (Picklist- will always be "Company")

 

Seems like it should be easy enough to do, but can someone point me in the right direction on how to get started?

 

Thanks-

Ryan

This is probably a very basic question. I'm new to programming and have spend 2 hours on this.
I'm trying to do a cross object field update trigger stamping one object with the CreatedDate of the other object.
The update field on the object I'm trying to update is of type Date.
trigger UpdateQSOCreatedDate on FRLS_Round__c (after insert) {
  	List<ID> QSOTargetIds = New List<ID>();

  for(FRLS_Round__c r : Trigger.new){
    if(r.QSO_Target__c!=null){
      QSOTargetIds.add(r.QSO_Target__c);
    }
  }

  List<QSO_Target__c> QSOTargetList = [SELECT id, Date_Last_Round_Created__c FROM QSO_Target__c WHERE id in :QSOTargetIds];
  for(integer i = 0 ; i < QSOTargetList.size(); i++){
  QSOTargetList[i].Date_Last_Round_Created__c = FRLS_Round__c.CreatedDate;
  }
  update QSOTargetList;
}


How do you convert CreatedDate to a Date field?

I'd like to write a trigger so when an opportunity get's submitted it creates a new record on a custom object for suppression/tracking purposes.

 

The custom object is suppression__c

 

Client-  Master-Detail with Account
Company name-  (pull from Account on Op)
Email domain- (Pull from main contact on Op)
Opportunity-  (Link to Opportunity)
Website- (Pull from Account on Op)
Source- (Picklist- Will always be "QSO")
Type- (Picklist- will always be "Company")

 

Seems like it should be easy enough to do, but can someone point me in the right direction on how to get started?

 

Thanks-

Ryan