• Ludivine
  • NEWBIE
  • 195 Points
  • Member since 2012
  • Salesforce Administrator
  • Amcor Flexibles

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 1
    Likes Given
  • 42
    Questions
  • 53
    Replies
Hi all,

In my company, we have several admins working in the same instance.
I am in charge of integrations, twice a week I do the deployments in sandbox or in production for the awaiting packages.
I would like to send a report of what is waiting for deployment before integration and after deployment, a report of the list of packages that have been deployed.
Any idea?
Hi dev team,

I have created a custom object with questions and corresponding marks detailed in several text and number fields to be displayed in a specific graph. The request is to create a Spider Chart.
Is there a existing Ligtning component for this sort of chart?
Or do you advise anything else?

Thank you.
Best Regards,
Ludivine
Hi,

I have created a Visualforce Page to be able to upload attachment in Salesforce for X-Author application since Salesforce doesn't allow anymore to create any attachments in attachment object.
Everything is working as expected. I just need help to get full code coverage.
Only 47% with the test cIass I wrote. Could you tell me why I am not able to cover it all and what is wrong?
 
//VF Page :
<apex:page standardController="Apttus_XApps__Application__c" extensions="AttachmentUploadController">
  <apex:form >
      <apex:pageBlock title="Upload Attachment">
            <apex:inputFile style="width:100%" id="fileToUpload" value="{!fileBody}" filename="{!fileName}" />
            <apex:commandButton value="Upload Attachment" action="{!UploadFile}"/>
       </apex:pageBlock>
  </apex:form>
</apex:page>

//Controller :
public with Sharing class AttachmentUploadController {

    public Id recId
    {    get;set;    }
    
    public AttachmentUploadController(ApexPages.StandardController ctlr)
    {
       recId = ApexPages.CurrentPage().getParameters().get('Id');      
    }
    
    public string fileName 
    {    get;set;    }
    
    public Blob fileBody 
    {    get;set;    }
  
    public PageReference UploadFile()
    {    
        PageReference pr;
        if(fileBody != null && fileName != null)
        {
          Attachment myAttachment  = new Attachment();
          myAttachment.Body = fileBody;
          myAttachment.Name = fileName;
          myAttachment.ParentId = recId;
          insert myAttachment;
            
           pr = new PageReference('/' + myAttachment.Id);
           pr.setRedirect(true);
           return pr;
        }
        return null;
    }    
}


// Test method:
@isTest
public class AttachmentUploadController_Test{

    static testMethod void testCase1() {        
        Id recID;    
    PageReference pr;
        String filename = 'Att1';
        Blob Body = Blob.valueof('Unit Test Attachment Body');

        Apttus_XApps__Application__c objApp = New Apttus_XApps__Application__c();
        objApp.Name = 'Test Upload Attachment';
        objApp.Apttus_XApps__Activated__c = True;
        objApp.Apttus_XApps__UniqueId__c ='123ADCDEFG';
        insert objApp;
        
        recID = objApp.Id;      
        
        AttachmentUploadController controller=new AttachmentUploadController(new ApexPages.StandardController(objApp));        
        
        Attachment myAttachment =New attachment();
        myAttachment.name =filename;
        myAttachment.Body = Body;
        myAttachment.ParentId = recID;
        controller.UploadFile();        

    }      
          
}
In the Developer console I see that this lines of the controller are not covered :

- public string fileName

-   Attachment myAttachment  = new Attachment();
    myAttachment.Body = fileBody;
    myAttachment.Name = fileName;
    myAttachment.ParentId = recId;
    insert myAttachment;
                        
           pr = new PageReference('/' + myAttachment.Id);
           pr.setRedirect(true);
           return pr;

Thank you.
Ludivine
Hello,

I want to extract metadata for our approval processes in an excel file to do some clean up and possibly merge several in one so that we can extend our limit as we have a few left among the 500 offered by salesforce. Half of them are inactive and as we don't want to delete our records we are not able to free them.
So I would like to know your best practices or even better the SOQL query to retrieve these details.
I need to get the list of Approval processes by Name, creation date, last modified date, entry criteria.
Could you advise how to do that? Thank you very much for your help.
Kind Regards,
Ludivine
Hello,

I have created a lightning component in sandbox to display the lock/ Unlock icon on my record Page.
This needs to create the following Apex method:
public class UnlockRecordUtil {
  @AuraEnabled
    public static Boolean islocked(String recordId){
       return Approval.isLocked(Id.ValueOf(recordId));
     }
    @AuraEnabled
    public static boolean unlockRecord(String objId){
        List<String> unlockrec = new List<string>();
        unlockrec.add(objId);
        Approval.UnlockResult[] unlockedRersult = Approval.unlock(unlockrec);
        return true;
    }
    @AuraEnabled
    public static Boolean LockRecords(String objId){
        List<Account> sobjectre = [Select Id FROM Account WHERE ID =:objId];
        Approval.LockResult[] lrList = Approval.lock(sobjectre, false);
    return true;
    }
}
However, I don't know how to do the test class for this ligthning component.
I have tried to fire approval from my test class but it is not testing these aura method...
Mant thanks in advance.
Best Regards.
Hi dreamteam,
I have made a redirection page for a related object on the account page, also available on opportunity page.
The account name is populating fine in both objects, but not my other picklists Business_group and Business_unit, the values are not showing in the form. However I see these values in the url of this new page...

My Apex Controller :

