• Crystal Rochlitz 4
  • NEWBIE
  • 40 Points
  • Member since 2014

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 16
    Replies
I am trying to write a trigger that will send a Opportuinty to approval when the stage is set to "send to accountig" I dot get a error when I save the code but it does not work and I am not sure why. 

trigger OpportunitySubmitForApproval2 on Opportunity (after update) {

for (Opportunity opp : Trigger.new){

if (opp.Stagename =='Sent To Accounting'){
    Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
    
}
}
}
 
I am trying to write a trigger that will send a Opportuinty to approval when the stage is set to "send to accountig" I dot get a error when I save the code but it does not work and I am not sure why. 

trigger OpportunitySubmitForApproval2 on Opportunity (after update) {

for (Opportunity opp : Trigger.new){

if (opp.Stagename =='Sent To Accounting'){
    Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
    
}
}
}
 
After installing the Zendesk Package for Salesforce, I'm trying to create a basic Salesforce apex trigger based off the Zendesk Ticket sObject, in order to update a boolean on a lead. This is my first Salesforce trigger, so there might be some basic steps I'm missing.. But I've saved the trigger in the Developer Console and it doesn't report any problems, yet creating a new ticket doesn't update the boolean.

Here's the trigger I'm running below. I've installed the Zendesk integration onto my Developer edition Salesforce, to the point that new tickets display on a lead's record. However when I have this trigger active and log a new ticket with a lead, it doesn't update the boolean.

Any help appreciated!
 
trigger UpdateCampaignResponse on Zendesk__Zendesk_Ticket__c (after insert) {
        for(Zendesk__Zendesk_Ticket__c ticket : Trigger.new) {

            // Check if ticket requester is a lead
            if(String.valueOf(ticket.Zendesk__Requester__c).startsWith('00Q')== True) {

                // Create a set, add ticket requester id
                set<id>leadId=new set<id>();
                leadId.add(ticket.Zendesk__Requester__c);

                // Lookup and assign lead based on set
                Lead lead=[Select CampaignResponse__c from Lead where id in :leadId];
            
                // Mark Campaign Response on lead
                lead.CampaignResponse__c=True;
                update lead;
            }
      }
}

 
Our developer is trying to develop visual force pages and is getting the following errors.
 
System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Record Type ID: this ID value isn't valid for the user: : [RecordTypeId]
 
Any ideas?
Hello,

I have a trigger that fires when a task is inserted or updated.  When it is, it marks a checkbox on the Opportunity as TRUE.  What I would now like to do is add logic that will mark the field as FALSE if that task is deleted, but I'm not sure how to do this.  Can anyone help based on the trigger and class below?

Class:
public class ClassRenewalTasks {
    public void renewalTasks(List<Task> checkTasks) {
        // set up lists you will need
        List<Opportunity> linkedOpps = new List<Opportunity>();
        Map<Id, Task> taskMap = new Map<Id, Task>();

        // go through the list of tasks that were inserted
        for (Task t: checkTasks) {
            // if they are related to a contact, add the contact id (whoID) and their values to a map
            if (t.WhatId  != null && t.Status == 'Completed' && (t.Subject == 'User Training Complete'||
                                                                t.Subject == 'Initial Program Confirmation'||
                                                                t.Subject == 'Renewal Package Review')){
                taskMap.put(t.WhatId, t);
            }
        }

        // if the map isnt empty  
        // *** saying !taskMap.isEmpty() costs much less than using taskMap.size()>0  ***
        system.debug('taskMap = '+taskMap);
        if (taskMap.size() > 0)
        {
            // get all of the contacts related to the tasks
            linkedOpps = [SELECT Id, RP_User_Training__c,
                                RP_Initial_Program_Developed__c,
                                RP_Recommendation_Review_Call__c
                            FROM Opportunity 
                            WHERE Id IN: taskMap.keySet()];
            // go through the list for each contact
            for (Opportunity c: linkedOpps){
                for (Task task2:[SELECT WhatId, Subject
                                FROM Task
                                WHERE WhatId =: c.Id]){
                    IF(task2.Subject == 'User Training Complete'){
                        c.RP_User_Training__c = TRUE;
                    }
                    IF(task2.Subject == 'Initial Program Confirmation'){
                        c.RP_Initial_Program_Developed__c = TRUE;
                    }
                    IF(task2.Subject == 'Renewal Package Review'){
                    c.RP_Recommendation_Review_Call__c = TRUE;
                    }
                }
            }

            // if the list of cons isnt empty, update them
            system.debug('linkedOpps = '+linkedOpps);
            if (linkedOpps.size() > 0)
            {
            update linkedOpps;
            }
        }
    }
}



