• Sarah Robertson
  • NEWBIE
  • 30 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 19
    Questions
  • 9
    Replies
Hi wondering if anyone can help me - i've got 60% coverage here where am i going wrong ? 

class:
public class LinuxITMigrationOpenOpps{
        
    public PageReference doMigration()
    {   
        LinuxITMigrationOpenOpps.doMigrationOpenOpps();
        PageReference pg=new pagereference('/001/o');
        pg.setredirect(true);
        return pg;
    }
    
    public PageReference doRemaining()
    {   
        LinuxITMigrationOpenOpps.remainingLinuxAccounts();
        PageReference pgr=new pagereference('/001/o');
        pgr.setredirect(true);
        return pgr;
    }
    
    public static void doMigrationOpenOpps()
    {    
        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.info,'Opps migrating'));
        
        Map<id, Opportunity> oppMap = new Map<id, Opportunity>([SELECT id, Name, account.Name, accountid from Opportunity 
                                                                WHERE StageName in ('Stage 0: Lead','Stage 1: Suspect','Stage 2: Prospect','Stage 3: Best Case','Stage 4: Committed Deal') 
                                                                AND (Account.Support_Group__c = 'LinuxIT')
                                                                AND account.RecordType.Name ='UK Account']);
        
        List<Opportunity> oppList = new List<Opportunity>();
        // Update Opportunity by defaulting Campaign as Not Campaign Related
        for(Opportunity opp: oppMap.values()){
            //the campaign id for not campaign related 
            opp.CampaignId = '7013N0000004wea';
            oppList.add(opp);
            //System.debug(Logginglevel.INFO,'Opportunity ID -->'+opp.id);
        }
        update oppList;
        
        Map<id, OpportunityLineItem> oppLineItem = new Map <id, OpportunityLineItem>();
        List<OpportunityLineItem> oppLineItemList = new list<OpportunityLineItem>();
        
        for (OpportunityLineItem oli:[SELECT id, name, OpportunityId, Term_months__c, Contract_Length_Years__c, From_ARV__c, Old_ARV_If_Replacement__c, To_ARV__c, Sales_ARV__c, From_ARC__c, To_ARC__c, NRC__c
                                      FROM OpportunityLineItem 
                                      WHERE OpportunityId in :oppMap.keyset()]){
            oli.Term_months__c = oli.Contract_Length_Years__c * 12;
            oli.From_ARV__c = oli.Old_ARV_If_Replacement__c;
            oli.To_ARV__c = oli.Sales_ARV__c;
            oli.From_ARC__c = 0;
            oli.To_ARC__c = 0;
            oli.NRC__c = 0;
                                          
            oppLineItem.put(oli.OpportunityId, oli);
            oppLineItemList.add(oli);
        }
        update oppLineItem.values();
        
        System.debug('Number of Opportunities --> ' + oppMap.size());
        System.debug('Number of OpplineItems --> ' + oppLineItem.size());
        System.debug('Number of OpplineItems List--> ' + oppLineItemList.size());
        
        List <Account> accList = new list<Account>();
        Map<id, Account> accMap = new map<id, Account>([SELECT id, name, NumberOfEmployees, No_of_Employees__c, support_group__c, Total_Sales__c, ARV__c 
                                                        FROM Account 
                                                        WHERE id in (SELECT accountid 
                                                                     FROM Opportunity 
                                                                     WHERE id in:oppMap.KeySet())]);
        
        for(Account acc: accMap.values()){
            //System.debug('Account Name '+acc.Name);
            acc.Name = acc.name + ' (LinuxIT)';
            acc.No_of_Employees__c = String.valueof(acc.NumberOfEmployees);
            acc.support_group__c = 'MSP';
            acc.ARV__c = acc.Total_Sales__c;
            
            accList.add(acc);
        }
        update accList;
        
       // System.debug('Number of Accounts -->' + accMap.size());
        
        /*
        List<Contact> conlist= new List<Contact>();
        map<id, Contact> conmap = new map<id, Contact>([Select id, name, Primary_Contact__c, Primary_Sales_Contact__c, Work_Phone_Extension__c,
                                                        phone
                                                        from Contact where accountid in: accmap.keyset()]);
        
        //string forphone;
        for(Contact con: conmap.values()){
            //System.debug('Contact Name '+con.Name);
            //forphone = '';
            con.Primary_Sales_Contact__c = con.Primary_Contact__c;
            //forphone = String.valueof(Con.phone);
            //con.Work_Phone_Extension__c = forphone.left(6); //(Con.phone ==''?'':Con.phone);
            conlist.add(con);
        }
        System.debug('Number of Contacts -->'+conmap.size());
        update conlist; 
        */
    }
    
    public static void remainingLinuxAccounts(){
        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.info,'Remaining Accounts migrating'));
        
        List <Account> accList = new list<Account>();
        Map<id, Account> accMap = new map<id, Account>([SELECT id, name, NumberOfEmployees, No_of_Employees__c, support_group__c, Total_Sales__c, ARV__c 
                                                        FROM Account 
                                                        WHERE support_group__c = 'LinuxIT' 
                                                        AND RecordType.Name ='UK Account']);
        
        for(Account acc: accMap.values()){
            //System.debug('Account Name '+acc.Name);
            acc.Name = acc.name + ' (LinuxIT)';
            acc.No_of_Employees__c = String.valueof(acc.NumberOfEmployees);
            acc.support_group__c = 'MSP';
            acc.ARV__c = acc.Total_Sales__c;
            
            accList.add(acc);
        }
        
        System.debug('Number of Accounts -->' + accList.size());
        //update accList;
    }
}


Test class