public without sharing class FTSRedirectController{
@TestVisible

    public final Field_Technical_Service__c fts;
    
    public Opportunity opp              {get;set;}
    public Account acc                  {get;set;}
    public String currencyCode          {get;set;}
    public String accId                 {get;set;}    
    public String defaultBusinessGroup  {get;set;}
    public String defaultBusinessUnit   {get;set;}
 

 public FTSRedirectController(ApexPages.StandardController stdController){
    
     //get the current record
        this.fts=(Field_Technical_Service__c)stdController.getRecord();
        
        user u = [SELECT Business_Group__c, Business_Unit__c, User_Division__c, User_Subdivision__c 
                  FROM User 
                  WHERE Id = :UserInfo.getUserId()];       
           
           
         // If a new Fts is opened from an Oppty:
         if(fts.Action_Name__c != null) {  
         opp = [
                    SELECT Id,Business_Group__c,Business_Unit__c, Manufacturing_plant__c, Sector__c, Vertical__c, Sub_Vertical__c, Expected_Sales_Revenue__c, CurrencyIsoCode, Account.Name, Expected_Units_Annually__c, AccountId
                    FROM Opportunity
                    WHERE Id = :fts.Action_Name__c
            ];
            
            //set the values :
            accId = opp.Account.Name;            
            currencyCode = opp.CurrencyIsoCode;                                
            defaultBusinessGroup = opp.Business_Group__c;
            defaultBusinessUnit = opp.Business_Unit__c;                 
        }
        
        system.debug('oppty : defaultBusinessUnit :'+defaultBusinessUnit+'defaultBusinessgroup:'+defaultBusinessGroup);
        
        
        // If a new Fts form is opened from an account:
        if(fts.Account_Name__c != null) {
        
            acc = [
                    SELECT Id,Business_group__c, Business_unit__c, name
                    FROM Account
                    WHERE Id = :fts.Account_Name__c or Id = :accId
            ];
             //set the values :
            accId = acc.Name;
            defaultBusinessGroup = acc.Business_Group__c;
            defaultBusinessUnit = acc.Business_Unit__c;
        } 
}
  public PageReference redirect()
    {
      String str='';
      
      str='/a4l/e?retURL=%2F001%2Fo&cancelURL=%2F001%2Fo&nooverride=1&CF00Nw0000006nT2m=='+accId+'&CF00Nw0000006nT2s=='+defaultBusinessGroup+'&CF00Nw0000006nT2t=='+defaultBusinessUnit+'&CF00Nw0000006nT2m=='+opp.id ;
     
     PageReference r= new PageReference(str);
        r.setRedirect(true);

        return r;
      
    }
}
----------------------------------------------------------------------------------------------------------------------------------------------------
My url :
https://amcorltd--uat.cs83.my.salesforce.com/a4l/e?cancelURL=%2F001%2Fo&CF00Nw0000006nT2m=%3DAaren+Laboratories_Ontario%2C+CA&CF00Nw0000006nT2s=%3DAmcor+Flexibles+Americas&CF00Nw0000006nT2t=%3DHealthcare+N.A.&nooverride=1&retURL=%2F001%2Fo

Do you Know if there is something special for picklist fields values?
Thank you,
Regards,
Ludi
Hi experts,
I need your help to build a formula as I am stuck here and don't know how to achieve the result that I want.

This is my formula :
if(ISNULL(Benefit_End_Date__c),12,round((Benefit_End_Date__c - Expected_Impact_Date__c),2)/30)
This formula returns 0 when the difference between the 2 dates are less than 30 days, so when there is less than a month.
In that case I would like to return 1. How cvan I do that?
It blocks me to implement a method as each time the result is 0 I get an error from Apex ...
Many thanks in advance for the time you will spend on my issue :)
Ludivine
Hi,

I need your help to write a trigger on Tasks which calculates the total Costs from all the SubTasks on a Project Stage
and update it in the Main task fields. I have an error when I try to save the trigger:
Compile Error: Loop with query must provide a statement

trigger IMSSumCostsOnTasks on TASKRAY__Project_Task__c (After insert, After Update) {
// TaskRay Project Task is a related Task object from TaskRay project object.
Set<Id> setTaskRayTaskIds=new Set<Id>();
For (TASKRAY__Project_Task__c c : trigger.new)
setTaskRayTaskIds.add(c.id);
//List of sub Tasks : Sub Tasks are those with empty value in Project stage
List<TASKRAY__Project_Task__c>ListTasks1 =[SELECT TASKRAY__Project__c,Type__c 
from TASKRAY__Project_Task__c 
where id in :setTaskRayTaskIds
AND Project_Stage__c = null 
AND TASKRAY__Project__c!=null
and type__c in ( 'Idea', 'Feasibility', 'Development', 'Validation and pre-launch','Feasibility','Launch')];

/*Main Tasks to update : main tasks are created from the project , 
Previously at task creation, the selected value in Type field is copied in project_Stage field to identify 
them as Main tasks.(Type values are  'Idea', 'Feasibility', 'Development', 'Validation and pre-launch','Feasibility','Launch')*/
List<TASKRAY__Project_Task__c>lstMainTasks1 = [SELECT TASKRAY__Project__c,Project_Stage__c from TASKRAY__Project_Task__c 
where id in :setTaskRayTaskIds 
AND TASKRAY__Project__c!=null
AND Project_Stage__c in ( 'Idea', 'Feasibility', 'Development', 'Validation and pre-launch','Feasibility','Launch')];

/*We want to update the costs & resources found in the Sub tasks by Type in the Main Stage Task
For Main Task 1, if Project Stage= idea, Each Type= Idea of subTasks of the same project have to be sum up*/

For( AggregateResult result:[Select TASKRAY__Project__c,Type__c,
//Sum Resources in planned fields on the sub tasks:
sum(FIR_R_D_Planned__c),
sum(FIR_CoE_planned__c),
sum(FIR_Marketing_Sales_planned__c),
sum(FIR_Plant_Technical_Planned__c),
sum(FIR_Field_Technical_Services_Planned__c),
sum(FIR_Other_Resources_Planned__c),
//Sum Costs in Planned fields
sum(FIC_Trials_Planned__c),
sum(FIC_Technical_Outsourcing_Planned__c),
sum(FIC_Market_Intelligence_Planned__c),
Sum(FIC_Marcom_planned__c),
Sum(FIC_Other_Cost_planned__c),
//Sum Resources in Actual fields on the sub tasks:
sum(FIR_R_D_Actual__c),
sum(FIR_CoE_Actual__c),
sum(FIR_Marketing_Sales_Actual__c),
sum(FIR_Plant_Technical_Actual__c),
sum(FIR_Field_Technical_Services_Actual__c),
sum(FIR_Other_Resources_Actual__c),
sum(FIC_Trials_Actual__c),
sum(FIC_Technical_Outsourcing_Actual__c),
sum(FIC_Market_Intelligence_Actual__c),
Sum(FIC_Marcom_Actual__c),
//Sum costs in Actual Fields
Sum(FIC_Other_Cost_Actual__c)
from TASKRAY__Project_Task__c 
WHERE (
Id IN :setTaskRayTaskIds 
AND Project_Stage__c = null 
AND TASKRAY__Project__c != null 
AND Type__c in ( 'Idea', 'Feasibility', 'Development', 'Validation and pre-launch','Feasibility','Launch') 
// Remove from the query all empty resources or costs to avoid too many sql limitation error
AND(
(FIR_R_D_Planned__c > 0) 
OR(FIR_CoE_planned__c > 0) 
OR(FIR_Marketing_Sales_planned__c> 0) 
OR(FIR_Field_Technical_Services_Planned__c > 0) 
OR(FIR_Other_Resources_Planned__c> 0) 
OR(FIC_Trials_Planned__c> 0) 
OR (FIC_Technical_Outsourcing_Planned__c> 0) 
OR (FIC_Market_Intelligence_Planned__c> 0) 
OR(FIR_Plant_Technical_Planned__c>0)
OR (FIC_Marcom_planned__c> 0) 
OR (FIC_Other_Cost_planned__c> 0) 
OR (FIR_R_D_Actual__c> 0) OR (FIR_CoE_Actual__c> 0) 
OR (FIR_Marketing_Sales_Actual__c> 0) 
OR (FIR_Plant_Technical_Actual__c> 0) 
OR (FIR_Field_Technical_Services_Actual__c> 0) 
OR (FIR_Other_Resources_Actual__c> 0) 
OR (FIC_Trials_Actual__c> 0) 
OR (FIC_Technical_Outsourcing_Actual__c> 0) 
OR (FIC_Market_Intelligence_Actual__c> 0) 
OR (FIC_Marcom_Actual__c> 0) 
OR (FIC_Other_Cost_Actual__c> 0)
)
)
GROUP BY TASKRAY__Project__c,Type__c]);

// to start, Let's try to update the  field FIR_R_D_Planned__c               
{
        for(TASKRAY__Project_Task__c p : lstMainTasks1 )
        {
            if(result.get('TASKRAY__Project__c') == p.TASKRAY__Project__c)
            {
            if(result.get('Type__c') == p.project_stage__c){
                if(p.FIR_R_D_Planned__c == null)
                {
                    p.FIR_R_D_Planned__c = 0;
                }
                //p.Amount__c = p.Amount__c + Decimal.ValueOf(String.ValueOf(result.get('expr0')));
                p.FIR_R_D_Planned__c =p.FIR_R_D_Planned__c + Decimal.ValueOf(String.ValueOf(result.get('expr0')));
                ListMainTasks1.add(p);
            }
        }}
    }
update lstMainTasks1 ;
}
Hi all,

