• Casey Hardesty 10
  • NEWBIE
  • 40 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 3
    Replies
I'm running into an issue with a workflow rule I created recently. Before I get into the specifics, I did reach out to Salesforce support and their reply was the error I'm getting for the workflow rule somehow has something to do with a Trigger related to the same object. Because I don't have premium support, that was all he could help with.

So here is the details:

The Error

Subject: Salesforce workflow could not perform a pending action
Details:
Object Type: Shipping

Record: S-306653
https://na6.salesforce.com/a0T8000000B5wWY

Workflow Rules attempted: add to Shipping Delivered campaign after 10/days
https://na6.salesforce.com/01Q80000000iYVn

Workflow Actions attempted: 10 day undelivered = true
https://na6.salesforce.com/04Y800000005bDd

Error Number: 714219628-12693 (1918307596)

Workflow Rule
Evaluation Criteria: Evaluate the rule when a record is created, and any time it's edited to subsequently meet criteria
Rule Criteria
AND(!ISBLANK( Tracking_Url__c ), ISBLANK( Error_Message_textarea__c ), Status_Code__c != "D" )
Time-Dependent Workflow Action
After 10 days from Created Date, Field update - update a boolean field to True

Trigger on Shipping__c object (supposedly what is causing the issue)

trigger ShippingTrigger on Shipping__c (after insert, after update, before insert) {
       Boolean isContact = False;
       Id leadOrContactId = Null;
       List<CampaignMember> cm = new List<CampaignMember>();
       List<Lead> l = new List<Lead>();
       List<Contact> c = new List<Contact>();
       DateTime myDate = system.now();
       String createdByName = '';
       if (Trigger.isAfter && Trigger.isUpdate) {
            for (Shipping__c s: trigger.new) {
                createdByName = s.CreatedByName__c;
                System.debug(createdByName);
                if ((Trigger.oldMap.get(s.Id).Status_Code__c != 'D' && s.Status_Code__c == 'D') || (Trigger.oldMap.get(s.Id).X10_Day_Undelivered__c == False && s.X10_Day_Undelivered__c == True)) {
                     if (s.Contact__c != Null) {
                          isContact = True;
                          leadOrContactId = s.Contact__c;
                          System.debug('First If: ' + leadOrContactId);
                      } else if (s.Lead__c != Null) {
                         leadOrContactId = s.Lead__c;
                         System.debug('First Else If: ' + leadOrContactId);
               } System.debug(isContact);
               if (isContact == True) {
                      cm = [Select Id, ContactId, CampaignId FROM CampaignMember WHERE CampaignId = '70180000001FPAn' AND ContactId = :leadOrContactId];
                } else if (isContact == False) {
                      cm = [Select Id, LeadId, CampaignId FROM CampaignMember WHERE CampaignId = '70180000001FOXJ' AND LeadId = :leadOrContactId];
                }
                if (cm.size() > 0 && isContact == False && leadOrContactId != Null) {
                     l = [Select Id, Package_Delivered_Date_Time__c, Shipping_Createdby__c FROM Lead WHERE Id = :leadOrContactId LIMIT 1];
                     if (l.size() > 0) { for (Lead ld: l) {
                          ld.Package_Delivered_Date_Time__c = myDate;
                          ld.Shipping_Createdby__c = createdByName;
                      }
                Update l;
                }
             } else if (cm.size() > 0 && isContact == True && leadOrContactId != Null) {
                   c = [Select Id, Package_Delivered_Date_Time__c, Shipping_Createdby__c FROM Contact WHERE Id = :leadOrContactId LIMIT 1];
                   if (c.size() > 0) {
                      for (Contact cs: c) {
                          cs.Package_Delivered_Date_Time__c = myDate;
                          cs.Shipping_Createdby__c = createdByName;
                      }
                      Update c;
                  }
             } else if (isContact == True && leadOrContactId != Null) {
                 c = [Select Id, Package_Delivered_Date_Time__c, Shipping_Createdby__c FROM Contact WHERE Id = :leadOrContactId LIMIT 1];
                 if (c.size() > 0) {
                    for (Contact cs: c) {
                        cs.Package_Delivered_Date_Time__c = myDate;
                        cs.Shipping_Createdby__c = createdByName;
                     } Update c;
                  }
                  CampaignMember mem = new CampaignMember(campaignid = '70180000001FPAn', contactId = leadOrContactId);
                   insert mem;
               } else if (isContact == False && leadOrContactId != Null) {
                    l = [Select Id, Package_Delivered_Date_Time__c, Shipping_Createdby__c FROM Lead WHERE Id = :leadOrContactId LIMIT 1];
                    if (l.size() > 0) { for (Lead ld: l) {
                        ld.Package_Delivered_Date_Time__c = myDate;
                        ld.Shipping_Createdby__c = createdByName;
                    }
                    Update l;
                }
                CampaignMember mem = new CampaignMember(campaignid = '70180000001FOXJ', leadid = leadOrContactId);
                insert mem;
                }
             }
           }
         }
         if (Trigger.isBefore && Trigger.isInsert) {
             for (Shipping__c s: trigger.new) {
                 if (s.Material_Short_Code__c == 'Pak_NA' ) {
                   s.Mail_Class__c = 'First'; s.Parcel_Type__c = 'Parcel';
                 } else if (s.Material_Short_Code__c == 'Pak_APPT' ) {
                    s.Mail_Class__c = 'Priority';
                    s.Parcel_Type__c = 'FlatRateEnvelope';
                 } else if (s.Material_Short_Code__c == 'GC-20'){
                    s.Mail_Class__c = 'First'; s.Parcel_Type__c = 'Parcel';
                 } else {
                   s.Mail_Class__c = 'Priority';
                   s.Parcel_Type__c = 'FlatRateEnvelope';
                 }
               }
             }
             List<Gift_Card__c> toUpdate = new List<Gift_Card__c>();
             for (Shipping__c s : trigger.new) { // assumes a gift card can only be associated with 1 shipping record
                 if (s.Is_Printed__c && s.Gift_Card__c != null && (trigger.isinsert || !trigger.oldmap.get(s.Id).Is_Printed__c)) {
                  toUpdate.add(new Gift_Card__c(Id = s.Gift_Card__c, Status__c = 'Issued'));
                  }
              }
              if (!toUpdate.isEmpty()) update toUpdate;
     } 

     Ok, anybody have any ideas. Thank you in advance for any help you may provide.
