• Todd Kadas
  • NEWBIE
  • 5 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 19
    Replies
Thanks for taking the time to read this.  I've got an apex wrapper class that compiles a list of opportunities that are pending approval.  I've then created two visualforce pages, one that displays the desired results and includes an export to excel button and the other that creates the excel table.  
In preview mode, the one that creates the excel table generates the desired results in Excel.  However, the one that contains the export button, on click, creates an excel file with each record displayed 3 times.  Here is the apex and the visualforce pages.  Any help would be greatly appreciated.

apex
public class getWrapDataexport{

    public PageReference exportToExcel() {
        PageReference retURLExcel = new PageReference('/apex/wraptestexport');
        return retURLExcel;
    }

 
    List<wrapperclass> wrapList = new List<wrapperclass>();
    public List<wrapperclass> getWrapList() {
 
        for (ProcessInstance pi: [SELECT Id, Status, TargetObjectId, TargetObject.Name, 
                (SELECT Id, ActorId, Actor.Name, OriginalActorId, OriginalActor.Name, StepStatus, Comments, ProcessNode.Name, CreatedDate FROM StepsAndWorkitems WHERE StepStatus =: 'Pending') 
                FROM ProcessInstance WHERE Status =: 'Pending' AND ProcessDefinitionId IN ('04a170000008pXpAAI','04a1J000000GqbkQAC') ORDER BY ProcessDefinitionId] ) {
 
                   for (ProcessInstanceHistory pih : pi.StepsAndWorkItems) {
                       wrapperClass pendingApprovalWrap = new wrapperClass();
                       pendingApprovalWrap.Status = pih.StepStatus;
                       pendingApprovalWrap.RecordName = String.valueOf(pi.TargetObject.Name);
                       pendingApprovalWrap.RecordId = String.valueOf(pi.TargetObjectId);
                       pendingApprovalWrap.RecordObject = String.valueOf(pi.TargetObjectId.getSObjectType()).split('__')[0];
                       pendingApprovalWrap.AssignedToName = String.valueOf(pih.OriginalActor.Name);
                       pendingApprovalWrap.ApproverName = pih.Actor.Name;
                       pendingApprovalWrap.CreatedDate = String.valueOf(pih.CreatedDate);
 
                       wrapList.add(pendingApprovalWrap);
                       }          
                   }
 
                   return wrapList;
    }
 
    public class wrapperClass{
        public String Status {get; set;}
        public String RecordName {get; set;}
        public String RecordId {get; set;}
        public String RecordObject {get; set;}
        public String AssignedToName {get; set;}
        public String ApproverName {get; set;}
        public String CreatedDate {get; set;}

}        
  
    }
visualforce page 1
<apex:page controller="getWrapDataexport" contentType="application/vnd.ms-excel#SalesForceExport.xls" cache="true">
  <head>
   <meta http-equiv="Content-Type" content="text/HTML;charset=UTF-8" />
  </head>
    <apex:pageblock title="Pending Approvals">
        <apex:pageblocktable value="{!wrapList}" var="wrap">
 
            <apex:column >
                <apex:facet name="header">Status</apex:facet>
                <apex:outputtext value="{!wrap.Status}"></apex:outputtext>
            </apex:column>
 
            <apex:column >
                <apex:facet name="header">Object</apex:facet>
                <apex:outputtext value="{!wrap.RecordObject}"></apex:outputtext>
            </apex:column>
 
            <apex:column headervalue="Name">
                <apex:facet name="header">Opportunity Name</apex:facet>
                <apex:outputlink value="/{!wrap.RecordId}">{!wrap.RecordName}</apex:outputlink>
            </apex:column>
 
            <apex:column >
                <apex:facet name="header">Assigned To</apex:facet>
                <apex:outputtext value="{!wrap.AssignedToName}"></apex:outputtext>
            </apex:column>
 
            <apex:column >
                <apex:facet name="header">Approver Name</apex:facet>
                <apex:outputtext value="{!wrap.ApproverName}"></apex:outputtext>
            </apex:column>
 
            <apex:column >
                <apex:facet name="header">Date</apex:facet>
                <apex:outputtext value="{!wrap.CreatedDate}"></apex:outputtext>
            </apex:column>
 
        </apex:pageblocktable>
    </apex:pageblock>