We want to use Cloud Scheduler but we get an error due to a trigger on Event Update/insert, when we disable this trigger Cloud Scheduler works perfectly.
Can we amend this trigger in order to avoid it to fire when we use Cloud scheduler for a meeting?
trigger Event_On_Update on Event (before update) {

    // Initialise ID maps for related sObjects
    map<Id, Contact> mapContact   = new map<Id, Contact>();
    map<Id, Lead> mapLead         = new map<Id, Lead>();
    map<Id, Contract> mapContract = new map<Id, Contract>();
    map<Id, Account> mapAccount   = new map<Id, Account>();
    map<Id, Opportunity> mapOpp   = new map<Id, Opportunity>();
    
    // Loop through event and fill the ID maps
    for(Event sEvent : trigger.new)
    {
        if(sEvent.WhoId != null && String.ValueOf(sEvent.WhoId).startsWith('003')){
          mapContact.put(sEvent.WhoId, null);
        }
        if (sEvent.WhoId != null && String.ValueOf(sEvent.WhoId).startsWith('00Q')){
          mapLead.put(sEvent.WhoId, null);
        }
        
        if(sEvent.WhatId != null && String.ValueOf(sEvent.WhatId).startsWith('001')){
          mapAccount.put(sEvent.WhatId, null);
        }
        if(sEvent.WhatId != null && String.ValueOf(sEvent.WhatId).startsWith('800')){
          mapContract.put(sEvent.WhatId, null);
        }
        if(sEvent.WhatId != null && String.ValueOf(sEvent.WhatId).startsWith('006')){
          mapContract.put(sEvent.WhatId, null);
        }
    }
    
    // Fill the Id -- > sObject maps for Contacts
    for(Contact arrContact : [
                                    select  Id,
                                            Account.Name,
                                            Name
                                    from    Contact
                                    where   id in :mapContact.keySet()
                                ])
    {
  
        mapContact.put(arrContact.Id, arrContact );
    }
    // Fill the Id -- > sObject maps for Leads
    for(Lead arrLead : [
                                    select  Id,
                                            Name,
                                            Company
                                    from    Lead
                                    where   id in :mapLead.keySet()
                                ])
    {
        mapLead.put(arrLead.Id, arrLead );
    }
    
    
    // Fill the Id -- > sObject maps for Contracts
    for(Contract arrContract : [
                                    select  Id,
                                            Account.Name,
                                            Contract_Name_Region_Location__c
                                    from    Contract
                                    where   id in :mapContract.keySet()
                                ])
    {
        mapContract.put(arrContract.Id, arrContract );
    }
    // Fill the Id -- > sObject maps for Opportunities
    for(Opportunity arrOpp : [
                                    select  Id,
                                            Account.Name
                                    from    Opportunity
                                    where   id in :mapOpp.keySet()
                                ])
    {
        mapOpp.put(arrOpp.Id, arrOpp );
    }
    // Fill the Id -- > sObject maps for Accounts
    for(Account arrAccount: [
                                    select  Id,
                                            Name
                                    from    Account
                                    where   id in :mapAccount.keySet()
                                ])
    {
        mapAccount.put(arrAccount.Id, arrAccount);
    }
    
    for(Event sEvent : trigger.new)
    {
        Contact thisContact    = mapContact.get(sEvent.WhoId);
        Lead    thisLead       = mapLead.get(sEvent.WhoId);
        
        Contract thisContract  = mapContract.get(sEvent.WhatId);
        Account  thisAccount   = mapAccount.get(sEvent.WhatId);
        Opportunity thisOpp    = mapOpp.get(sEvent.WhatId);
        
         //Update dates for Event
        sEvent.DisplayDateStart__c = sEvent.StartDateTime.format();
        sEvent.DisplayDateEnd__c = sEvent.EndDateTime.format();

        if(thisContact != null)
        {
          sEvent.DisplayRelatedWho__c = thisContact.Name + ', ' + thisContact.Account.Name;
        }
        if(thisLead != null)
        {
          sEvent.DisplayRelatedWho__c = thisLead.Name + ', ' + thisLead.Company;
        }
        
        if(thisContract != null)
        {
          sEvent.DisplayRelatedTo__c = thisContract.Contract_Name_Region_Location__c + ', ' + thisContract.Account.Name;
        }
        if(thisAccount != null)
        {
          sEvent.DisplayRelatedTo__c = thisAccount.Name;
        }
        if(thisOpp != null)
        {
          sEvent.DisplayRelatedTo__c = thisOpp.Name + ', ' + thisOpp.Account.Name;
        }
   
}

}

 
Dear Team,

I need help to buid a SOql query.
I would like to retrieve some fields of opportunity and Contract object related to TargetObjectId :

SELECT TargetObjectid,(select actor.name from Workitems),
(SELECT StepStatus, Actor.Name FROM Steps),
(Select RecordType.Name, Status from Opportunities where Id in ProcessInstance.TargetObjectId)
​(Select RecordType.Name, Status from Contracts where Id in ProcessInstance.TargetObjectId)
FROM ProcessInstance where Status = 'Pending'

Unfortunatly it gives me an error : Unknown error parsing query
Can you help me to build this query properly?
Hello,

Can you give me the correct statement to get the Id of the Approver in a pending Approval process in my test class?

In my org, when we create an Opportunity, the record is automatically submitted for Approval thanks to the Approval Process found.
I have created a similar action in my test class and I need to add the statement to retrieve the id of the Approver to Approve the record for him.
And there I am struggling...

The error I get in the Apex Test Result :
System.DmlException: Process failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []

