• mark-az
  • NEWBIE
  • 50 Points
  • Member since 2012

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 10
    Replies

Hello.  I thought I could pull values up to a parent record using a combination of rollups and workflow, but with the order of operations, the rollup happens after my workflow fires, so my totals are one update behind.  To fix this, I thought I could write a trigger that would identify the most recent child record from that object itself.  Just not sure I can even do this. 

 

I wrote the following simple trigger, but nothing is happening.  I am trying to debug now, but could you please let me know if something like this would even be possible?  Thanks in advance.

 

trigger SetMostRecent on Risk_Assessment__c (after insert, after update) {

integer count=1;
String yes='Y';
String no='N';

  for (Risk_Assessment__c n: Trigger.new) {
      String srmtool = n.SRM_Tools__c;  
      // gets ALL assessments for the parent id of the current record
      List<Risk_Assessment__c> listRAs = [Select Id, Most_Recent_Risk_Profile__c from Risk_Assessment__c
                            where SRM_Tools__c=:srmtool order by CreatedDate desc];
                          
      for(Risk_Assessment__c ra : listRAs)
      { 
        if(count==1){
            ra.Most_Recent_Risk_Profile__c=yes;
            update ra;
        }else{
            ra.Most_Recent_Risk_Profile__c=no;
            update ra;
            }   
       
        count++; 
       
      }
  }                          
} //end trigger

Hello.  I am trying to roll up values from a grand-child relationship all the way up to the parent.  I can do this all the way up using roll-ups, but I thought I would be clever and try to do it with the new-ish cross object workflow.  However, I am finding that this takes 2 updates on the 'grandchild' record before it pulls up the changes.  I have read a bit in the forums, and think I understand why this is happening, but it doesn't make a whole lot of sense with how wf works.

 

Here's my basic structure:

 

     Parent (Profile)                            ie. 'Most Recent Grandchild Balance'

           ^

 Child (Financial Info Summary)   ie. 'Most Recent Grandchild Balance'

           ^

Grandchild (Individual Accounts)  ie. Balance

 

I am using rollup fields to bring the 'most recent' grandchild dollar amounts up to the 'Child' level, which works ok.  I created a workflow rule that was set to run whenever the record was updated, and it would just copy the same dollar amounts up to the Parent.

 

By doing it this way, if I create a new 'grandchild' record, the totals at the parent level don't update right away.  If I edit the grandchild record a second time, all of the calculations work.

 

Looking through the 'order of operations' info, I think that the rollups happen almost last, after everything else has run.  This means that the workflow is firing, but is pushing the 'old' values up to the parent the first time, then the rollups happen.  On the second update, the correct values get pulled up.

 

I think to fix this I'm going to just have to give in and create the same rollups at the 'Parent' level.  This cross-object updating doesn't make a whole lot of sense, though, if you try to use it with rollups.  Can someone please agree with this or tell me I'm missing something easy?  Thanks in advance.

Hello, everyone.  I'm fairly new to VF, and think I can do what I'm about to ask, but wanted to make sure before I went too far on it.

 

I've built a few new 'profile' objects off of account.  On my second layer of 'profiles', I'd like to display a related list of all account contacts.  Somewhat like this:

 

Account -< Contact

    ^

Profile Summary

    ^

Config Profile  ** -> This is where I'd like a related list that simply shows all account contacts

 

After reading through the forums quite a bit, it looks like I could possibly create a Controller that would query for account contacts (I think I can create a wf to copy the account id down to the config profile).  Once I had the records, I could create a pretty simple vf related list that shows the fields I'm interested in.

 

This post looked the closest to what I'm thinking of doing: http://boards.developerforce.com/t5/Visualforce-Development/Filter-Data-of-a-Related-List/m-p/95329/highlight/true#M6270

 

Could someone please let me know if this isn't too crazy?  Thanks in advance.

 

Hello.  I'm pretty new to triggers, and am somewhat stuck.  I'm trying to write a trigger that will look at tasks, and if they were created under a case, pull the Case Contact (WhoId) down onto the Task in the 'Name' field.  I have the first piece of logic working which checks to see if the task is related to a case.  When I get to the SOQL query, though, it always returns zero results.  I have tried looking over numerous examples and even hard-coding a case id that should work, but it still comes back empty.  Does anyone have any ideas?  Any assistance would be appreciated, and thanks in advance. Here's the trigger:

 

trigger UpdateCaseTask on Task (before insert, before update)
{

  String tempId;
  String contactId;
  String recType;
  List<Task> newValues = trigger.new;
  List<Id> caseIds = new List<Id>();
  List<Case> caseData = new List<Case>();
  Map<Id,Case> caseMap = new Map<Id,Case>();
  Boolean haveCases = false;

 

// This for look checks the tasks to see if they are tied to a case
for (Task newValue: newValues){
  tempId=newValue.WhatId;
  if(tempId.substring(0,4)=='500R') {
    caseIds.add(tempId);  
    haveCases = true;
    }   
}
// If we have activities that are tied to cases, query for the case information
if (haveCases) { 
       caseData=[Select Id,ContactId,RecordTypeId from Case where Id in: caseIds];
       for (Case c:caseData) {   
           caseMap.put(c.Id,c);
           }  
}    
// Rebuild the list of tasks that need updates   
   for (Task newValue: NewValues) {
       tempId=newValue.WhatId;
       contactId=newValue.WhoId;
 system.debug ('trying to update Task '+caseMap.get(tempId).ContactId);  
 system.debug ('filling in task');  
       if(tempId.substring(0,4)=='500R') {
           contactId=caseMap.get(tempId).ContactId;
       }
      }
}