</apex:page>
visualforce page 2
<apex:page controller="getWrapDataexport" >

    <apex:pageblock title="Pending Approvals">
        <apex:pageblocktable value="{!wrapList}" var="wrap">
 
            <apex:column >
                <apex:facet name="header">Status</apex:facet>
                <apex:outputtext value="{!wrap.Status}"></apex:outputtext>
            </apex:column>
 
            <apex:column >
                <apex:facet name="header">Object</apex:facet>
                <apex:outputtext value="{!wrap.RecordObject}"></apex:outputtext>
            </apex:column>
 
            <apex:column headervalue="Name">
                <apex:facet name="header">Opportunity Name</apex:facet>
                <apex:outputlink value="/{!wrap.RecordId}">{!wrap.RecordName}</apex:outputlink>
            </apex:column>
 
            <apex:column >
                <apex:facet name="header">Assigned To</apex:facet>
                <apex:outputtext value="{!wrap.AssignedToName}"></apex:outputtext>
            </apex:column>
 
            <apex:column >
                <apex:facet name="header">Approver Name</apex:facet>
                <apex:outputtext value="{!wrap.ApproverName}"></apex:outputtext>
            </apex:column>
 
            <apex:column >
                <apex:facet name="header">Date</apex:facet>
                <apex:outputtext value="{!wrap.CreatedDate}"></apex:outputtext>
            </apex:column>
        </apex:pageblocktable>
    </apex:pageblock>
    <hr/>
    <apex:form >
    <apex:commandButton action="{!exportToExcel}" value="Export to Excel" id="ExportExcel"/>
    </apex:form>