The error is in there : 
reqc.setNextApproverIds(new Id[] {UserInfo.getUserId()});
but I have tried a lot of things without success...

I use that method :

        // Instantiate the new ProcessWorkitemRequest object and populate it         
        Approval.ProcessWorkitemRequest reqc = new Approval.ProcessWorkitemRequest();
        reqc.setComments('Approving request.');
        reqc.setAction('Approve');
        // Approver is Marco Isenmann '00520000002DPkK&tab'
        reqc.setNextApproverIds(new Id[] {UserInfo.getUserId()});
        
        // Use the ID from the newly created item to specify the item to be worked             
        reqc.setWorkitemId(newWorkItemIds1.get(0));
        
        // Submit the request for approval              
        Approval.ProcessResult resultc =  Approval.process(reqc);
        
        // Verify the results             
        System.assert(resultc.isSuccess(), 'Result Status:'+resultc.isSuccess());

Thanks a lot for your help.
Hello,

Can someone give me the correct statement to get the Id of the Approver in a pending Approval process in my test class?

In my org, when we create an Opportunity, the record is automatically submitted for Approval thanks to the Approval Process found.
I have created a similar action in my test class and I need to add the statement to retrieve the id of the Approver to Approve the record for him.
And there I am struggling...

The error I get in the Apex Test Result :
System.DmlException: Process failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []

The error is in there : 
reqc.setNextApproverIds(new Id[] {UserInfo.getUserId()});
but I have tried a lot of things without success...

I use that method :

        // Instantiate the new ProcessWorkitemRequest object and populate it         
        Approval.ProcessWorkitemRequest reqc = new Approval.ProcessWorkitemRequest();
        reqc.setComments('Approving request.');
        reqc.setAction('Approve');
        // Approver is Marco Isenmann '00520000002DPkK&tab'
        reqc.setNextApproverIds(new Id[] {UserInfo.getUserId()});
        
        // Use the ID from the newly created item to specify the item to be worked             
        reqc.setWorkitemId(newWorkItemIds1.get(0));
        
        // Submit the request for approval              
        Approval.ProcessResult resultc =  Approval.process(reqc);
        
        // Verify the results             
        System.assert(resultc.isSuccess(), 'Result Status:'+resultc.isSuccess());

Thanks a lot for your help.
We are facing an issue with this view when the owner of the lead is assingned to a queue.
When a member of this queue opens the lead, it remains unread.
Salesforce support said this may be achieved with a trigger.
I wonder how I can write a trigger to update a record in a view?
All I am aware with trigger is the possibility to update a record if it is new or edited.
I don't know how to update a record with a trigger just by viewing it.
Do you have an example or a tutorial to share?
Thanks in advance for your help.
 
I want in my test trigger to update an opportunity.
How can  I get the Opportunity.id that I have just inserted instead of taking the opportunity.name?
@isTest
private class TestFireApproval_Trigger {