@isTest
public class LinuxITMigrationOpenOppsTest {
     static testmethod void LinuxITMigrationOpenOppsTest(){
        Test.startTest();
         
        Account Acc = new Account(name = 'test account',
                                  support_group__c = 'LinuxIT', 
                                  recordtypeid = '01220000000E1sfAAC', 
                                  Projected_FYCV__c = 10,   
                                  Turnover_currency__c = 10, 
                                  Company_Registered_Number__c ='1', 
                                  BillingStreet = '123', 
                                  Customer_Segment__c = 'SMB',
                                  Vertical_Classification__c = 'Gaming', 
                                  cf_customer_vertical__c = 'Finance', 
                                  cf_customer_segment__c = 'Corporate', 
                                  cf_customer_sector__c = 'Private');
        insert Acc;
        
         
        Contact con = new Contact(accountid = acc.id, 
                                  firstName = 'test first', 
                                  lastname = 'test last', 
                                  MobilePhone = '0123456789', 
                                  Direct_Dial__c = '0123456789', 
                                  Salutation = 'Mr');
        insert con;
        
         
        Product2 pd = new Product2(name= 'Test Product', 
                                   isActive = true, 
                                   CurrencyIsoCode = 'GBP');
        insert pd;
         
         
        Id pricebookId = Test.getStandardPricebookId(); // Standard price book entries require the standard price book ID.
        PricebookEntry standardPrice = new PricebookEntry(Pricebook2Id = pricebookId, 
                                                          Product2Id = pd.Id,
                                                          UnitPrice = 10000, IsActive = true);
        insert standardPrice; 
         
         
        Pricebook2 pb = new pricebook2(name ='Test PB', 
                                       isActive = true);
        insert pb;
                       
         
        PriceBookEntry pbe= new PriceBookEntry(pricebook2id = pb.Id, 
                                               product2ID = pd.id, 
                                               isActive = true, 
                                               UnitPrice = 10000, 
                                               UseStandardPrice = false, 
                                               CurrencyIsoCode = 'GBP');
        insert pbe;
         
         
        Campaign ca = new Campaign(name = 'Test Campaign',
                                   recordTypeID = '01220000000E1sB',
                                   isActive = true);
        insert ca;
        
        
        Opportunity opp = new Opportunity (accountid = acc.id, 
                                           name = 'test opp', 
                                           stageName = 'Stage 0: Lead', 
                                           closeDate = system.today(), 
                                           CampaignId = '7013N0000004wea', 
                                           LeadSource = 'Cold Call'); 
        insert opp;
        
       opp.CampaignId = '7013N0000004wea';
       
       update opp;

        
         system.assert(opp.CampaignId == '7013N0000004wea');
         
         
         
        List<Opportunity> oppList = new List<Opportunity>();
        oppList.add(opp);
        
         
        OpportunityLineItem oppLineItem = new OpportunityLineItem(opportunityid = opp.id, 
                                                                  pricebookentryid = pbe.id, 
                                                                  From_ARV__c = 10,
                                                                  To_ARC__c = 0,
                                                                  product2id = pd.id, 
                                                                  Quantity = 1, 
                                                                  UnitPrice = 750, 
                                                                  Term_months__c=12);
        insert oppLineItem;
        oppLineItem.From_ARV__c = oppLineItem.Old_ARV_If_Replacement__c;
        update oppLineItem; 
         
         
        LinuxITMigrationOpenOpps limo = new LinuxITMigrationOpenOpps();
        Pagereference pg1 = new Pagereference('/');        
        pg1 = limo.doMigration();
        pg1 = limo.doRemaining();
      
      
      
      
   
  }
      
         
         
       
           
}

 

Hi

I have a standard button which is part of a managed packages, so I cannot make any changes to it. 
Basically i wanted to add this to a lightning component on my page- basically the reason for doing this is the button is executing an api call but the page is not refreshing afterwards. I wanted to add to a lightning component which would enable me to refresh it aferwards.

Can anyone confirm if it is possible to add a custom button to a lightning component ? 

Thanks

 

Sarah 

Hi guys 

I'm wondering if someone can help me i'm quite a newbie developer
I've created a button which is updating a field on the account  using a component and class. I'm having trouble gettting any coverage for my class can anyone tell me where i am going wrong ? 

in my test class i'm getting an error on "    updateBillingAddressPlan.UpdateBill(Acc);
" as it doesn't recognise Acc as a variable. 

Here is my class 

public class updateBillingAddressPlan {

    @AuraEnabled

    public static void UpdateBill(){
      
        list<Account> Acc_list = new list<Account>();

        Acc_list = [select id,Shipping_to_Billing__c from Account Limit 1];

        Account acc =new Account();

       acc.id=Acc_list[0].id;

        acc.Shipping_to_Billing__c=true;

        update acc;

    }

}

Test class 

@isTest

    
  
private class updateBillingAddressPlantest{
   @AuraEnabled
        public static boolean UpdateBill(){
        
        //List<Account> Acc_list = new list<Account>();
        
       // Acc_list = [select id,Shipping_to_Billing__c from Account Limit 1];
      //  system.debug(Acc_list.size());  
        Account acc =new Account();

      // acc.id=Acc_list[0].id;
        acc.name ='test account';
        acc.Siret_Number__c='12345678911111';
        acc.Shipping_to_Billing__c=true;

        insert acc;
        system.debug('inserting account was a success');
        return acc.Shipping_to_Billing__c;
        }
        
        
        static testmethod void doTest(){
        Test.startTest();
        User U = new User();
        U.FirstName = 'Testy';
        U.LastName = 'Tester';
      //  U.CurrencyIsoCode = 'GBP';
        U.Username = 'tester_User@test.com';
        U.email = 'tester@test.com';
        U.Alias = 'tstr';
        U.TimeZoneSidKey = 'Europe/London';
        U.LocaleSidKey ='en_GB';
        U.EmailEncodingKey ='ISO-8859-1';
        U.LanguageLocaleKey = 'en_US';
        U.profileID = '00e1t000000FMFdAAO';
       // U.Annual_Target_New_TCVP__c = 100000;
    //    U.Booked_YTD_New_TCVP__c = 50000;
        Insert U;
        
        System.runAs(U){
            Account Acc = new Account();
           // Acc.recordTypeID = Schema.SObjectType.Account.getRecordTypeInfosByName().get('UK Account').getRecordTypeId();
            Acc.Name = 'Account Testing';
            Acc.Siret_Number__c='12345678923456';
           // Acc.cf_customer_sector__c = 'Public';
        //    Acc.cf_customer_segment__c = 'SMB';
            Acc.cf_customer_vertical__c = 'Finance';
            insert Acc;
            
            Opportunity opp = new Opportunity();
            opp.name = 'Test Opportunity';
         //   opp.Start_Date__c = system.today();
            opp.closeDate = system.today().addDays(1);
            opp.stageName = 'Stage 2: Prospect';
            insert opp;}
            
            updateBillingAddressPlan.UpdateBill(Acc);

          
      
        Test.stopTest();
        
        
        
        
        
        }}