Hey everybody,

I'm running into a challenge that is probably very easy but I'm struggling with it. I need to write a SOQL query that will simple pull all Leads not attached to a Campaign. Here is what I've come up with so far but it is definitely not working...

SELECT Id, (Select Id From CampaignMembers WHERE Id = Null) FROM Lead WHERE CreatedDate >= 2016-03-13T00:00:00Z

When I go through the results, most of these are indeed attached to a campaign so not sure what I'm doing wrong.

Any ideas? Thanks in advance.
So, I'm tasked with a project and need some general guidance. Basically, here is what I am trying to accomplish...

1. Our Org has a custom object that when created, I would like to fire off a trigger
2. The Trigger (or class that the trigger calls) would then find the subscriber (because they should already exist in Exact Target) and add that subscriber to an existing List in Exact Target. 

My question is... Can this be done with Apex code? I've read the documentation around adding subscribers to a list using the API but I haven't found any examples using APEX. I guess the other option would be to Invoke a Callout?

Thoughts? Thanks in advance for your time and effort.

Casey 
I'm trying to build a simple visual force chart but am running into roadblocks on the couple ways I've tried to accomplish the task. First off, here is the relevant code from controller and page.

// Controller method
public List<annuityChartWrap> annuityChartList = new List<annuityChartWrap>();
public List<annuityChartWrap> getAnnuityChart() {
        AggregateResult[] AgR = [SELECT Hot_Rate__c, SUM(Annuity_Investment__c) sumAnnuity FROM Account WHERE OwnerId=:userid GROUP BY Hot_Rate__c];
        for (AggregateResult AnnuityTotals : AgR) {
            annuityChartList.add(new annuityChartWrap(Integer.valueOf(AnnuityTotals.get('Hot_Rate__c')), Integer.valueOf(AnnuityTotals.get('sumAnnuity'))));
        }
        return annuityChartList;
    }