</apex:page>


 
I've been struggling for quite some time now to figure out a way to provide the approvers within my company with a list of opportunities that are pending approval and by whom (we have two parallel approval processes in place). The way I'm currently doing it is manually (running a SOQL query in dev console, pushing that to Excel, running an opportunity report, exporting that to Excel, and then merging the files together. Below, gets details from process instance into a visualforce page which is good but doesn't include any fields from opportunity object and also doesn't let me export to Excel.
Would anyone be able to assist me in updating this wrapper class by showing me how to query the opportunity object and including selected fields in VF output? Thanks in advance.
 
public class getWrapData{

    List<wrapperclass> wrapList = new List<wrapperclass>();
    public List<wrapperclass> getWrapList() {

        for (ProcessInstance pi: [SELECT Id, Status, TargetObjectId, TargetObject.Name, 
                (SELECT Id, ActorId, Actor.Name, OriginalActorId, OriginalActor.Name, StepStatus, Comments, ProcessNode.Name, CreatedDate FROM StepsAndWorkitems WHERE StepStatus =: 'Pending') 
                FROM ProcessInstance WHERE Status =: 'Pending' ORDER BY TargetObjectId] ) {

                   for (ProcessInstanceHistory pih : pi.StepsAndWorkItems) {
                       wrapperClass pendingApprovalWrap = new wrapperClass();
                       pendingApprovalWrap.Status = pih.StepStatus;
                       pendingApprovalWrap.RecordName = String.valueOf(pi.TargetObject.Name);
                       pendingApprovalWrap.RecordId = String.valueOf(pi.TargetObjectId);
                       pendingApprovalWrap.RecordObject = String.valueOf(pi.TargetObjectId.getSObjectType()).split('__')[0];
                       pendingApprovalWrap.AssignedToName = String.valueOf(pih.OriginalActor.Name);
                       pendingApprovalWrap.ApproverName = pih.Actor.Name;
                       pendingApprovalWrap.CreatedDate = String.valueOf(pih.CreatedDate);

                       wrapList.add(pendingApprovalWrap);
                       }          
                   }

                   return wrapList;
    }

    public class wrapperClass{
        public String Status {get; set;}
        public String RecordName {get; set;}
        public String RecordId {get; set;}
        public String RecordObject {get; set;}
        public String AssignedToName {get; set;}
        public String ApproverName {get; set;}
        public String CreatedDate {get; set;}
    }
}

 
Hello kind people,

I'm sure this is rather simple but I've been struggling with it for a while.  I'm just trying to create a list button for a custom log a call feature that I can add to my Account Activity History.
Here is the class:
public class LogCallController2 
{

    public LogCallController2(ApexPages.StandardSetController controller) {

    }

    public task t1{get;set;}
    //public task t1{get
    //{
    //String strId = ApexPages.currentPage().getParameters().get('id');
    //t1=[SELECT Id, WhatId FROM Task WHERE id =:strId];
    //return t1;
    //}
    //set;}
    public LogCallController2(ApexPages.StandardController controller) 
    {
   
        t1= new task();
    }
    public PageReference save()
    {
        insert t1;
        //PageReference p=new PageReference('/a0T/o');
        //return p;
        return null;
    }
}
And here is the VF page.  Ideally,  I would like to be able to pre-populate all fields with the exception of Comments (Description) and Who Id. 

I tried to give up and just go the old URL hack route with a custom record type and page layout but it seems I coudn't pass values to text fields in LEX.  

Any assistance anyone can offer would be greatly appreciated.  
 
<apex:page standardController="Task" recordSetVar="tasks" extensions="LogCallController2">
  <apex:form >
  <apex:pageBlock title="Log a Call">
  <apex:pageBlockSection >
  <apex:inputField value="{!task.Subject}"/>
    <apex:inputField value="{!task.Description}"/>
      <apex:inputField value="{!task.ActivityDate}"/>
        <apex:inputField value="{!task.Priority}"/>
         <apex:inputField value="{!task.Status}"/>
          <apex:inputField value="{!task.WhatId}"/>
           <apex:inputField value="{!task.WhoId}"/>        
  </apex:pageBlockSection>
  <apex:pageBlockButtons location="top">
  <apex:commandButton value="Save" action="{!save}"/>
    <apex:commandButton value="Cancel" action="{!cancel}"/>
  </apex:pageBlockButtons>
  </apex:pageBlock>
  </apex:form>
</apex:page>


 
I have a trigger that grabs approval comments and updates a custom field on an opportunity record.  I am able to get 100% code coverage on test class when approval process requires one approver.  However, when I change approval process to one that requires unanimous approval, I get the following error: System.AssertException: Assertion Failed: Instance StatusPending: Expected: Approved, Actual: Pending.
Any idea how to update test class to, I suppose, send to parallel approvers, and acheive approval?

trigger
trigger TriggerApprover on opportunity (before update) {
    
       if(trigger.isUpdate){
             List<Opportunity> opptyList =  [Select id,
                                                   (Select Id, 
                                                         IsPending, 
                                                         ProcessInstanceId, 
                                                         TargetObjectId, 
                                                         StepStatus, 
                                                         OriginalActorId, 
                                                         ActorId, 
                                                         RemindersSent, 
                                                         Comments, 
                                                         IsDeleted, 
                                                         CreatedDate, 
                                                         CreatedById, 
                                                         SystemModstamp 
                                                    FROM ProcessSteps
                                                ORDER BY CreatedDate DESC) 
                                                    From opportunity
                                                WHERE Id IN : Trigger.new];

             if(opptyList.size() > 0){

               for(Opportunity opp : opptyList){
              
                for(Opportunity opp1 : Trigger.new) {
                  
                         //check copy comment is true
                         if(opp.id == opp1.id && opp1.copy_comment__c) {
 
                           if (opp.ProcessSteps.size() > 0) {
                            
                         opp1.Approval_History_Comments__c = opp.ProcessSteps[0].Comments;
                         //opp1.copy_comment__c = false;//
                
                           }

                        }
                 
                    }
               }
             }   
        }  
    }
test class
@isTest
private class ApprovalComments_Test{
 static testMethod void testMethodAppCmmt() 
  {
        Account acct = new Account(Name = 'Test Account');
        insert acct;

//Create your pricebook entry
// Instantiate the Pricebook2 record first, setting the Id
Pricebook2 standardPricebook = new Pricebook2(
  Id = Test.getStandardPricebookId(),
    IsActive=true

);

// Run an update DML on the Pricebook2 record
// This enables IsStandard to become true
// on the PricebookEntry record
update standardPricebook;

// Re-Query for the Pricebook2 record, for debugging
standardPricebook = [SELECT IsStandard FROM Pricebook2 WHERE Id = :standardPricebook.Id];

// This should return true now
system.assertEquals(true, standardPricebook.IsStandard, 'The Standard Pricebook should now return IsStandard = true');

// Create the Product
Product2 testProduct = new Product2(
  Name = 'Test Product', 
  IsActive = true
);
insert testProduct;

            PricebookEntry pbe = new PricebookEntry(Pricebook2Id=standardPricebook.Id, Product2Id=testProduct.Id, UnitPrice=99);
    insert pbe;
        
// Create the PricebookEntry
PricebookEntry testPbe = new PricebookEntry(
  Pricebook2Id = '01so0000003MaLt',
  Product2Id = testProduct.Id,
  UnitPrice = 100,
  IsActive = true
);

insert testPbe;

// Re-Query the PBE
testPbe = [SELECT Id, Pricebook2.IsStandard FROM PricebookEntry where Pricebook2Id = '01so0000003MaLt'];

// Should also return true
system.assertEquals(false, testPbe.Pricebook2.IsStandard, 'The Standard Pricebook should return true from the PBE as well.');
        
         List<Opportunity> opps = new List<Opportunity>();
        
      Opportunity testOpportunity = new Opportunity(
      //Changed StageName to Qualification so that field values do not match process builder criteria.  This will cause test class to fail 
            StageName = 'Qualification',
              CloseDate=System.today().addMonths(1),       
            AccountId = acct.Id,
            OwnerId='0051J000005xUguQAE',
            Credit_Terms_Requested__c='More than 60 days',
            Name = 'Test Opportunity',
            pricebook2Id = testPbe.Pricebook2Id,
                  Amount=150000.0,
             Service_Line__c='FCL - Standard',
             Submit_to_Credit_Approval_Process__c=TRUE
        );
        insert testOpportunity;
        opps.add(testOpportunity);
         system.debug(LoggingLevel.FINE, '<content>');  
        system.debug(opps.size());

       // return acct;
        OpportunityLineItem op=new OpportunityLineItem (quantity=1.0,Opportunityid=opps[0].id,   PricebookEntryId=testPbe.Id, Product2Id = testProduct.Id,
TotalPrice=500000.0 ,CM__c=100.0, UoM__c='KG' ,volume__c=10.0);
      insert op;

          opps =[SELECT AccountId, Amount, Id, Name, CloseDate, StageName, Credit_Terms_Requested__c, Submit_to_Credit_Approval_Process__c, Service_Line__c,(SELECT Quantity, ListPrice,PriceBookEntry.UnitPrice, PricebookEntry.Name,
Estimated_CM__c,CM__c,  UnitPrice FROM OpportunityLineItems) FROM Opportunity where AccountId=: acct.Id ]; 
        //AccountId=: acct.Id ORDER BY CloseDate DESC LIMIT 10 ];
         
 User user1 = [SELECT Id FROM User WHERE Alias='aAbou'];
            
        // Create an approval request for the opportunity
        Approval.ProcessSubmitRequest req1 = 
            new Approval.ProcessSubmitRequest();
        req1.setComments('Submitting request for approval.');
        req1.setObjectId(testOpportunity.id);
        
        // Submit on behalf of a specific submitter
        req1.setSubmitterId(user1.Id); 
        
        // Submit the record to specific process and skip the criteria evaluation
        req1.setProcessDefinitionNameOrId('Credit_Legal_and_Strategy_Review');
        req1.setSkipEntryCriteria(true);
        
        // Submit the approval request for the account
        Approval.ProcessResult result = Approval.process(req1);
        
        // Verify the result
        System.assert(result.isSuccess());
        
        System.assertEquals(
            'Pending', result.getInstanceStatus(), 
            'Instance Status'+result.getInstanceStatus());
        
        // Approve the submitted request
        // First, get the ID of the newly created item
        List<Id> newWorkItemIds = result.getNewWorkitemIds();
        
        // Instantiate the new ProcessWorkitemRequest object and populate it
        Approval.ProcessWorkitemRequest req2 = 
            new Approval.ProcessWorkitemRequest();
        req2.setComments('Approving request.');
        req2.setAction('Approve');
        req2.setNextApproverIds(new Id[] {UserInfo.getUserId()});
        
        // Use the ID from the newly created item to specify the item to be worked
        req2.setWorkitemId(newWorkItemIds.get(0));
        
        // Submit the request for approval
        Approval.ProcessResult result2 =  Approval.process(req2);
        
        // Verify the results
        System.assert(result2.isSuccess(), 'Result Status:'+result2.isSuccess());
        // This fails when approval process requires unanimous approval
        System.assertEquals(
            'Approved', result2.getInstanceStatus(), 
            'Instance Status'+result2.getInstanceStatus());
    }
}

 
Hoping someone can help me out.  I'm a bit new here.  Error message and Apex class provided below.  I have a trigger that fires after a user creates a new note in Notes & Attachment resulting in a task being created.  Below script then populates fields in the task to complete it.  Works fine when notes are created in Accounts and Opportunities but throws below error when notes are created in Leads or Contacts.  

If you're scratching your head around why this would have been created, it's that several of our users complained that they weren't getting credit for activities they perform throughout the week, such as updating account data with notes.  By using this, when management reviews their teams activities, each note is counted as 1 activity.

Apex script unhandled trigger exception by user/organization: 005o0000001aU9R/00D0m000000CmUV Source organization: 00Do0000000ZWI0 (null)
NotesTrigger: execution of AfterInsert
 
caused by: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Related To ID: id value of incorrect type: 00Qo000000UcO86EAF: [WhatId]
 
Class.NotesHandler.onAfterInsert: line 54, column 1
Trigger.NotesTrigger: line 14, column 1
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
*\arg ClassName    :NotesHandler
*\arg CreatedOn    :
*\arg LastModifiedOn    :
*\arg CreatedBy    :
*\arg ModifiedBy    :
*\arg Description    :Handler class to create task after notes are inserted
*/
public with sharing class NotesHandler
{
    /*Start - Constructor*/
    public NotesHandler()
    {
        //do nothing
    }
    /* End - Constructor*/
    
    /**
    @MethodName    :onAfterUpdate
    @Param    :
    @Description:
    **/
    public void onAfterInsert(List<Note>lstNote)
    {
    String userID=UserInfo.getUserId();
    List<Task>lstTask=new List<Task>();
    for(Note objNote :lstNote)
    {
        Schema.SObjectType objType=objNote.parentId.getSobjectType();
        String strObjType = objType+' ';
        if( strObjType != 'Task')
        {
        Task objTask = new Task();
        objTask.Subject = 'Note created -'+objNote.Title;
        objTask.Priority = 'Normal';
        objTask.Type = 'Note created';
        objTask.Status = 'Completed';
        objTask.ActivityDate = objNote.CreatedDate.Date();
        objTask.Task_Completion_Date__c = objNote.CreatedDate;
        if(strObjType=='Contact'||strObjType=='Lead')
        ObjTask.WhoId=objNote.parentId;
        else
        objTask.WhatId = objNote.parentId;
        objTask.OwnerId = userId;
        
        lstTask.add(objTask);
        
        }
   
        
    }
     
     if(!lstTask.isEmpty())
         insert lstTask;
    }
    
    
}
Continue to receive the following error message "Could not find a Permission Set named 'Trailhead' that has the 'Two-Factor Authentication for User Interface Logins' permission enabled.".  I have created the following: new developer edition, new user,  and new permission set with required 'Two Factor Authentication for User Interface Logins' ticked.  I then assigned the permission set to the new user, logged out, logged back in as the new user and was successfully able to log in using 2FA.  I am logged in to the same developer edition that I used to create user and set.
Hello,

I am trying to find the name of user ID "00520000004FxxP" and can't find it (i created a user report and exported all users both active and inactive).

I received an Appex Application error saying the below and trying to investigate. Any ideas?

Apex script unhandled trigger exception by user 00520000004FxxP

Opportunity:execution of BeforeUpdate
caused by:System.QueryException:sObject type 'Product_c' is not supported.

Class.OpportunityTriggerHandler.populateFields: Line 59, Column 1
Trigger.Opportunity:line 17, column 1
I have a requirement that I have to fetch all the Account Lookup fields.I'm using Schema.DisplayType for fetching Text,Picklistlist fields.But for lookup fields I don't know how to fetch.Can anyone help me?
I need to have a schedule report exported to excel and put it into a schedule and  send it to specific e-mails.
I have already the report created.

I have used the following code:

global class Exporter implements System.Schedulable {
    global void execute(SchedulableContext sc) {
        ApexPages.PageReference report = new ApexPages.PageReference('/00O58000003m3Sa?csv=1');
        Messaging.EmailFileAttachment attachment = new Messaging.EmailFileAttachment();
        attachment.setFileName('report.xls');
        attachment.setBody(report.getContent());
        attachment.setContentType('text/csv');
        Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
        message.setFileAttachments(new Messaging.EmailFileAttachment[] { attachment } );
        message.setSubject('Report');
        message.setPlainTextBody('The report is attached.');
        message.setToAddresses( new String[] { 'mplampla.com' } );
        Messaging.sendEmail( new Messaging.SingleEmailMessage[] { message } );
        
    }
 }

although I don't see how i give this a schedule.
I guess that this reads the schedule that exists in the report and so the report is sent thourgh this code as an attachment in an email?
Can I also store the executable attachment directly to a path?
Hoping someone can help me out.  I'm a bit new here.  Error message and Apex class provided below.  I have a trigger that fires after a user creates a new note in Notes & Attachment resulting in a task being created.  Below script then populates fields in the task to complete it.  Works fine when notes are created in Accounts and Opportunities but throws below error when notes are created in Leads or Contacts.  

If you're scratching your head around why this would have been created, it's that several of our users complained that they weren't getting credit for activities they perform throughout the week, such as updating account data with notes.  By using this, when management reviews their teams activities, each note is counted as 1 activity.

Apex script unhandled trigger exception by user/organization: 005o0000001aU9R/00D0m000000CmUV Source organization: 00Do0000000ZWI0 (null)
NotesTrigger: execution of AfterInsert
 
caused by: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Related To ID: id value of incorrect type: 00Qo000000UcO86EAF: [WhatId]
 
Class.NotesHandler.onAfterInsert: line 54, column 1
Trigger.NotesTrigger: line 14, column 1
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
*\arg ClassName    :NotesHandler
*\arg CreatedOn    :
*\arg LastModifiedOn    :
*\arg CreatedBy    :
*\arg ModifiedBy    :
*\arg Description    :Handler class to create task after notes are inserted
*/
public with sharing class NotesHandler
{
    /*Start - Constructor*/
    public NotesHandler()
    {
        //do nothing
    }
    /* End - Constructor*/
    
    /**
    @MethodName    :onAfterUpdate
    @Param    :
    @Description:
    **/
    public void onAfterInsert(List<Note>lstNote)
    {
    String userID=UserInfo.getUserId();
    List<Task>lstTask=new List<Task>();
    for(Note objNote :lstNote)
    {
        Schema.SObjectType objType=objNote.parentId.getSobjectType();
        String strObjType = objType+' ';
        if( strObjType != 'Task')
        {
        Task objTask = new Task();
        objTask.Subject = 'Note created -'+objNote.Title;
        objTask.Priority = 'Normal';
        objTask.Type = 'Note created';
        objTask.Status = 'Completed';
        objTask.ActivityDate = objNote.CreatedDate.Date();
        objTask.Task_Completion_Date__c = objNote.CreatedDate;
        if(strObjType=='Contact'||strObjType=='Lead')
        ObjTask.WhoId=objNote.parentId;
        else
        objTask.WhatId = objNote.parentId;
        objTask.OwnerId = userId;
        
        lstTask.add(objTask);
        
        }
   
        
    }
     
     if(!lstTask.isEmpty())
         insert lstTask;
    }
    
    
}
Dear all,

I am new to Salesforce. I created a developer environment, and a test Connected App, so that I can test making REST API calls.
The problem is that I cannot locate the consumer key and consumer secret for my app. I have read people had similar issues in the past, but their solution didn't work for me.
I attach a screenshot of my app details. According to the docs, this is where I should see consumer key and consumer secret.

User-added image

Thanks for the help!

Daniele 
Hi all,
I need to capture an approval comments to populate a lead custom field when the lead status = unqualified and the step status = rejected. I have an error compilation like "Error: Compile Error: Variable does not exist: Lead at line 14 column 109"
Here is my code. Any help?
trigger Unqualified on Lead (before update) {
//Get all approval process records from an approval process definition. ProcessDefinitionId = The ID of this approval process instance.TargetObjectId = ID of the object affected by this approval process instance.//
List<ProcessInstance> instances = [SELECT Id,TargetObjectId,(SELECT Id, StepStatus, Comments FROM Steps) FROM ProcessInstance Where ProcessDefinitionId  = '[ TargetObjectId]'];

//guarda la información de los leads. Declara e inicializa. List (nombre del objeto)//
List<Lead> Leads = New List <Lead>(); 

//Create a set of object Ids which has process instance//
    for(ProcessInstance pi:instances){
        LeadIds.add(pi.TargetobjectId);
    }
 
//Query for related records//
Map<Id,Lead> LeadMap = new Map<Id,Lead>([Select ReasonRejectedByCommercialPlanning__c from Lead Where Id in:Lead]);

//populate object's reason rejected field from approval comments
if (l.status == 'Unqualified')
    if (l.recordtypeId == '0121A000000QeSxQAK')
    for(ProcessInstance pi:instances){
       for (ProcessInstanceStep step : pi.Steps) {
         if(step.Status == 'Rejected') {
            LeadMap.get(pi.TargetObjectId).ReasonRejectedByCommercialPlanning__c = step.Comments;
         }
       }
    }

//Update your object//
update LeadMap.values();
  • January 31, 2017
  • Like
  • 0
Hello,

I have this error when I try to check challenge:

Challenge Not yet complete... here's what's wrong: 
Could not find an account named 'Blackbeards Grog Emporium' created from Workbench with the Description 'The finest grog in the seven seas.'


In the next picture you can see what I send by the Workbench

User-added image

The result is succes and in my Developer Org I can see the Account created correctly, but the challenge isn't passed.
Process Builder seems to be causing issues with Test Classes. They have all failed after we have activated a few new processes in Process Builder. When deactivating the processes and resorting to workflow rules, the test classes do not fail.
I am trying to pass Quick start Apex Step two. I have copy and pasted the code given

public class OlderAcccountsUtility {
public static void updateOlderAccounts() {
// Get the 5 oldest accounts
Account[] oldAccounts = [SELECT Id, Description FROM Account ORDER BY CreatedDate ASC LIMIT 5];
// loop through them and update the Description field
for (Account acct : oldAccounts) {
acct.Description = 'Heritage Account';
}
// save the change you made
update oldAccounts;


but I am getting the below error message

Step Not yet complete... here's what's wrong: 
The 'updateOlderAccounts' method did not update account records as expected 
Note: you may run into errors if you've skipped previous steps.

Can Someone please look over what I am doing wrong?
Hello Friends,

I was going through the trailhead and happened to execute the below code:

public static void updateOlderAccounts() {
    // Get the 5 oldest accounts
    Account[] oldAccounts = [SELECT Id, Description FROM Account ORDER BY CreatedDate ASC LIMIT 5];
    // loop through them and update the Description field
    for (Account acct : oldAccounts) {
        acct.Description = 'Heritage Account';
   }
   // save the change you made
   update oldAccounts;
}


But its showing error on line 1 - unexpected token: 'void'

Can anyone please help?

Thanks in advance!
 
Is there a way to update a custom field on a the opportunity record with the approval comments from the fina approver?

 
Hi,  I receive the following error in a test class but have not been able to repeat them in non test running scenarios.

"System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_EXECUTE_FLOW_TRIGGER, The record couldn’t be saved because it failed to trigger a flow. 
A flow trigger failed to execute the flow with version ID 301O00000008hM6. 
Contact your administrator for help.: []"

Does anyone know if there could be an issue running flows in test class contexts but not otherwise?

Thanks.

I need to export a report as a CSV to an FTP site or email it on a daily or weekly basis.

 

I have a Report.  I need to get the report out of Salesforce somehow into CSV format.

 

Ideally, this would be scheduled.


I'm a developer so I can do developer stuff.  However, I don't know APEX and I don't know VisualForce.  I can get someone to do that stuff if we need to.


Thanks!

  • July 26, 2011
  • Like
  • 2

Hi,

 

Please help me to create a report that display all the users who have not created any opportunity in last 7 days.

  • September 20, 2010
  • Like
  • 0