Hello, everyone.  I am trying to create a workflow rule that looks for the string 'SIA' in the subject of a task.  I set this up as " SIA " so that it would only flag this string, and not include it if it was part of another word (ie., don't flag 'Asia', for instance).  I used 'contains' as the rule criteria.

 

However, when I run the rule, it is incorrectly flagging tasks that have sia anywhere in the subject line.  If the subject is 'test SIA test', it works like I would expect.  If the subject is 'test ASIA test', though, it is catching and flagging this as well. 

 

I tried creating a more complex rule that said 'CONTAINS(TEXT(Subject)," SIA "), but when I try to save it I get a strange error about how text expects a number or date, but not a picklist.  I saw that others in the boards had a similar problem with a workflow rule trigger, but couldn't find any other solutions to this.


Does anyone have any thoughts?  Thanks in advance.

Hello.  I thought I could pull values up to a parent record using a combination of rollups and workflow, but with the order of operations, the rollup happens after my workflow fires, so my totals are one update behind.  To fix this, I thought I could write a trigger that would identify the most recent child record from that object itself.  Just not sure I can even do this. 

 

I wrote the following simple trigger, but nothing is happening.  I am trying to debug now, but could you please let me know if something like this would even be possible?  Thanks in advance.

 

trigger SetMostRecent on Risk_Assessment__c (after insert, after update) {

integer count=1;
String yes='Y';
String no='N';

  for (Risk_Assessment__c n: Trigger.new) {
      String srmtool = n.SRM_Tools__c;  
      // gets ALL assessments for the parent id of the current record
      List<Risk_Assessment__c> listRAs = [Select Id, Most_Recent_Risk_Profile__c from Risk_Assessment__c
                            where SRM_Tools__c=:srmtool order by CreatedDate desc];
                          
      for(Risk_Assessment__c ra : listRAs)
      { 
        if(count==1){
            ra.Most_Recent_Risk_Profile__c=yes;
            update ra;
        }else{
            ra.Most_Recent_Risk_Profile__c=no;
            update ra;
            }   
       
        count++; 
       
      }
  }                          
} //end trigger

Hello, everyone.  I'm fairly new to VF, and think I can do what I'm about to ask, but wanted to make sure before I went too far on it.

 

I've built a few new 'profile' objects off of account.  On my second layer of 'profiles', I'd like to display a related list of all account contacts.  Somewhat like this:

 

Account -< Contact

    ^

Profile Summary

    ^

Config Profile  ** -> This is where I'd like a related list that simply shows all account contacts

 

After reading through the forums quite a bit, it looks like I could possibly create a Controller that would query for account contacts (I think I can create a wf to copy the account id down to the config profile).  Once I had the records, I could create a pretty simple vf related list that shows the fields I'm interested in.

 

This post looked the closest to what I'm thinking of doing: http://boards.developerforce.com/t5/Visualforce-Development/Filter-Data-of-a-Related-List/m-p/95329/highlight/true#M6270

 

Could someone please let me know if this isn't too crazy?  Thanks in advance.

 

Hello.  I'm pretty new to triggers, and am somewhat stuck.  I'm trying to write a trigger that will look at tasks, and if they were created under a case, pull the Case Contact (WhoId) down onto the Task in the 'Name' field.  I have the first piece of logic working which checks to see if the task is related to a case.  When I get to the SOQL query, though, it always returns zero results.  I have tried looking over numerous examples and even hard-coding a case id that should work, but it still comes back empty.  Does anyone have any ideas?  Any assistance would be appreciated, and thanks in advance. Here's the trigger:

 

trigger UpdateCaseTask on Task (before insert, before update)
{

  String tempId;
  String contactId;
  String recType;
  List<Task> newValues = trigger.new;
  List<Id> caseIds = new List<Id>();
  List<Case> caseData = new List<Case>();
  Map<Id,Case> caseMap = new Map<Id,Case>();
  Boolean haveCases = false;

 

// This for look checks the tasks to see if they are tied to a case
for (Task newValue: newValues){
  tempId=newValue.WhatId;
  if(tempId.substring(0,4)=='500R') {
    caseIds.add(tempId);  
    haveCases = true;
    }   
}
// If we have activities that are tied to cases, query for the case information
if (haveCases) { 
       caseData=[Select Id,ContactId,RecordTypeId from Case where Id in: caseIds];
       for (Case c:caseData) {   
           caseMap.put(c.Id,c);
           }  
}    
// Rebuild the list of tasks that need updates   
   for (Task newValue: NewValues) {
       tempId=newValue.WhatId;
       contactId=newValue.WhoId;
 system.debug ('trying to update Task '+caseMap.get(tempId).ContactId);  
 system.debug ('filling in task');  
       if(tempId.substring(0,4)=='500R') {
           contactId=caseMap.get(tempId).ContactId;
       }
      }
}