Hi 

I have a button on a lightning component that basically executes 

      window.location.reload()
         
I was trying to see if it is possible to call this action - either via process builder or a trigger. I can't seem to find a way so far :( 

Sarah 
Hi I'm quite new to apex and wondering if someone can help me getting code coverage for this method would be greatly appreciated. 
Here's my apex method : 
global Auth.UserData  getUserInfo(Map<string,string> authProviderConfiguration, Auth.AuthProviderTokenResponse response) { 
        String token = response.oauthToken;
        
        HttpRequest req = new HttpRequest();
        req.setHeader('Authorization', 'Bearer ' + token);
        
        String accessTokenUrl = authProviderConfiguration.get('LoginURL__c');
        req.setEndpoint(accessTokenUrl);
        
        
        
        req.setMethod('GET');
        
        Http http = new Http();
        HTTPResponse res = http.send(req);
        String responseBody = res.getBody();
        
        
        final Auth.UserData userData = new Auth.UserData(
            null // identifier
            , null // firstName
            , null // lastName
            , null // fullName
            ,null // email
            , null // link
            , null // userName
            , null  //locale
            , 'SireneAuth' //provider
            , null // siteLoginUrl
            , new Map<String,String>());
        
        return userdata;
        
    }


Here is what i have so far for my test class : 

@isTest 

 static testmethod void testGetUserIfo(){
        
           Map<String,String> authProviderConfiguration =

        setupAuthProviderConfig();
        
        System.Test.setMock(HttpCalloutMock.class, new SireneMockHttpResponseGenerator());

        SireneAuth SireneAuthCls = new SireneAuth();

        SireneAuthCls.accessTokenUrl  = authProviderConfiguration.get

        ('LoginUrl_c');

     

        

     

        
}




 
HI Wondering if anyone can help a newbie here in trouble !  

I'm trying to write a test class for this class which uses an ivokable method callled by process builder. I'm getting the following error on the test class can anyone direct me as to where i'm going wrong ? 
: Compile Error: Method does not exist or incorrect signature: void invokeapexcallout(List<String>, List<Id>) from the type MakeApexCallout at line 29 column 28

Here is my class : 

public class MakeApexCallout {

  @InvocableMethod(label='callout')
   public static void invokeapexcallout(list<Account> acc) {
     Futureapexcallout.apexcallout(acc[0].Siret_Number__c,acc[0].Id);
   }
}


My Test Class 

@IsTest

public Class MakeApexCalloutTest {

static testMethod void CallOutTest() {

   

// Create Account
          
        Account acc = new Account();

        acc.Name = 'test Account';

        acc.Siret_Number__c = '42097142600035';
        
        insert acc;
            
           List<Id> AccountIds = new List<Id>(); 
           AccountIds.add(acc.Id);
           List<String> SiretNumbers= new List<String>();
          
          SiretNumbers.add(acc.Siret_Number__c);


            Test.startTest();

         
           MakeApexCallout.invokeapexcallout(SiretNumbers, AccountIds);
            Test.stopTest();

}}


 
HI we've developed a trigger which is fired in the event of deletion upon the ContentDocument object. Wondering if someone could tell me where i am going wrong ! The class is running with no apparent errors however we have 0% code coverage :(  :

My Class : 

@istest
public class count_attach_test {

        static testmethod void attachtest() {
            Account a = new Account();
            a.RecordTypeId='0121r000000pvQm';
            a.name = 'Test NL Account';
            
            
            insert a;
           
        
            Attachment at = new Attachment();
            at.name = 'test attachment';
            at.body = blob.valueof('attachment body');
            at.parentid = a.id;
            insert at;   
            
            
           Opportunity o = New Opportunity ();
           o.RecordTypeId ='0121r000000pvdX';
           o.AccountId =a.Id;
           o.StageName ='Stage 1: Suspect';
           o.Start_Date__c=System.today();
           o.CloseDate=System.today() + 5;
           o.Name='Test NL Opportunity';
           
           insert o; 
           
           o.attachment_edited__c=TRUE;
           update o;            
            
             Attachment at2 = new Attachment();
            at2.name = 'test attachment';
            at2.body = blob.valueof('attachment body');
            at2.parentid = o.id;
            insert at2;   
            
            delete at;
            
            delete at2;
            Blob beforeblob=Blob.valueOf('Unit Test Attachment Body');
ContentVersion cv = new ContentVersion();
        cv.title = 'test content trigger';      
        cv.PathOnClient ='test';           
        cv.VersionData =beforeblob;          
        insert cv;     
            
 ContentVersion testContent = [SELECT id, ContentDocumentId FROM ContentVersion where Id = :cv.Id];
List<ContentDocument> documents = [SELECT Id, Title, LatestPublishedVersionId FROM ContentDocument];

        ContentDocumentLink contentlink=new ContentDocumentLink();
        contentlink.LinkedEntityId=a.id;
        contentlink.ShareType= 'v';
        contentlink.LinkedEntityId = a.Id; 
        contentlink.ContentDocumentId=documents[0].Id;
        contentlink.Visibility = 'AllUsers'; 
        insert contentlink;          
            
            delete contentlink;   
            
            
            //List<Attachment> attachments = [Select Id From Attachment Where parentId = :a.id];
            
           // System.assert(attachments.size() == 1, 'Wrong number of attachments (( ' + attachments.size() );
        }   }

