1

On the Ideas Object, how can I get the child Ideas (merged Ideas) to inherit the Status of the Master Idea if it is changed? The Ideas Object does not have record types.

I tried to create a workflow rule with a field update but there is not an option to reference the child status from the master status. Process builder does not support Ideas yet so there is no option there.

It seems odd to me that nobody else would have come across this issue yet. Doesn't it make sense that the merged Ideas status should update to whatever the Master Ideas status is?

I've created a lookup relationship with Opportunities on Ideas and I wanted to be able to alert Opportunity Owners when an Idea became available so that they can close the loop with our customers.

Does anyone have a suggestion on how I can get the merged Ideas status to inherit the Master Idea when it is changed?

  • You're going to want to create a trigger to run after an update on the master and the status has changed then pick up all the children and update their status after. The problem is, when you have a large amount of children and mass update them, you may hit processing limits on the trigger as well as colliding with other things such as workflows and users in the middle of editing a child record. – AlphaBravo Jun 13 '16 at 18:29
0

Salesforce support trigger on Idea object but they are not fired on merge. A merge operation is a) Populates the parentID field with the idea ID with which it has been merged b) Set isMerged field to true. You can vote for the idea here: https://success.salesforce.com/ideaView?id=08730000000BqSpAAK

Coming back to the solution to your problem. I only see one way to accomplish this is by using batch class approach. A batch class could be build and made to run say every 15 minutes which will take all children ideas and update their statuses to their parents.

Here is the basic code snippet which can be used to update idea status based on the parent idea status:

Batch class:

global class ideaStatusChange implements Database.Batchable<sObject> {
    global Database.QueryLocator start(Database.BatchableContext BC) {
        String query = 'Select Id, IsMerged, parentIdeaId, Status FROM Idea where parentIdeaId != null AND IsMerged = true';
        return Database.getQueryLocator(query);
    }
    public map<Id,Idea> getParentIdeasMap()
    {
        map<Id,Idea> ideaMap = new map<Id,Idea> ([Select Id, IsMerged, parentIdeaId, Status from Idea where (parentIdeaId = '' OR parentIdeaId = null) AND (IsMerged = false)]);   
        return ideaMap;
    }
    global void execute(Database.BatchableContext BC, List<Idea> scope) {
             List <Idea> lstIdeas = (List <Idea> ) scope;
             List <Idea> lstUpdateIdeas = new List <Idea>();
             for(Idea a : lstIdeas)
             {
                 if(a.Status != getParentIdeasMap().get(a.parentIdeaId).status){
                     a.Status = getParentIdeasMap().get(a.parentIdeaId).status; 
                     lstUpdateIdeas.add(a);   
                 }        
             }

             if(lstUpdateIdeas.size() > 0)
                 update lstUpdateIdeas;
           }


    global void finish(Database.BatchableContext BC) {
    }
}

Scheduler Class:

global class schduleBatchIdeaStatusChange implements Schedulable {

   global void execute(SchedulableContext ctx) {
      ideaStatusChange i = new ideaStatusChange();
        database.executeBatch(i);
   }   
}

Snippet to execute from developer console to schedule the batch:

System.schedule('Scheduled Job 1', '0 0 * * * ?', new schduleBatchIdeaStatusChange());
System.schedule('Scheduled Job 2', '0 15 * * * ?', new schduleBatchIdeaStatusChange());
System.schedule('Scheduled Job 3', '0 30 * * * ?', new schduleBatchIdeaStatusChange());
System.schedule('Scheduled Job 4', '0 45 * * * ?', new schduleBatchIdeaStatusChange());

Hope this helps!

| improve this answer | |
  • Hi Shailesh, Thank you so much for your response. Would you be willing to supply the code snippet? Thanks again! – Meghan Gaumond Jun 14 '16 at 22:29
  • @MeghanGaumond I have added the code. Please let me know should you have any questions. Thanks! – Shailesh Patil Jun 15 '16 at 14:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.