    private static testMethod void triggersTestFireApprovalAFEA(){
        
        Profile p = [select id from profile where name='Standard User'];
        User u = new User(alias = 'standt', email='standarduser4@testorg.com',emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
        localesidkey='en_US', profileid = p.Id, timezonesidkey='America/Los_Angeles', username='TESTUSER23@testorg.com');
        
        System.runAs(u) {  


//Create a new Opportunity for AFEA

        Opportunity Op = new Opportunity();

 // Fill in mandatory fields       
        Op.stageName ='Idea Action';
        Op.CurrencyIsoCode ='EUR';
        Op.Accountid ='00120000003XRRY';//'Amcor Ltd';
        Op.Business_group__c = 'Amcor Flexibles Europe & Americas';
        Op.Business_Unit__c ='FAME and extrusion';
        Op.Division__c ='AF Cambe';
        Op.Manufacturing_plant__c ='Cambe';
        Op.Step_change__c ='N/A';
        Op.industry__c ='Capsules';
        Op.Segment__c='Capsules';
        Op.Sub_Segment__c ='Capsules';     
        Op.Type = 'Volume Change';
        Op.Detailed_Action_Type__c = 'New Amcor Product Innovation';
        Op.Action_Risk__c ='Low';
        Op.budgeted_Action__c ='No';
        Op.Value_Plus_Site_Review__c = 'No';
        Op.ongoing__c ='Yes';
        Op.Customer_Value__c ='No';
        Op.CloseDate = system.today();        
        Op.Unadj_Expected_Annual_Impact__c = 30000;
        Op.Expected_Implementation_Date__c = system.today();
        Op.Expected_Impact_Date__c = system.today();
        Op.Expected_PM_of_New_Volume__c =30;
        Op.Expected_Units_Annually__c =100000;
        Op.Unit_of_Measure__c ='MSI';
        Op.Expected_Sales_Revenue__c =500000;
        Op.name ='TestFireApproval1'+ system.now();
        Op.Actual_Implementation_Date__c = system.today();
            
        try{
            insert Op; 

            } 
        catch (System.DmlException e){
            System.debug('we caught a dml exception: ' + e.getDmlMessage(0));  
            
           // String OpId1;
          //  OpId1 = Op.Id; 
        } 


//--> Select the record        
        Opportunity B1 = [Select Id,
             stageName,
             Expected_Impact_Date__c,
             Expected_Units_Annually__c,
             Expected_Sales_Revenue__c,
             Expected_PM_of_New_Volume__c,
             Actual_Implementation_Date__c,
             Actual_Impact_Date__c,
             Actual_Units_Annually__c,
             Unadjusted_Actual_Annual_Impact__c,
             Actual_Sales_Revenue__c 
                           from Opportunity 
                            where name ='TestFireApproval1'];
                            //--->Where Id =  OpId1 ;
            // ----->How to find the Id of Opportunity above?? 

            update B1;

Thanks.
Hi all,

How can I create a formula field to display the Related To Account Name on my Event Page?
When I customize the formula, I am only able to find the WhatId but how can I do to add a WhatId or WhoId.Account.Name field?

Many thanks,
Regards,
Ludivine
Dear all,

I want to display a date field on my contract page only when this date is not null.
But something is wrong in the rendered statement, It displays an error message instead of nothing when the date is null :

Content cannot be displayed : The value "null" is not valid for operator '<='

My Visualforce page :

<apex:page sidebar="false" standardController="Contract" rendered="{!AND(contract.Reminder_Date__c<=today(),contract.Contract_Extension_Date__c<=null)}">
<font color="#595959" size="2"> <b>Contract Extension date</b> &nbsp;&nbsp;&nbsp; </font>
<apex:outputfield value="{!contract.Contract_Extension_Date__c}" />
</apex:page>



Any ideas?
Thanks,
Ludivine
Hi,

Is SFDC offering a solution for field technical service support?
It can be already in SFDC or an app we need to buy.
Dear all,

I have amended a trigger in my org.
Pb is when I validate it in production I got an error message.
I think this is because my trigger has 0% code coverage.
Could you tell me how to write the test trigger on this function that fires Approval on Opportunities?

Here is the trigger that I want to implement :

trigger fireApproval on Opportunity (after insert, after update){
if(runCheck.runOnce())    {
  for (Opportunity Oppty: Trigger.new){
        if(Oppty.StageName == 'Impact Action' && (trigger.isInsert || trigger.oldMap.get(Oppty.id).StageName != 'Impact Action') && 
                    ((Oppty.Business_Group__c == 'Australasia' && Oppty.Business_Unit__c=='Corrugated')&& 
                            (Oppty.Division__c== 'QLD' ||Oppty.Division__c== 'National' ||
                             Oppty.Division__c== 'NSW' ||
                            Oppty.Division__c== 'SA' ||
                             Oppty.Division__c== 'VIC/TAS'||
                            Oppty.Division__c== 'WA'))){           
                             //modfied 2010-07-05 by Lee Tsiamis - Velteo
            //This will auto submit for approval.
            Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
            req1.setComments('Submitting request for approval.');
            String accountID = Oppty.id;
            req1.setObjectId(accountID);

            // 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());
        }
        
        /*
         // --------------------------------------------- //
        // added by Ludivine Dos REis- Amcor, 2013-06-19 //
        // --------------------------------------------- //
        else if(Oppty.StageName == 'Planned - market'  
        && trigger.oldMap.get(Oppty.id).StageName != 'Planned - market'  
        && Oppty.Business_Group__c == 'Amcor Flexibles Europe & Americas'
                            )
                            {         
    //This will auto submit for approval.
    
            Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
            req1.setComments('Submitting request for approval.');
            String accountID = Oppty.id;
            req1.setObjectId(accountID);

            // Submit the approval request for processing 
            Approval.ProcessResult result = Approval.process(req1);
            // Verify the result 
            System.assert(result.isSuccess());
            System.assertEquals('Pending', result.getInstanceStatus(), 'Instance Status'+result.getInstanceStatus());
        }     */        
                     
         // --------------------------------------------- //
        // added by Matt Watson - Salesforce, 2012-02-20 //
        // --------------------------------------------- //
        // triggers "AA Beverage" approval processes (x3)
        else if(Oppty.Business_Group__c == 'Australasia' && Oppty.Business_Unit__c== 'Beverage' && 
                        (
                        (Oppty.StageName == 'Planned Action' && (trigger.isInsert ||
                        trigger.oldMap.get(Oppty.id).StageName != 'Planned Action')) ||
                        (Oppty.StageName == 'Impact Action' && (trigger.isInsert ||
                        trigger.oldMap.get(Oppty.id).StageName != 'Impact Action')) 
                        )
                )
        {            
            //This will auto submit for approval.
            Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
            req1.setComments('Submitting request for approval.');
            String accountID = Oppty.id;
            req1.setObjectId(accountID);

            // 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());
        }
        
        
          }
}
    }

Many thanks for your help.
Dear all,

I don't manage to have at least 1% code coverage for my trigger , could you help me please?

What it does, From clicktools url, when a contact answers 'Yes' on the Survey, as soon as it is created in Salesforce , 
this triggers looks in the Field Q6_NeedAmcorToContactYou__c, if value is 'Yes', it creates an Event with the following values.

trigger TriggerEventForCustomerToContact on Amcor_Surveys__c (After insert)
{
     set<id> setamcorIds= new set<id>();
For (Amcor_Surveys__c ams : trigger.new)
{
  If(ams.Q6_NeedAmcorToContactYou__c == 'Yes')
  {
     setamcorIds.add(ams.Id);
  }
}

list<Amcor_Surveys__c> listSelectedAmcor= [select Account_ID__r.OwnerId,Contact_ID__c
                                            from  Amcor_Surveys__c
              where id in :setamcorIds];
System.debug('Creating event record');

list<Event> listEventToCreate= new list<Event> ();
for(Amcor_Surveys__c ams :listSelectedAmcor)
{
  //create an event record
  Event ev = new Event();
  Ev.Business_group__c ='Amcor Flexibles Europe & Americas';
  Ev.Whatid = ams.id;
  ev.RecordTypeId='012g00000004ajF';//'Visit Report VOC';
  ev.Type ='Customer Satisfaction Survey';
  ev.DurationInMinutes = 720;
  ev.Ownerid = ams.Account_ID__r.OwnerId;
  ev.whoId =ams.Contact_ID__c;
  ev.Subject ='Customer Satisfaction Survey - Customer contact' ;
  ev.objective__c = 'Improve Relationship';
  //System.debug('************ ' + system.today());
  Date startDate = system.today();
  ev.ActivityDate = startDate;
  ev.StartDateTime = Datetime.newInstanceGmt(startDate.year(), startDate.month(), startDate.day(), 0, 0, 9);
   ev.ActivityDateTime = Datetime.newInstanceGmt(startDate.year(), startDate.month(), startDate.day(), 0, 0, 09);
  Date EndDate = startdate +5;
  System.debug('Attempting to insert...');
  
  listEventToCreate.add(ev);
    }
try{
insert listEventToCreate;
}
catch(Exception e)
{
  System.debug(e.getMessage());
  }
}

Could you write it for me?
Many thanks for your help.

Dear all,

I am Struggling to find how to search the end of an email in my Apex Class.
I wrote this but it doesn't work somebody helps me?

//error message if non amcor email in Contact list
            Integer i = con.email.length();
            if (con.email.substring(con.email,i - 10,10) != '@amcor.com'){ 
                isDisabled = true;
                apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.ERROR, 'You cannot send an email to this person. Email is external from Amcor domain');
                apexpages.addmessage(msg);
                System.debug('@@DEBUG non amcor email: '+con);
                return null;
            }

The error message I got is as follow :

Error: Event_Ext Compile Error: Method does not exist or incorrect signature: [String].substring(String, Integer, Integer)

Many thanks

Hello !

 

I have begun a trigger to copy on the Actions page (Opportunity page) ,the picklist values of 3 fields from the Account related list

 

But I meet troubles to do the mapping.

 

I can't map the AccountId field from Oppty(Actions), I have the following error :

 

Error: Compile Error: Illegal assignment from Schema.SObjectField to String at line 30 column 10 

 

Here here my code... I have done my best using other existing triggers in my org but it is probably wrong...

 

Trigger UpdateIndustrySegmentSubSegment on Opportunity (Before insert,Before Update) 
{
    // Initialise ID maps for related sObjects
    map<Id, Account> mapAccount   = new map<Id, Account>();
    
    // Fill the Id -- > sObject maps for Accounts
  for(Account[] arrAccount: [
                                    select  Id,
                                            Name,industry__c,segment__c,sub_segment__c
                                    from    Account
                                   where   id in :mapAccount.keySet()
                                ])
   {
        for(Account sAccount : arrAccount)
        {
            mapAccount.put(sAccount.Id, sAccount);
        }
    }
    
   for(Opportunity sOppty : trigger.new)
    {
        
        Account  thisAccount   = mapAccount.get(sOppty.Account.Id);
 
        if(
        sOppty.Business_group__c == 'Amcor Flexibles Europe & Americas' && 
        //thisAccount.industry__c != null && 
        sOppty.RecordTypeId != '012200000002HdgAAE')
        
        {sOppty.industry__c = Account.industry__c;
        sOppty.segment__c = Account.segment__c;
        sOppty.sub_segment__c = Account.sub_segment__c;}
  
    }
}

 Thanks a lot for your help

Hi all,

In my company, we have several admins working in the same instance.
I am in charge of integrations, twice a week I do the deployments in sandbox or in production for the awaiting packages.
I would like to send a report of what is waiting for deployment before integration and after deployment, a report of the list of packages that have been deployed.
Any idea?
Hi dev team,

I have created a custom object with questions and corresponding marks detailed in several text and number fields to be displayed in a specific graph. The request is to create a Spider Chart.
Is there a existing Ligtning component for this sort of chart?
Or do you advise anything else?

Thank you.
Best Regards,
Ludivine
Hi,

I have created a Visualforce Page to be able to upload attachment in Salesforce for X-Author application since Salesforce doesn't allow anymore to create any attachments in attachment object.
Everything is working as expected. I just need help to get full code coverage.
Only 47% with the test cIass I wrote. Could you tell me why I am not able to cover it all and what is wrong?
 
//VF Page :
<apex:page standardController="Apttus_XApps__Application__c" extensions="AttachmentUploadController">
  <apex:form >
      <apex:pageBlock title="Upload Attachment">
            <apex:inputFile style="width:100%" id="fileToUpload" value="{!fileBody}" filename="{!fileName}" />
            <apex:commandButton value="Upload Attachment" action="{!UploadFile}"/>
       </apex:pageBlock>
  </apex:form>
</apex:page>

//Controller :
public with Sharing class AttachmentUploadController {

    public Id recId
    {    get;set;    }
    
    public AttachmentUploadController(ApexPages.StandardController ctlr)
    {
       recId = ApexPages.CurrentPage().getParameters().get('Id');      
    }
    
    public string fileName 
    {    get;set;    }
    
    public Blob fileBody 
    {    get;set;    }
  
    public PageReference UploadFile()
    {    
        PageReference pr;
        if(fileBody != null && fileName != null)
        {
          Attachment myAttachment  = new Attachment();
          myAttachment.Body = fileBody;
          myAttachment.Name = fileName;
          myAttachment.ParentId = recId;
          insert myAttachment;
            
           pr = new PageReference('/' + myAttachment.Id);
           pr.setRedirect(true);
           return pr;
        }
        return null;
    }    
}


// Test method:
@isTest
public class AttachmentUploadController_Test{

    static testMethod void testCase1() {        
        Id recID;    
    PageReference pr;
        String filename = 'Att1';
        Blob Body = Blob.valueof('Unit Test Attachment Body');

        Apttus_XApps__Application__c objApp = New Apttus_XApps__Application__c();
        objApp.Name = 'Test Upload Attachment';
        objApp.Apttus_XApps__Activated__c = True;
        objApp.Apttus_XApps__UniqueId__c ='123ADCDEFG';
        insert objApp;
        
        recID = objApp.Id;      
        
        AttachmentUploadController controller=new AttachmentUploadController(new ApexPages.StandardController(objApp));        
        
        Attachment myAttachment =New attachment();
        myAttachment.name =filename;
        myAttachment.Body = Body;
        myAttachment.ParentId = recID;
        controller.UploadFile();        

    }      
          
}
In the Developer console I see that this lines of the controller are not covered :

- public string fileName

-   Attachment myAttachment  = new Attachment();
    myAttachment.Body = fileBody;
    myAttachment.Name = fileName;
    myAttachment.ParentId = recId;
    insert myAttachment;
                        
           pr = new PageReference('/' + myAttachment.Id);
           pr.setRedirect(true);
           return pr;

Thank you.
Ludivine
Hello,

I have created a lightning component in sandbox to display the lock/ Unlock icon on my record Page.
This needs to create the following Apex method:
public class UnlockRecordUtil {
  @AuraEnabled
    public static Boolean islocked(String recordId){
       return Approval.isLocked(Id.ValueOf(recordId));
     }
    @AuraEnabled
    public static boolean unlockRecord(String objId){
        List<String> unlockrec = new List<string>();
        unlockrec.add(objId);
        Approval.UnlockResult[] unlockedRersult = Approval.unlock(unlockrec);
        return true;
    }
    @AuraEnabled
    public static Boolean LockRecords(String objId){
        List<Account> sobjectre = [Select Id FROM Account WHERE ID =:objId];
        Approval.LockResult[] lrList = Approval.lock(sobjectre, false);
    return true;
    }
}
However, I don't know how to do the test class for this ligthning component.
I have tried to fire approval from my test class but it is not testing these aura method...
Mant thanks in advance.
Best Regards.
Hi experts,
I need your help to build a formula as I am stuck here and don't know how to achieve the result that I want.

This is my formula :
if(ISNULL(Benefit_End_Date__c),12,round((Benefit_End_Date__c - Expected_Impact_Date__c),2)/30)
This formula returns 0 when the difference between the 2 dates are less than 30 days, so when there is less than a month.
In that case I would like to return 1. How cvan I do that?
It blocks me to implement a method as each time the result is 0 I get an error from Apex ...
Many thanks in advance for the time you will spend on my issue :)
Ludivine
Hi,

I need your help to write a trigger on Tasks which calculates the total Costs from all the SubTasks on a Project Stage
and update it in the Main task fields. I have an error when I try to save the trigger:
Compile Error: Loop with query must provide a statement

trigger IMSSumCostsOnTasks on TASKRAY__Project_Task__c (After insert, After Update) {
// TaskRay Project Task is a related Task object from TaskRay project object.
Set<Id> setTaskRayTaskIds=new Set<Id>();
For (TASKRAY__Project_Task__c c : trigger.new)
setTaskRayTaskIds.add(c.id);
//List of sub Tasks : Sub Tasks are those with empty value in Project stage
List<TASKRAY__Project_Task__c>ListTasks1 =[SELECT TASKRAY__Project__c,Type__c 
from TASKRAY__Project_Task__c 
where id in :setTaskRayTaskIds
AND Project_Stage__c = null 
AND TASKRAY__Project__c!=null
and type__c in ( 'Idea', 'Feasibility', 'Development', 'Validation and pre-launch','Feasibility','Launch')];

/*Main Tasks to update : main tasks are created from the project , 
Previously at task creation, the selected value in Type field is copied in project_Stage field to identify 
them as Main tasks.(Type values are  'Idea', 'Feasibility', 'Development', 'Validation and pre-launch','Feasibility','Launch')*/
List<TASKRAY__Project_Task__c>lstMainTasks1 = [SELECT TASKRAY__Project__c,Project_Stage__c from TASKRAY__Project_Task__c 
where id in :setTaskRayTaskIds 
AND TASKRAY__Project__c!=null
AND Project_Stage__c in ( 'Idea', 'Feasibility', 'Development', 'Validation and pre-launch','Feasibility','Launch')];

/*We want to update the costs & resources found in the Sub tasks by Type in the Main Stage Task
For Main Task 1, if Project Stage= idea, Each Type= Idea of subTasks of the same project have to be sum up*/

For( AggregateResult result:[Select TASKRAY__Project__c,Type__c,
//Sum Resources in planned fields on the sub tasks:
sum(FIR_R_D_Planned__c),
sum(FIR_CoE_planned__c),
sum(FIR_Marketing_Sales_planned__c),
sum(FIR_Plant_Technical_Planned__c),
sum(FIR_Field_Technical_Services_Planned__c),
sum(FIR_Other_Resources_Planned__c),
//Sum Costs in Planned fields
sum(FIC_Trials_Planned__c),
sum(FIC_Technical_Outsourcing_Planned__c),
sum(FIC_Market_Intelligence_Planned__c),
Sum(FIC_Marcom_planned__c),
Sum(FIC_Other_Cost_planned__c),
//Sum Resources in Actual fields on the sub tasks:
sum(FIR_R_D_Actual__c),
sum(FIR_CoE_Actual__c),
sum(FIR_Marketing_Sales_Actual__c),
sum(FIR_Plant_Technical_Actual__c),
sum(FIR_Field_Technical_Services_Actual__c),
sum(FIR_Other_Resources_Actual__c),
sum(FIC_Trials_Actual__c),
sum(FIC_Technical_Outsourcing_Actual__c),
sum(FIC_Market_Intelligence_Actual__c),
Sum(FIC_Marcom_Actual__c),
//Sum costs in Actual Fields
Sum(FIC_Other_Cost_Actual__c)
from TASKRAY__Project_Task__c 
WHERE (
Id IN :setTaskRayTaskIds 
AND Project_Stage__c = null 
AND TASKRAY__Project__c != null 
AND Type__c in ( 'Idea', 'Feasibility', 'Development', 'Validation and pre-launch','Feasibility','Launch') 
// Remove from the query all empty resources or costs to avoid too many sql limitation error
AND(
(FIR_R_D_Planned__c > 0) 
OR(FIR_CoE_planned__c > 0) 
OR(FIR_Marketing_Sales_planned__c> 0) 
OR(FIR_Field_Technical_Services_Planned__c > 0) 
OR(FIR_Other_Resources_Planned__c> 0) 
OR(FIC_Trials_Planned__c> 0) 
OR (FIC_Technical_Outsourcing_Planned__c> 0) 
OR (FIC_Market_Intelligence_Planned__c> 0) 
OR(FIR_Plant_Technical_Planned__c>0)
OR (FIC_Marcom_planned__c> 0) 
OR (FIC_Other_Cost_planned__c> 0) 
OR (FIR_R_D_Actual__c> 0) OR (FIR_CoE_Actual__c> 0) 
OR (FIR_Marketing_Sales_Actual__c> 0) 
OR (FIR_Plant_Technical_Actual__c> 0) 
OR (FIR_Field_Technical_Services_Actual__c> 0) 
OR (FIR_Other_Resources_Actual__c> 0) 
OR (FIC_Trials_Actual__c> 0) 
OR (FIC_Technical_Outsourcing_Actual__c> 0) 
OR (FIC_Market_Intelligence_Actual__c> 0) 
OR (FIC_Marcom_Actual__c> 0) 
OR (FIC_Other_Cost_Actual__c> 0)
)
)
GROUP BY TASKRAY__Project__c,Type__c]);

// to start, Let's try to update the  field FIR_R_D_Planned__c               
{
        for(TASKRAY__Project_Task__c p : lstMainTasks1 )
        {
            if(result.get('TASKRAY__Project__c') == p.TASKRAY__Project__c)
            {
            if(result.get('Type__c') == p.project_stage__c){
                if(p.FIR_R_D_Planned__c == null)
                {
                    p.FIR_R_D_Planned__c = 0;
                }
                //p.Amount__c = p.Amount__c + Decimal.ValueOf(String.ValueOf(result.get('expr0')));
                p.FIR_R_D_Planned__c =p.FIR_R_D_Planned__c + Decimal.ValueOf(String.ValueOf(result.get('expr0')));
                ListMainTasks1.add(p);
            }
        }}
    }
update lstMainTasks1 ;
}
Hello,

Can you give me the correct statement to get the Id of the Approver in a pending Approval process in my test class?

In my org, when we create an Opportunity, the record is automatically submitted for Approval thanks to the Approval Process found.
I have created a similar action in my test class and I need to add the statement to retrieve the id of the Approver to Approve the record for him.
And there I am struggling...

The error I get in the Apex Test Result :
System.DmlException: Process failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []

The error is in there : 
reqc.setNextApproverIds(new Id[] {UserInfo.getUserId()});
but I have tried a lot of things without success...

I use that method :