My Trigger :

trigger DeleteFileNL on ContentDocument (before delete) {
                
    Set<id> contentDocumentIDs = new Set<Id>();
    Set<id> sObjectIds = new Set<id>();
    Map<id,Account> tempAccounts = new Map<id,Account>();
    List<Account> accountsToUpdate = new List<Account>();
    
    List<ContentDocument> cdocuments = ( Trigger.isDelete ? Trigger.old : Trigger.new );
    String additonalWhereClause = ( Trigger.isDelete ? 'and ContentDocumentID not in:contentDocumentIDs' : '');
    
    for(ContentDocument cd: cdocuments){
        contentDocumentIDs.add(cd.id);
    }
    
    for ( ContentDocumentLink cdl : [Select LinkedEntityID, ContentDocumentID from ContentDocumentLink where ContentDocumentID IN: contentDocumentIDs]) {
        sObjectIds.add( cdl.LinkedEntityId );
    }
    
    if(sObjectIds.size()>0){
        String query = 'Select LinkedEntityId, count(ContentDocumentID) from ContentDocumentLink where LinkedEntityId in:sObjectIds '+additonalWhereClause+' group by LinkedEntityId';
        AggregateResult[] aggrResult = Database.query(query);
        SYstem.debug(query);
        
        Map<id,Account> accMap = new Map<id,Account>([Select id, name, Attachment_Increment__c from Account where id in:sObjectIds]);
        
        for(AggregateResult ar: aggrResult){
            Object sObjectId = ar.get('LinkedEntityId');
            if(accMap.containsKey((id)sObjectId)){
                Account acc =  accMap.get((id)sObjectId);
                //acc.Attachment_Increment__c = (Integer)ar.get('expr0');    
                acc.Attachment_Increment__c=1*-1;
                acc.Attachment_Edited__c=True;
                System.debug('(Integer)ar.get(expr0)'+(Integer)ar.get('expr0'));
                tempAccounts.put(acc.id,acc);
                accountsToUpdate.add(acc);    
            }
        }
        
        for(Account acc: accMap.values()){
            if(!tempAccounts.containsKey(acc.id)){
                Account a = acc;
            acc.Attachment_Increment__c=1*-1;
               a.Attachment_Edited__c=True;
                accountsToUpdate.add(acc); 
            }
        }
        
        try{
            update accountsToUpdate; 
        }catch(Exception e){
            System.debug('Error Message: '+e.getMessage()+' trace: '+e.getStackTraceString());
        }  
    }
    
}



 

Hi I'm looking to conditionally show a field if the following conditions are met on a Lightning component : 

1. if its the record owner viewing it 
2. if its an admin profile. 

However I'm running into issues, we have a problem as users are able to see it in global searches (which we cannot change as we have multiple countries using our org) Also they are able to see it in the report sections. So i was looking to turn off the visibility of this field and enforce the visibility through preferably a lightning component or if that's not possible a visualforce page. Has anyone managed to do this ?
 

Thanks very much 
 

Sarah 

Hi our company wants to do weekly forecasting, has anyone managed to do this declaratively through an app ? 
Or are we looking at a bespoke solution ? 