// Wrapper class for annuity values per Hot Rating Sections
    public class annuityChartWrap {

        public Integer hotRating {get;set;}
        public Integer annuityTotal {get;set;}

        public annuityChartWrap (Integer hotRating, Integer annuityTotal) {

            this.hotRating = hotRating;
            this.annuityTotal = annuityTotal;

        }  
    }

  <!-- relevant vf-page code -->
<apex:chart data="{!AnnuityChart}" height="400" width="500">
        <apex:legend position="left"/>
        <apex:axis type="Numeric" position="left" title="Annuity Totals" grid="true"
            fields="annuityTotal" dashSize="2">
            <apex:chartLabel/>
        </apex:axis>
        <apex:axis type="Category" position="bottom" fields="hotRating" title="Hot Rating">
            <apex:chartLabel rotate="315"/>
        </apex:axis>
        <apex:barSeries orientation="vertical" axis="left" stacked="true"
            xField="hotRating" yField="annuityTotal" title=""/>
    </apex:chart>

So, I was getting an error originally when I was using a number field in the soql query to group by... the error -> <number field> cannot be grouped by in a query call.

So I went back and created a text field which is what you see in the code (Hot_Rate__c). The problem now is that the chart displays the numbers in the incorrect order as you can see in the image below.

User-added image

So, as you can see, I'm running into a few roadblocks on what seems like a very simple chart. Any help would be greatly appreciated.
Hey everybody,

I'm running into a challenge that is probably very easy but I'm struggling with it. I need to write a SOQL query that will simple pull all Leads not attached to a Campaign. Here is what I've come up with so far but it is definitely not working...

SELECT Id, (Select Id From CampaignMembers WHERE Id = Null) FROM Lead WHERE CreatedDate >= 2016-03-13T00:00:00Z

When I go through the results, most of these are indeed attached to a campaign so not sure what I'm doing wrong.

Any ideas? Thanks in advance.
I'm trying to build a simple visual force chart but am running into roadblocks on the couple ways I've tried to accomplish the task. First off, here is the relevant code from controller and page.

// Controller method
public List<annuityChartWrap> annuityChartList = new List<annuityChartWrap>();
public List<annuityChartWrap> getAnnuityChart() {
        AggregateResult[] AgR = [SELECT Hot_Rate__c, SUM(Annuity_Investment__c) sumAnnuity FROM Account WHERE OwnerId=:userid GROUP BY Hot_Rate__c];
        for (AggregateResult AnnuityTotals : AgR) {
            annuityChartList.add(new annuityChartWrap(Integer.valueOf(AnnuityTotals.get('Hot_Rate__c')), Integer.valueOf(AnnuityTotals.get('sumAnnuity'))));
        }
        return annuityChartList;
    }

// Wrapper class for annuity values per Hot Rating Sections
    public class annuityChartWrap {

        public Integer hotRating {get;set;}
        public Integer annuityTotal {get;set;}

        public annuityChartWrap (Integer hotRating, Integer annuityTotal) {

            this.hotRating = hotRating;
            this.annuityTotal = annuityTotal;

        }  
    }

  <!-- relevant vf-page code -->
<apex:chart data="{!AnnuityChart}" height="400" width="500">
        <apex:legend position="left"/>
        <apex:axis type="Numeric" position="left" title="Annuity Totals" grid="true"
            fields="annuityTotal" dashSize="2">
            <apex:chartLabel/>
        </apex:axis>
        <apex:axis type="Category" position="bottom" fields="hotRating" title="Hot Rating">
            <apex:chartLabel rotate="315"/>
        </apex:axis>
        <apex:barSeries orientation="vertical" axis="left" stacked="true"
            xField="hotRating" yField="annuityTotal" title=""/>
    </apex:chart>

So, I was getting an error originally when I was using a number field in the soql query to group by... the error -> <number field> cannot be grouped by in a query call.

So I went back and created a text field which is what you see in the code (Hot_Rate__c). The problem now is that the chart displays the numbers in the incorrect order as you can see in the image below.

User-added image

So, as you can see, I'm running into a few roadblocks on what seems like a very simple chart. Any help would be greatly appreciated.