• vasantq
  • NEWBIE
  • 0 Points
  • Member since 2013

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

I'm trying to write a trigger than initiates itself when a checkbox is checked.

 

The trigger will basically go and clear some fields in the record. I've already coded this portion:

 

trigger ReparentToNextPlanningWeek on Innovation_Planning__c (before update) {
    for (Innovation_Planning__c IP : Trigger.new) {
        if(IP.Carryover__c == TRUE) {
            IP.Status__c = NULL;
            IP.Percent_Complete__c = NULL;
            IP.Carryover_Count__c = IP.Carryover_Count__c+1;
            IP.Carryover__c = FALSE;
        }
    }
}

 

I also want this trigger to look into the "Planning Week" object, and reparent itself to the next week's planning record. For example, if the current Innovation Planning record exists as a master-detail to the "03-03-2013" Planning Week record, I'd now like for the trigger to be reparented to the "03-10-2013" Planning Week record. Please note that the dates are always 7 days out and occur on Sundays. Perhaps this could be used in the logic?

 

Basically, I have no idea how to write a trigger that reparents itself to another record in the parent object.

 

Can someone please help?

I'm trying to write a trigger than initiates itself when a checkbox is checked.

 

The trigger will basically go and clear some fields in the record. I've already coded this portion:

 

trigger ReparentToNextPlanningWeek on Innovation_Planning__c (before update) {
    for (Innovation_Planning__c IP : Trigger.new) {
        if(IP.Carryover__c == TRUE) {
            IP.Status__c = NULL;
            IP.Percent_Complete__c = NULL;
            IP.Carryover_Count__c = IP.Carryover_Count__c+1;
            IP.Carryover__c = FALSE;
        }
    }
}

 

I also want this trigger to look into the "Planning Week" object, and reparent itself to the next week's planning record. For example, if the current Innovation Planning record exists as a master-detail to the "03-03-2013" Planning Week record, I'd now like for the trigger to be reparented to the "03-10-2013" Planning Week record. Please note that the dates are always 7 days out and occur on Sundays. Perhaps this could be used in the logic?

 

Basically, I have no idea how to write a trigger that reparents itself to another record in the parent object.

 

Can someone please help?