Thanks
Sarah 
Hi Im writing a trigger for the cases object which looks for a matching sname and matches the appropriate account for some reason I'm only getting 37 % coverage with my test class. 
Where am i going wrong this is drivign me a bit potty ! I've underlined the parts of the trigger that are covered
Here's my trigger :
trigger UpdateRelatedAccountTrigger on Case (before update,before insert) {
  
Try{

Account a = [select ID, Messina_Short_Name__c,  Name from Account where Messina_Short_Name__c = :trigger.new[0].Messina_Short_Name__c ];

for(Case c1 : trigger.new){

if((
    
    c1.Messina_Short_Name__c!=c1.Messina_Sname__c
  )){


c1.Account_Reference__c= a.ID;
c1.AccountId=a.ID;
   
}
}
Test Class


@isTest
public class UppdateAssignedAccountCaseClass {
    static testMethod void  UpdateCustomSyncHandler() {
        Account acc1 = new Account();
        acc1.Name = 'test account';
        insert acc1;
        system.debug('insert acc1 is success');



           
        Opportunity Opp1 = new Opportunity();
        Opp1.Credit_Check_Requested__c =FALSE;
        Opp1.Name = 'testOpp';
        Opp1.AccountId = acc1.Id;
        Opp1.StageName = 'Stage 0: Lead';
        Opp1.Super_Group__c='Network';
        Opp1.Resource_Group__c='MSP';
        Opp1.CloseDate = system.Today();
        
        Opp1.LeadSource='Marketing';
        insert Opp1;        
        system.debug('insert opp1 success');
        
        Product2 Pro1 = new Product2();
        Pro1.Name = 'Broadband Internet No Resilience';
       
       
       
        pro1.isActive = True;
        Insert pro1;
        system.debug('insert pro1 is success');       
        
        Pricebook2 pb = new pricebook2();
        pb.Name = 'Test Pricebook';
        pb.description = 'Test Pricebook';
        pb.isActive = True;
        insert pb;
        system.debug('pb value is'+ pb.Id);
        system.debug('insert pricebook2 is success');

        Id pricebookId = Test.getStandardPricebookId();        

        PricebookEntry StandardPriceBookEntry = new PricebookEntry();
        StandardPriceBookEntry.Pricebook2Id = pricebookId;
        StandardPriceBookEntry.Product2Id = pro1.Id;
        StandardPriceBookEntry.UnitPrice = 25;
        StandardPriceBookEntry.IsActive =True;        
        insert StandardPriceBookEntry;
        system.debug('insert StandardPriceBookEntry');

        PricebookEntry pbe = new PricebookEntry(pricebook2id=pb.id, product2id=pro1.id, unitprice=20, isActive = True);
        insert pbe;
        system.debug('insert pbe is success');





       

        


        
             Case C1 = new Case(); 
        //C1.Opportunity_Name__r.Id = Opp1.Id;
       // C1.RecordType.Id='012w0000000V6vq';
        C1.Origin='Web';
        C1.Messina_Short_Name__c='SARAH';
       
        insert C1;       
        system.debug('insert C1 success');
        
        C1.Origin='Web';
        C1.Messina_Short_Name__c='SARAH';
       
       update C1;
        
        }}


 
Hi 
I'm working on some triggers on quote line item, basically what i'm looking to do is when a user changes a single field or any field on the page it automatically triggers a save, without the user having to hit save. We have asked users to hit save so the triggers recalculate the values but if there is a way to do this automatically it would be so awesome and i would owe you a beer :) 
I'm quite new to apex but can someone help me identify where i'm going wrong i keep getting this error when i try to save my trigger : 
Compile Error: Expression cannot be assigned at line -1 column -1

trigger updateprimcount on Contact (before update) {
for (Contact c: Trigger.new){
        if(Contact.Primary_Sales_Contact__c  == TRUE ){
       Account.Primary_Sales_Contact_Count__c =(integer.valueOf(Account.Primary_Sales_Contact_Count__c) + 1);
       
       
 
       
       
       }
       
    
     
        

}}
 

Hi

wondering if someone can help, we have some custom fields on the product (setup and recurring cost)  what we were looking to do was to have this copy accross to the opportunity product when a user adds the product from the price book. We wanted the users to be able to edit it in the opportunity product multi line edit view but for it to appear as soon as they open the page but before saving. Is this possible ?
 

Thanks
 

Sarah 

Hi I'm trying to edit this existing trigger, I want to add a condition so it runs when the email condition only contains certain text 

It's not liking this part of the apex :  
If(EmailMessage.ToAddress.contains=('SignedOrder')){

Here's the code I'm using, can anyone give me any pointers as to where I am going wrong ?

Thanks so much Sarah   :


trigger UpdateTo on EmailMessage (before insert) {


    //set<id> CaseIds = new set<Id>();
    map<Id,EmailMessage> MapEmailMessage = new map<Id,EmailMessage>();

    List<Case> newList = new List<Case>();

    for(EmailMessage e:trigger.new){
If(EmailMessage.ToAddress.contains=('SignedOrder')){



        MapEmailMessage.put(e.ParentId,e);

    }

    

    list<Case> lstC = [select Id,To__c from Case where id in:MapEmailMessage.keyset()];

    for(Case c:lstC){

        if(MapEmailMessage != null && MapEmailMessage.get(c.Id) != null )

            c.To__c = MapEmailMessage.get(c.Id).ToAddress;

            newList.add(c);

    }

    if(newList.size()>0)

    {

        update newList;

    }

}}

Hi 

I'm trying to set up a button on the opportunity page which opens a new case but preselects a particular record type for cases  ('UK Sales Engagement'). 

I have this but it's not working, any ideas where I'm going wrong ? 

/500/e?retURL=%2F500%2Fo 

&cas4_lkid={!Account.Id} 
&cas4={!Account.Name} 
&00Nw0000008rJRa_lkid={!Account.Id} 
&00Nw0000008rJRa={!Account.Messina_Short_Name__c} 
&CF00Nw0000008rJRp_lkid={!Opportunity.Id} 
&CF00Nw0000008rJRp={!Opportunity.Name} 
&00Nw0000008rJRB_lkid={!Opportunity.Id} 
&00Nw0000008rJRB={!Opportunity.ARV_Churn__c} 
&00Nw0000008rJRk_lkid={!Opportunity.Id} 
&00Nw0000008rJRk={!Opportunity.TCVP_New_del__c} 
&00Nw0000008rJS4_lkid={!Opportunity.Id} 
&00Nw0000008rJS4={!Opportunity.UK_TCVP_re_contract__c} 
&{!Case.RecordType}='UK Sales Engagement' 
&retURL=/{!Opportunity.Id} 
&saveURL=/{!Opportunity.Id}



Thanks very much 

Sarah 

Hi 

I was wondering if someone might be able to help me with this requirement. I was looking to have a trigger which enters a value for a picklist field but was stuck on the event condition. What i wanted to happen is for when the user creates an account and the blank form loads for that field to be populated, but before the user enters their own data and then saves. If that makes sense ? Is it possible ? 

Thank you 

 

Hi

We have a save to quote button on our quotations (pdf ) format.

When we select this nothing happens, does anyone know where you can configure this button ? Is it possible to edit it ? Also do you know if it is possible to remove the email quotation email ?
 

Thanks

 

Sarah

Hi

We have a label called Account type  Previous customer in this example, does anyone know where i can find hte tranlation settings for this field as should be in German and can't find it anywher e :S
User-added image
Hi

I've created a new custom picklist field in the price book called product family. The users wanted it so when they create a new opportunity product it copies this field from the price book, they also want the field to be a pick list in the opportunity product. I've looked at field updates using workflow but it doesn' allow me to do it. Anyone ever experienced this before ? help ! :)
 
Hi wondering if anyone can help me - i've got 60% coverage here where am i going wrong ? 

class:
public class LinuxITMigrationOpenOpps{
        
    public PageReference doMigration()
    {   
        LinuxITMigrationOpenOpps.doMigrationOpenOpps();
        PageReference pg=new pagereference('/001/o');
        pg.setredirect(true);
        return pg;
    }
    
    public PageReference doRemaining()
    {   
        LinuxITMigrationOpenOpps.remainingLinuxAccounts();
        PageReference pgr=new pagereference('/001/o');
        pgr.setredirect(true);
        return pgr;
    }
    
    public static void doMigrationOpenOpps()
    {    
        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.info,'Opps migrating'));
        
        Map<id, Opportunity> oppMap = new Map<id, Opportunity>([SELECT id, Name, account.Name, accountid from Opportunity 
                                                                WHERE StageName in ('Stage 0: Lead','Stage 1: Suspect','Stage 2: Prospect','Stage 3: Best Case','Stage 4: Committed Deal') 
                                                                AND (Account.Support_Group__c = 'LinuxIT')
                                                                AND account.RecordType.Name ='UK Account']);
        
        List<Opportunity> oppList = new List<Opportunity>();
        // Update Opportunity by defaulting Campaign as Not Campaign Related
        for(Opportunity opp: oppMap.values()){
            //the campaign id for not campaign related 
            opp.CampaignId = '7013N0000004wea';
            oppList.add(opp);
            //System.debug(Logginglevel.INFO,'Opportunity ID -->'+opp.id);
        }
        update oppList;
        
        Map<id, OpportunityLineItem> oppLineItem = new Map <id, OpportunityLineItem>();
        List<OpportunityLineItem> oppLineItemList = new list<OpportunityLineItem>();
        
        for (OpportunityLineItem oli:[SELECT id, name, OpportunityId, Term_months__c, Contract_Length_Years__c, From_ARV__c, Old_ARV_If_Replacement__c, To_ARV__c, Sales_ARV__c, From_ARC__c, To_ARC__c, NRC__c
                                      FROM OpportunityLineItem 
                                      WHERE OpportunityId in :oppMap.keyset()]){
            oli.Term_months__c = oli.Contract_Length_Years__c * 12;
            oli.From_ARV__c = oli.Old_ARV_If_Replacement__c;
            oli.To_ARV__c = oli.Sales_ARV__c;
            oli.From_ARC__c = 0;
            oli.To_ARC__c = 0;
            oli.NRC__c = 0;
                                          
            oppLineItem.put(oli.OpportunityId, oli);
            oppLineItemList.add(oli);
        }
        update oppLineItem.values();
        
        System.debug('Number of Opportunities --> ' + oppMap.size());
        System.debug('Number of OpplineItems --> ' + oppLineItem.size());
        System.debug('Number of OpplineItems List--> ' + oppLineItemList.size());
        
        List <Account> accList = new list<Account>();
        Map<id, Account> accMap = new map<id, Account>([SELECT id, name, NumberOfEmployees, No_of_Employees__c, support_group__c, Total_Sales__c, ARV__c 
                                                        FROM Account 
                                                        WHERE id in (SELECT accountid 
                                                                     FROM Opportunity 
                                                                     WHERE id in:oppMap.KeySet())]);
        
        for(Account acc: accMap.values()){
            //System.debug('Account Name '+acc.Name);
            acc.Name = acc.name + ' (LinuxIT)';
            acc.No_of_Employees__c = String.valueof(acc.NumberOfEmployees);
            acc.support_group__c = 'MSP';
            acc.ARV__c = acc.Total_Sales__c;
            
            accList.add(acc);
        }
        update accList;
        
       // System.debug('Number of Accounts -->' + accMap.size());
        
        /*
        List<Contact> conlist= new List<Contact>();
        map<id, Contact> conmap = new map<id, Contact>([Select id, name, Primary_Contact__c, Primary_Sales_Contact__c, Work_Phone_Extension__c,
                                                        phone
                                                        from Contact where accountid in: accmap.keyset()]);
        
        //string forphone;
        for(Contact con: conmap.values()){
            //System.debug('Contact Name '+con.Name);
            //forphone = '';
            con.Primary_Sales_Contact__c = con.Primary_Contact__c;
            //forphone = String.valueof(Con.phone);
            //con.Work_Phone_Extension__c = forphone.left(6); //(Con.phone ==''?'':Con.phone);
            conlist.add(con);
        }
        System.debug('Number of Contacts -->'+conmap.size());
        update conlist; 
        */
    }
    
    public static void remainingLinuxAccounts(){
        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.info,'Remaining Accounts migrating'));
        
        List <Account> accList = new list<Account>();
        Map<id, Account> accMap = new map<id, Account>([SELECT id, name, NumberOfEmployees, No_of_Employees__c, support_group__c, Total_Sales__c, ARV__c 
                                                        FROM Account 
                                                        WHERE support_group__c = 'LinuxIT' 
                                                        AND RecordType.Name ='UK Account']);
        
        for(Account acc: accMap.values()){
            //System.debug('Account Name '+acc.Name);
            acc.Name = acc.name + ' (LinuxIT)';
            acc.No_of_Employees__c = String.valueof(acc.NumberOfEmployees);
            acc.support_group__c = 'MSP';
            acc.ARV__c = acc.Total_Sales__c;
            
            accList.add(acc);
        }
        
        System.debug('Number of Accounts -->' + accList.size());
        //update accList;
    }
}