        // Instantiate the new ProcessWorkitemRequest object and populate it         
        Approval.ProcessWorkitemRequest reqc = new Approval.ProcessWorkitemRequest();
        reqc.setComments('Approving request.');
        reqc.setAction('Approve');
        // Approver is Marco Isenmann '00520000002DPkK&tab'
        reqc.setNextApproverIds(new Id[] {UserInfo.getUserId()});
        
        // Use the ID from the newly created item to specify the item to be worked             
        reqc.setWorkitemId(newWorkItemIds1.get(0));
        
        // Submit the request for approval              
        Approval.ProcessResult resultc =  Approval.process(reqc);
        
        // Verify the results             
        System.assert(resultc.isSuccess(), 'Result Status:'+resultc.isSuccess());

Thanks a lot for your help.
Dear all,

I want to display a date field on my contract page only when this date is not null.
But something is wrong in the rendered statement, It displays an error message instead of nothing when the date is null :

Content cannot be displayed : The value "null" is not valid for operator '<='

My Visualforce page :

<apex:page sidebar="false" standardController="Contract" rendered="{!AND(contract.Reminder_Date__c<=today(),contract.Contract_Extension_Date__c<=null)}">
<font color="#595959" size="2"> <b>Contract Extension date</b> &nbsp;&nbsp;&nbsp; </font>
<apex:outputfield value="{!contract.Contract_Extension_Date__c}" />
</apex:page>



Any ideas?
Thanks,
Ludivine
Dear all,

I have amended a trigger in my org.
Pb is when I validate it in production I got an error message.
I think this is because my trigger has 0% code coverage.
Could you tell me how to write the test trigger on this function that fires Approval on Opportunities?

Here is the trigger that I want to implement :

trigger fireApproval on Opportunity (after insert, after update){
if(runCheck.runOnce())    {
  for (Opportunity Oppty: Trigger.new){
        if(Oppty.StageName == 'Impact Action' && (trigger.isInsert || trigger.oldMap.get(Oppty.id).StageName != 'Impact Action') && 
                    ((Oppty.Business_Group__c == 'Australasia' && Oppty.Business_Unit__c=='Corrugated')&& 
                            (Oppty.Division__c== 'QLD' ||Oppty.Division__c== 'National' ||
                             Oppty.Division__c== 'NSW' ||
                            Oppty.Division__c== 'SA' ||
                             Oppty.Division__c== 'VIC/TAS'||
                            Oppty.Division__c== 'WA'))){           
                             //modfied 2010-07-05 by Lee Tsiamis - Velteo
            //This will auto submit for approval.
            Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
            req1.setComments('Submitting request for approval.');
            String accountID = Oppty.id;
            req1.setObjectId(accountID);

            // 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());
        }
        
        /*
         // --------------------------------------------- //
        // added by Ludivine Dos REis- Amcor, 2013-06-19 //
        // --------------------------------------------- //
        else if(Oppty.StageName == 'Planned - market'  
        && trigger.oldMap.get(Oppty.id).StageName != 'Planned - market'  
        && Oppty.Business_Group__c == 'Amcor Flexibles Europe & Americas'
                            )
                            {         
    //This will auto submit for approval.
    
            Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
            req1.setComments('Submitting request for approval.');
            String accountID = Oppty.id;
            req1.setObjectId(accountID);

            // Submit the approval request for processing 
            Approval.ProcessResult result = Approval.process(req1);
            // Verify the result 
            System.assert(result.isSuccess());
            System.assertEquals('Pending', result.getInstanceStatus(), 'Instance Status'+result.getInstanceStatus());
        }     */        
                     
         // --------------------------------------------- //
        // added by Matt Watson - Salesforce, 2012-02-20 //
        // --------------------------------------------- //
        // triggers "AA Beverage" approval processes (x3)
        else if(Oppty.Business_Group__c == 'Australasia' && Oppty.Business_Unit__c== 'Beverage' && 
                        (
                        (Oppty.StageName == 'Planned Action' && (trigger.isInsert ||
                        trigger.oldMap.get(Oppty.id).StageName != 'Planned Action')) ||
                        (Oppty.StageName == 'Impact Action' && (trigger.isInsert ||
                        trigger.oldMap.get(Oppty.id).StageName != 'Impact Action')) 
                        )
                )
        {            
            //This will auto submit for approval.
            Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
            req1.setComments('Submitting request for approval.');
            String accountID = Oppty.id;
            req1.setObjectId(accountID);

            // 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());
        }
        
        
          }
}
    }

Many thanks for your help.
Dear all,

I don't manage to have at least 1% code coverage for my trigger , could you help me please?

What it does, From clicktools url, when a contact answers 'Yes' on the Survey, as soon as it is created in Salesforce , 
this triggers looks in the Field Q6_NeedAmcorToContactYou__c, if value is 'Yes', it creates an Event with the following values.

trigger TriggerEventForCustomerToContact on Amcor_Surveys__c (After insert)
{
     set<id> setamcorIds= new set<id>();
For (Amcor_Surveys__c ams : trigger.new)
{
  If(ams.Q6_NeedAmcorToContactYou__c == 'Yes')
  {
     setamcorIds.add(ams.Id);
  }
}

list<Amcor_Surveys__c> listSelectedAmcor= [select Account_ID__r.OwnerId,Contact_ID__c
                                            from  Amcor_Surveys__c
              where id in :setamcorIds];
System.debug('Creating event record');

list<Event> listEventToCreate= new list<Event> ();
for(Amcor_Surveys__c ams :listSelectedAmcor)
{
  //create an event record
  Event ev = new Event();
  Ev.Business_group__c ='Amcor Flexibles Europe & Americas';
  Ev.Whatid = ams.id;
  ev.RecordTypeId='012g00000004ajF';//'Visit Report VOC';
  ev.Type ='Customer Satisfaction Survey';
  ev.DurationInMinutes = 720;
  ev.Ownerid = ams.Account_ID__r.OwnerId;
  ev.whoId =ams.Contact_ID__c;
  ev.Subject ='Customer Satisfaction Survey - Customer contact' ;
  ev.objective__c = 'Improve Relationship';
  //System.debug('************ ' + system.today());
  Date startDate = system.today();
  ev.ActivityDate = startDate;
  ev.StartDateTime = Datetime.newInstanceGmt(startDate.year(), startDate.month(), startDate.day(), 0, 0, 9);
   ev.ActivityDateTime = Datetime.newInstanceGmt(startDate.year(), startDate.month(), startDate.day(), 0, 0, 09);
  Date EndDate = startdate +5;
  System.debug('Attempting to insert...');
  
  listEventToCreate.add(ev);
    }
try{
insert listEventToCreate;
}
catch(Exception e)
{
  System.debug(e.getMessage());
  }
}

Could you write it for me?
Many thanks for your help.

Dear all,

I am Struggling to find how to search the end of an email in my Apex Class.
I wrote this but it doesn't work somebody helps me?

//error message if non amcor email in Contact list
            Integer i = con.email.length();
            if (con.email.substring(con.email,i - 10,10) != '@amcor.com'){ 
                isDisabled = true;
                apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.ERROR, 'You cannot send an email to this person. Email is external from Amcor domain');
                apexpages.addmessage(msg);
                System.debug('@@DEBUG non amcor email: '+con);
                return null;
            }