Trigger:
trigger MainTriggerTask on Task (after insert, after update, after delete) {
    
    IF(Trigger.IsAfter){
        IF(Trigger.IsInsert){
            
            if(checkTaskRecursive.runAfterInsertOnce()){
                
                ClassRenewalTasks updater6 = new ClassRenewalTasks();
                updater6.renewalTasks(Trigger.new);
                
            }
        }
        
        IF(Trigger.IsUpdate){
            
            if(checkTaskRecursive.runAfterUpdateOnce()){
                
                ClassRenewalTasks updater3 = new ClassRenewalTasks();
                updater3.renewalTasks(Trigger.new);
            }
            
        }
        
}

 
looks like if i set a fields value to null, then query the table for those records, they dont get returned. because a decimal thats null isnt actually null??
 
Account bad_data = [SELECT Id, Name, Latitude__c, Longitude__c, Location__latitude__s, Location__longitude__s 
                    	FROM Account 
                    	WHERE Id IN ('0018000000mZrLUAA0')][0];
system.debug(bad_data);
system.debug('bad_data.Latitude__c = null ? ' + bad_data.Latitude__c == null);
system.debug('bad_data.Longitude__c = null ? ' + bad_data.Longitude__c == null);
system.debug('bad_data.Location__latitude__s = null ? ' + bad_data.Location__latitude__s == null);
system.debug('bad_data.Location__longitude__s = null ? ' + bad_data.Location__longitude__s == null);


system.debug('bad_data.Latitude__c ? ' + String.valueOf(bad_data.Latitude__c));
system.debug('bad_data.Longitude__c ? ' + String.valueOf(bad_data.Longitude__c));
system.debug('bad_data.Location__latitude__s ? ' + String.valueOf(bad_data.Location__latitude__s));
system.debug('bad_data.Location__longitude__s ? ' + String.valueOf(bad_data.Location__longitude__s));

// get records
// are they null: nope
// well then what are they? theyre null

smh
I have created a webassessor account.But under developer registration i cant find the term dev 401.(The following picture explains it).
Reply me ASAP.
here is the screenshot.User-added image
Hi there,

I have a custom Visualforce page which is all html with styling and format to this site: (http://www.salesforce.com/products/30daytrial/pe-getting-started.jsp). This seems to affect the header and sidebar of the salesforce when I go to that page. Why is this happening? What can I do to fix this? Thanks.

S.S.
Hello,

I'm getting an error that I think is recursion-based and I'm not sure how to fix it. Basically, I'm trying to update the DD field on my DDCustom__c object with a value from my Opportunity field UpdateDD__c (which is a lookup).
 
trigger UpdateDD2 on DDCustom__c (after update, after insert) {

  List<DDCustom__c> des = [select Id, DD__r.Id, Opportunity__r.Id from DDCustom__c where Id in :Trigger.newMap.keySet()];
  List<Opportunity> opp = [select Id, UpdateDD__c, UpdateDD__r.Id from Opportunity where Id = : des[0].cv__Opportunity__r.Id and UpdateDD__c != null];
  List<DDCustom__c> des2 = new List<DDCustom__c>();
  
  Set<DDCustom__c> desSet = new Set<DDCustom__c>();
  
  for(DDCustom__c d : des){
  
      if(des2.size()>0){
          desSet.addAll(des2);
          }
  
      if((! desSet.contains(d)) && (opp[0].UpdateDD__c != null) && (d.DD__r.Id != opp[0].UpdateDD__r.Id)){
           d.DD__r.Id = opp[0].UpdateDD__r.Id;
              des2.add(d);
              }
      }
 
   update des2;
   }

 
Hello, I need some help with a couple triggers i'm having issues with.  I am somewhat new to triggers and i created and After update trigger that inserts a list when an opportunity is updated if the list = 0.  The problem i'm having is that another trigger might be causing my trigger some issues.  We have a database feeding into salesforce using a boomi process and accounts are not being updated or failing because of the 2 triggers.  Below is the error:

SF_ERROR: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY
OBJ: Applicant__c - ApplicantDataWriting: execution of AfterUpdate

caused by: System.DmlException: Update failed. First exception on row 0 with id 006F000000JBTpEIAX; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, applicationchecklistUpdate: execution of AfterUpdate

caused by: System.DmlException: Insert failed. First exception on row 0 with id a0sF0000003fQgQIAU; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]

Trigger.applicationchecklistUpdate: line 202, column 1: []

Trigger.ApplicantDataWriting: line 266, column 1

My trigger is an after update trigger which inserts a list an an object if it's = to 0 and the other triger is an after insert, after update trigger which converts leads to opportunities, updates accounts, opportunities and create new opportunities based on a boomi process we have which feeds from our database to boomi.

I did not have room to post the code but i can after i sumit the question.

Any help is appreciated.
Hi,
We have a business need to send and email to new lead leads in certain cases. I've organized those cases by 'campaign 1'. This is on a trial enterprise org. We are using First Contact to capture business cards for this case. There are two custom fields entered at the time of busines card scan and the user associates the new lead to 'campaign 1'.

Great!

Now I have the following workflow I'm doing manually once I see the lead in Salesforce. 

 
  • leads ->'Campaign 1'(custom view) -> go

  • Click on first lead with status of Entered Contest

  • Under the Activity History related list click Send an Email -> Select Template -> campaign 1 email template

  • Cut and paste the URL link(generated by the template merge feature using custom fields) into a browser, test and save positive result as a pdf.

    • Ad leads initials to the default pdf name file_name.pdf -> file_name_cg.pdf

  • Attach the newly created pdf to the email. Attach file

  • Send

  • Under Campaign History linked list click edit next to the IFP iPad Mini Give Away

  • Change campaign 1 status from Entered Contest to Email Sent



    Another requirement not listed here is that we want the email to go out n hours after the lead enteres the system (not immediately)

 A couple of questions. Can this be automated in Salesforce?

Most of the workflow is straight forward: Send the email, select a template, change a status. Where does this automation happend? Can you point me on hwere to learn about automating vanila Salesforce activities? Is this a 'trigger' a 'worlflow'?

What about generating the pdf? Is this something I should not expect to do with Salesforce? Right now I'm using the cut and pasted the URL into google chrome and print pdf. Should I make an executable that does this and call it from Salesforce?


Thanks for taking the time to read this for a new user. I apprecatiate the kindness I've received so far in the community.

John
looks like if i set a fields value to null, then query the table for those records, they dont get returned. because a decimal thats null isnt actually null??
 
Account bad_data = [SELECT Id, Name, Latitude__c, Longitude__c, Location__latitude__s, Location__longitude__s 
                    	FROM Account 
                    	WHERE Id IN ('0018000000mZrLUAA0')][0];
system.debug(bad_data);
system.debug('bad_data.Latitude__c = null ? ' + bad_data.Latitude__c == null);
system.debug('bad_data.Longitude__c = null ? ' + bad_data.Longitude__c == null);
system.debug('bad_data.Location__latitude__s = null ? ' + bad_data.Location__latitude__s == null);
system.debug('bad_data.Location__longitude__s = null ? ' + bad_data.Location__longitude__s == null);


system.debug('bad_data.Latitude__c ? ' + String.valueOf(bad_data.Latitude__c));
system.debug('bad_data.Longitude__c ? ' + String.valueOf(bad_data.Longitude__c));
system.debug('bad_data.Location__latitude__s ? ' + String.valueOf(bad_data.Location__latitude__s));
system.debug('bad_data.Location__longitude__s ? ' + String.valueOf(bad_data.Location__longitude__s));

// get records
// are they null: nope
// well then what are they? theyre null

smh