Test class

@isTest
public class LinuxITMigrationOpenOppsTest {
     static testmethod void LinuxITMigrationOpenOppsTest(){
        Test.startTest();
         
        Account Acc = new Account(name = 'test account',
                                  support_group__c = 'LinuxIT', 
                                  recordtypeid = '01220000000E1sfAAC', 
                                  Projected_FYCV__c = 10,   
                                  Turnover_currency__c = 10, 
                                  Company_Registered_Number__c ='1', 
                                  BillingStreet = '123', 
                                  Customer_Segment__c = 'SMB',
                                  Vertical_Classification__c = 'Gaming', 
                                  cf_customer_vertical__c = 'Finance', 
                                  cf_customer_segment__c = 'Corporate', 
                                  cf_customer_sector__c = 'Private');
        insert Acc;
        
         
        Contact con = new Contact(accountid = acc.id, 
                                  firstName = 'test first', 
                                  lastname = 'test last', 
                                  MobilePhone = '0123456789', 
                                  Direct_Dial__c = '0123456789', 
                                  Salutation = 'Mr');
        insert con;
        
         
        Product2 pd = new Product2(name= 'Test Product', 
                                   isActive = true, 
                                   CurrencyIsoCode = 'GBP');
        insert pd;
         
         
        Id pricebookId = Test.getStandardPricebookId(); // Standard price book entries require the standard price book ID.
        PricebookEntry standardPrice = new PricebookEntry(Pricebook2Id = pricebookId, 
                                                          Product2Id = pd.Id,
                                                          UnitPrice = 10000, IsActive = true);
        insert standardPrice; 
         
         
        Pricebook2 pb = new pricebook2(name ='Test PB', 
                                       isActive = true);
        insert pb;
                       
         
        PriceBookEntry pbe= new PriceBookEntry(pricebook2id = pb.Id, 
                                               product2ID = pd.id, 
                                               isActive = true, 
                                               UnitPrice = 10000, 
                                               UseStandardPrice = false, 
                                               CurrencyIsoCode = 'GBP');
        insert pbe;
         
         
        Campaign ca = new Campaign(name = 'Test Campaign',
                                   recordTypeID = '01220000000E1sB',
                                   isActive = true);
        insert ca;
        
        
        Opportunity opp = new Opportunity (accountid = acc.id, 
                                           name = 'test opp', 
                                           stageName = 'Stage 0: Lead', 
                                           closeDate = system.today(), 
                                           CampaignId = '7013N0000004wea', 
                                           LeadSource = 'Cold Call'); 
        insert opp;
        
       opp.CampaignId = '7013N0000004wea';
       
       update opp;

        
         system.assert(opp.CampaignId == '7013N0000004wea');
         
         
         
        List<Opportunity> oppList = new List<Opportunity>();
        oppList.add(opp);
        
         
        OpportunityLineItem oppLineItem = new OpportunityLineItem(opportunityid = opp.id, 
                                                                  pricebookentryid = pbe.id, 
                                                                  From_ARV__c = 10,
                                                                  To_ARC__c = 0,
                                                                  product2id = pd.id, 
                                                                  Quantity = 1, 
                                                                  UnitPrice = 750, 
                                                                  Term_months__c=12);
        insert oppLineItem;
        oppLineItem.From_ARV__c = oppLineItem.Old_ARV_If_Replacement__c;
        update oppLineItem; 
         
         
        LinuxITMigrationOpenOpps limo = new LinuxITMigrationOpenOpps();
        Pagereference pg1 = new Pagereference('/');        
        pg1 = limo.doMigration();
        pg1 = limo.doRemaining();
      
      
      
      
   
  }
      
         
         
       
           
}

 
Hi guys 