The error message I got is as follow :

Error: Event_Ext Compile Error: Method does not exist or incorrect signature: [String].substring(String, Integer, Integer)

Many thanks
Dear all,

I have set up a workflow task to create a task each time the answer on my custom object is no.
It works but the Related To field is not populated!
How can  ido to get also this inforation in the task?

Thanks in advance.

My VP does not like the current process he uses to approve contracts and other objects.  He uses the "Items to Approve" component on the home page, but for each item, he clicks to go view the actual record with all the details.  Then he approves or denies, then has to click the home tab again to see the next item in his list.

 

I would like to add a similiar widget to the sidebar instead so that he doesn't have to click the home tab every time to see his list.

 

Has anyone done anything like this already?  I'm sure it's possible, but have no idea how to do it.

 

It doesn't have to look exactly like the current component, all I need is a list to show up on the sidebar.

 

Thanks!

Is there a way to create an event based on a field level trigger? I know you can do a field update, task, etc...but I am interested in creating an actual event so that it will show up in the calendar view with the times.
If not, is there a way to create a task that can house a time period (ex: 8:00a-12:00p) that will then show up on the calendar view?

  • February 24, 2009
  • Like
  • 1
Hi,

Why I cannot link Event to Account in relationship query, such as: Event.Account.Name ?

sq