I'm wondering if someone can help me i'm quite a newbie developer
I've created a button which is updating a field on the account  using a component and class. I'm having trouble gettting any coverage for my class can anyone tell me where i am going wrong ? 

in my test class i'm getting an error on "    updateBillingAddressPlan.UpdateBill(Acc);
" as it doesn't recognise Acc as a variable. 

Here is my class 

public class updateBillingAddressPlan {

    @AuraEnabled

    public static void UpdateBill(){
      
        list<Account> Acc_list = new list<Account>();

        Acc_list = [select id,Shipping_to_Billing__c from Account Limit 1];

        Account acc =new Account();

       acc.id=Acc_list[0].id;

        acc.Shipping_to_Billing__c=true;

        update acc;

    }

}

Test class 

@isTest

    
  
private class updateBillingAddressPlantest{
   @AuraEnabled
        public static boolean UpdateBill(){
        
        //List<Account> Acc_list = new list<Account>();
        
       // Acc_list = [select id,Shipping_to_Billing__c from Account Limit 1];
      //  system.debug(Acc_list.size());  
        Account acc =new Account();

      // acc.id=Acc_list[0].id;
        acc.name ='test account';
        acc.Siret_Number__c='12345678911111';
        acc.Shipping_to_Billing__c=true;

        insert acc;
        system.debug('inserting account was a success');
        return acc.Shipping_to_Billing__c;
        }
        
        
        static testmethod void doTest(){
        Test.startTest();
        User U = new User();
        U.FirstName = 'Testy';
        U.LastName = 'Tester';
      //  U.CurrencyIsoCode = 'GBP';
        U.Username = 'tester_User@test.com';
        U.email = 'tester@test.com';
        U.Alias = 'tstr';
        U.TimeZoneSidKey = 'Europe/London';
        U.LocaleSidKey ='en_GB';
        U.EmailEncodingKey ='ISO-8859-1';
        U.LanguageLocaleKey = 'en_US';
        U.profileID = '00e1t000000FMFdAAO';
       // U.Annual_Target_New_TCVP__c = 100000;
    //    U.Booked_YTD_New_TCVP__c = 50000;
        Insert U;
        
        System.runAs(U){
            Account Acc = new Account();
           // Acc.recordTypeID = Schema.SObjectType.Account.getRecordTypeInfosByName().get('UK Account').getRecordTypeId();
            Acc.Name = 'Account Testing';
            Acc.Siret_Number__c='12345678923456';
           // Acc.cf_customer_sector__c = 'Public';
        //    Acc.cf_customer_segment__c = 'SMB';
            Acc.cf_customer_vertical__c = 'Finance';
            insert Acc;
            
            Opportunity opp = new Opportunity();
            opp.name = 'Test Opportunity';
         //   opp.Start_Date__c = system.today();
            opp.closeDate = system.today().addDays(1);
            opp.stageName = 'Stage 2: Prospect';
            insert opp;}
            
            updateBillingAddressPlan.UpdateBill(Acc);

          
      
        Test.stopTest();
        
        
        
        
        
        }}
HI Wondering if anyone can help a newbie here in trouble !  

I'm trying to write a test class for this class which uses an ivokable method callled by process builder. I'm getting the following error on the test class can anyone direct me as to where i'm going wrong ? 
: Compile Error: Method does not exist or incorrect signature: void invokeapexcallout(List<String>, List<Id>) from the type MakeApexCallout at line 29 column 28

Here is my class : 

public class MakeApexCallout {

  @InvocableMethod(label='callout')
   public static void invokeapexcallout(list<Account> acc) {
     Futureapexcallout.apexcallout(acc[0].Siret_Number__c,acc[0].Id);
   }
}


My Test Class 

@IsTest

public Class MakeApexCalloutTest {

static testMethod void CallOutTest() {

   

// Create Account
          
        Account acc = new Account();

        acc.Name = 'test Account';

        acc.Siret_Number__c = '42097142600035';
        
        insert acc;
            
           List<Id> AccountIds = new List<Id>(); 
           AccountIds.add(acc.Id);
           List<String> SiretNumbers= new List<String>();
          
          SiretNumbers.add(acc.Siret_Number__c);


            Test.startTest();

         
           MakeApexCallout.invokeapexcallout(SiretNumbers, AccountIds);
            Test.stopTest();

}}


 
Hi Im writing a trigger for the cases object which looks for a matching sname and matches the appropriate account for some reason I'm only getting 37 % coverage with my test class. 
Where am i going wrong this is drivign me a bit potty ! I've underlined the parts of the trigger that are covered
Here's my trigger :
trigger UpdateRelatedAccountTrigger on Case (before update,before insert) {
  
Try{

Account a = [select ID, Messina_Short_Name__c,  Name from Account where Messina_Short_Name__c = :trigger.new[0].Messina_Short_Name__c ];

for(Case c1 : trigger.new){

if((
    
    c1.Messina_Short_Name__c!=c1.Messina_Sname__c
  )){


c1.Account_Reference__c= a.ID;
c1.AccountId=a.ID;
   
}
}
Test Class


@isTest
public class UppdateAssignedAccountCaseClass {
    static testMethod void  UpdateCustomSyncHandler() {
        Account acc1 = new Account();
        acc1.Name = 'test account';
        insert acc1;
        system.debug('insert acc1 is success');



           
        Opportunity Opp1 = new Opportunity();
        Opp1.Credit_Check_Requested__c =FALSE;
        Opp1.Name = 'testOpp';
        Opp1.AccountId = acc1.Id;
        Opp1.StageName = 'Stage 0: Lead';
        Opp1.Super_Group__c='Network';
        Opp1.Resource_Group__c='MSP';
        Opp1.CloseDate = system.Today();
        
        Opp1.LeadSource='Marketing';
        insert Opp1;        
        system.debug('insert opp1 success');
        
        Product2 Pro1 = new Product2();
        Pro1.Name = 'Broadband Internet No Resilience';
       
       
       
        pro1.isActive = True;
        Insert pro1;
        system.debug('insert pro1 is success');       
        
        Pricebook2 pb = new pricebook2();
        pb.Name = 'Test Pricebook';
        pb.description = 'Test Pricebook';
        pb.isActive = True;
        insert pb;
        system.debug('pb value is'+ pb.Id);
        system.debug('insert pricebook2 is success');

        Id pricebookId = Test.getStandardPricebookId();        

        PricebookEntry StandardPriceBookEntry = new PricebookEntry();
        StandardPriceBookEntry.Pricebook2Id = pricebookId;
        StandardPriceBookEntry.Product2Id = pro1.Id;
        StandardPriceBookEntry.UnitPrice = 25;
        StandardPriceBookEntry.IsActive =True;        
        insert StandardPriceBookEntry;
        system.debug('insert StandardPriceBookEntry');

        PricebookEntry pbe = new PricebookEntry(pricebook2id=pb.id, product2id=pro1.id, unitprice=20, isActive = True);
        insert pbe;
        system.debug('insert pbe is success');





       

        


        
             Case C1 = new Case(); 
        //C1.Opportunity_Name__r.Id = Opp1.Id;
       // C1.RecordType.Id='012w0000000V6vq';
        C1.Origin='Web';
        C1.Messina_Short_Name__c='SARAH';
       
        insert C1;       
        system.debug('insert C1 success');
        
        C1.Origin='Web';
        C1.Messina_Short_Name__c='SARAH';
       
       update C1;
        
        }}


 
Hi 
I'm working on some triggers on quote line item, basically what i'm looking to do is when a user changes a single field or any field on the page it automatically triggers a save, without the user having to hit save. We have asked users to hit save so the triggers recalculate the values but if there is a way to do this automatically it would be so awesome and i would owe you a beer :) 
I'm quite new to apex but can someone help me identify where i'm going wrong i keep getting this error when i try to save my trigger : 
Compile Error: Expression cannot be assigned at line -1 column -1

trigger updateprimcount on Contact (before update) {
for (Contact c: Trigger.new){
        if(Contact.Primary_Sales_Contact__c  == TRUE ){
       Account.Primary_Sales_Contact_Count__c =(integer.valueOf(Account.Primary_Sales_Contact_Count__c) + 1);
       
       
 
       
       
       }
       
    
     
        

}}
 

Hi 

I'm trying to set up a button on the opportunity page which opens a new case but preselects a particular record type for cases  ('UK Sales Engagement'). 

I have this but it's not working, any ideas where I'm going wrong ? 

/500/e?retURL=%2F500%2Fo 

&cas4_lkid={!Account.Id} 
&cas4={!Account.Name} 
&00Nw0000008rJRa_lkid={!Account.Id} 
&00Nw0000008rJRa={!Account.Messina_Short_Name__c} 
&CF00Nw0000008rJRp_lkid={!Opportunity.Id} 
&CF00Nw0000008rJRp={!Opportunity.Name} 
&00Nw0000008rJRB_lkid={!Opportunity.Id} 
&00Nw0000008rJRB={!Opportunity.ARV_Churn__c} 
&00Nw0000008rJRk_lkid={!Opportunity.Id} 
&00Nw0000008rJRk={!Opportunity.TCVP_New_del__c} 
&00Nw0000008rJS4_lkid={!Opportunity.Id} 
&00Nw0000008rJS4={!Opportunity.UK_TCVP_re_contract__c} 
&{!Case.RecordType}='UK Sales Engagement' 
&retURL=/{!Opportunity.Id} 
&saveURL=/{!Opportunity.Id}



Thanks very much 

Sarah