• Adnubis LLC
  • NEWBIE
  • 210 Points
  • Member since 2014
  • Adnubis LLC

  • Chatter
    Feed
  • 7
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 41
    Replies
I did try the query in Force.com Explore and get the result whoever when I ran the test this error comes up.  Please help!!!
Here is my code:

@istest
private class QuoteProductEntryTests {

    static testMethod void theTests(){
      
          
        QuoteLineItem qli = [select Id, PricebookEntryId, PriceBookEntry.Product2Id, QuoteId, Quote.OpportunityId from QuoteLineItem limit 1];
             
              
        ////////////////////////////////////////
        //  test QuoteProductEntry
        ////////////////////////////////////////
      
        // load the page     
        PageReference pageRef = Page.QuoteProductEntry;
        pageRef.getParameters().put('Id',qli.QuoteId);
        Test.setCurrentPageReference(pageRef);
      
        // load the extension
        QuoteitemExtension oPEE = new QuoteItemExtension(new ApexPages.StandardController(qli.Quote));
      
        // test 'getChosenCurrency' method
        if(UserInfo.isMultiCurrencyOrganization())
            System.assert(oPEE.getChosenCurrency()!='');
        else
            System.assertEquals(oPEE.getChosenCurrency(),'');

        // we know that there is at least one line item, so we confirm
        Integer startCount = oPEE.ShoppingCart.size();
        system.assert(startCount>0);

        //test search functionality without finding anything
        oPEE.searchString = 'michaelforce is a hip cat';
        oPEE.updateAvailableList();
        system.assert(oPEE.AvailableProducts.size()==0);
      
        //test remove from shopping cart
        oPEE.toUnselect = qli.PricebookEntryId;
        oPEE.removeFromShoppingCart();
        system.assert(oPEE.shoppingCart.size()==startCount-1);
      
        //test save and reload extension
        oPEE.onSave();
        oPEE = new QuoteItemExtension(new ApexPages.StandardController(qli.Quote));
        system.assert(oPEE.shoppingCart.size()==startCount-1);
      
        // test search again, this time we will find something
        oPEE.searchString = qli.PricebookEntry.Name;
        oPEE.updateAvailableList();
        system.assert(oPEE.AvailableProducts.size()>0);     

        // test add to Shopping Cart function
        oPEE.toSelect = oPEE.AvailableProducts[0].Id;
        oPEE.addToShoppingCart();
        system.assert(oPEE.shoppingCart.size()==startCount);
              
        // test save method - WITHOUT quanitities and amounts entered and confirm that error message is displayed
        oPEE.onSave();
        system.assert(ApexPages.getMessages().size()>0);
      
        // add required info and try save again
        for(QuoteLineItem o : oPEE.ShoppingCart){
            o.quantity = 5;
            o.unitprice = 300;
        }
        oPEE.onSave();
      
        // query line items to confirm that the save worked
        QuoteLineItem[] qli2 = [select Id from QuoteLineItem where QuoteId = :qli.QuoteId];
        system.assert(qli2.size()==startCount);
      
        // test on new Opp (no pricebook selected) to make sure redirect is happening
        Quote newQuote = new Quote(Name='New quote', OpportunityId=qli.Quote.OpportunityId);
        insert(newQuote);
        oPEE = new QuoteItemExtension(new ApexPages.StandardController(newQuote));
        System.assert(oPEE.priceBookCheck()!=null);
      
        // final quick check of cancel button
        System.assert(oPEE.onCancel()!=null);
      
      
        ////////////////////////////////////////
        //  test redirect page
        ////////////////////////////////////////
      
        // load the page

   
    }
}
Could someone please help why the following code is not working??

________

public class THUpdateLRO extends AbcTriggerHandler {
    private void updateLRO(List<License_Registration__c> newLROs) {
     

Set<id> AccIds = new Set<id>();

    for (License_Registration__c c : newLROs){
        AccIds.add(c.Current_Application__c);
    }

    Map<id, Application__c> AccIDmap = new Map<id, Application__c>([Select Id, Application_Outcome__c from Application__c
    Where Id in :AccIds]);
  
    for (License_Registration__c LicReg : newLROs){
       if(LicReg.Current_Application__c != null && LicReg.Current_Application__r.Application_Status__c == 'Withdrawn'){

       LicReg.Status__c = AccIDmap.get(LicReg.Current_Application__c).Application_Outcome__c; 
       }      
}
}

public override void OnBeforeInsert(SObject[] newObjects){
        updateLRO((List<License_Registration__c>)newObjects);
    }
public override void OnBeforeUpdate(SObject[]       newObjects,
                                       Map<Id,SObject> newObjectMap,
                                       SObject[]       oldObjects,
                                       Map<Id,SObject> oldObjectMap){
         updateLRO((List<License_Registration__c>)newObjects);
    }
}
  • February 15, 2014
  • Like
  • 0
Ok, this is giving me head ache, I have so far been unable to get it correct. The below code works, but I really need to get the SOQL outside of the FOR loop, due to apex govenor limits. Can you assist please?

trigger CaseEquipmentStatus on Case (After Update) {
Set<Id> caseIds = new Set<Id>();
Set<Id> EquipIds = new Set<Id>();
       for (Case c: Trigger.New){
         if (c.Opportunity__c != null && c.Status == 'Request Completed' && c.Origin == 'PRM' )
         caseIds.add(c.Opportunity__c);
         }
         for (Equipment__c Eq: [select id, Opportunity__c, Statis__c from
         Equipment__c where Opportunity__c in :caseIds]) {
         if(eq.Statis__c == 'Programming Change Requested'){
         eq.Statis__c = 'Active';    }
         Update eq;
        } }
Hello.  I have a client who wants external users to submit data via a Sites VF page and update Opportunity records.

Of course the Sites profile doesn't have permissions to update standard objects.  Furthermore, the client does not want to purchase portal licenses for these external users.

I am considering two workarounds and am wondering if they are possible:

1.  Write some Apex webservices and call them from the Sites page Visualforce controller.
-- Looking at the webservice documentation, this doesn't seem possible, but I thought I check to make sure.

2.  Have the Sites page create a custom object record instead, and then write a trigger to update the opp record using the custom object.
-- Will the trigger be running in the system context and be able to update the opp?

Thanks
David

I have a SOQL query that is using SUM and Group By, but I need to also get the Id of a field that doesn't use an aggregate function nor is it used in the Group By clause.

select Field1__c, GroupByField__r.Name, SUM(MyField2__c) sumMyField2 from My_SObject__c GROUP BY GroupByField__r.Name

I need to include "Field1__c" in the query to get the ids from that field. Is it possible to include the field without putting it in the Group By clause or using an aggregate function on it?

Thanks for any help.
I created a Opp List in controller and bind it with repeater, In VF page I used InputFild but on saving it gives Null pointer exception but when I uses InputText it works, problem is I cannot use inputText for CloseDate and Stages, what could be the issue with InputFiled
Good Morning,

First, I must admit this is my first time working with Apex code so any assistance that you can offer is VERY much appreciated.

After having worked my way through Salesforce tutorial on Apex and receiving some assistance from the help desk at Salesforce, I managed to put together the following Apex trigger:

trigger leadAssignment on Lead (before insert) {
    for(lead lea : trigger.new) {
        Boolean isLeadEnd = lea.Distributor_Or_End_User__c.equals('End User');
        if (isLeadEnd) {
        List<leadRound__c> mcs1 = new List<leadRound__c>();
        leadRound__c mcs = [SELECT Id, name__c, LeadRoundNm__C FROM leadRound__c WHERE name__c='leadround'];
        string textField='';
        integer LA;
        if (mcs.name__c == 'leadround') {
            textField = mcs.name__c;
            LA = integer.valueOf(mcs.LeadRoundNm__c);
        }
   
       for(lead lea2 : trigger.new) {
            integer round;
            for(round=1;round<=3;round++)
            {
                if(round==LA)
                {
                    integer arry = round -1;
                    integer LA1 = LA + 1;
             
                    if(LA1>3)
                    {
                        LA1 = 1;
                        mcs.LeadRoundNm__c=decimal.valueOf(LA1);
                        mcs1.add(mcs);
                    }
                    else {
                        mcs.LeadRoundNm__c = decimal.valueOf(LA1);
                        mcs1.add(mcs);
                    }
                }
            }
        }
    update mcs1;
    }
        }
}

The purpose of this trigger is to update a custom setting number field that we can refer to when assigning incoming End User leads via round robin (we cannot do the typical round robin custom formula based on an autonumber as we want our distributor leads to be assigned to specific users).

The trigger appears to be working fine in the development site and functions just as it should. However, the issue I am running into presently is in preparing the test class for this trigger. I have prepared the following test class and have run tests on it, but to no avail. Here is the test class I prepared:

@isTest

public class RoundRobinLeadTest{
static testMethod void myUnitTest ()
    {
        Boolean updated;
        integer roundBefore;
        integer roundAfter;
        List<leadRound__c> old1 = new List<leadRound__c>();
        leadRound__c old = [SELECT LeadRoundNm__c FROM leadRound__c];
        roundBefore = integer.valueOf(old.leadRoundNm__c);
       
        test.startTest();
        //Setup the lead record
        Lead lead = new Lead();
        lead.LastName = 'last';
        lead.FirstName = 'First';
        lead.company = 'Company';
        lead.Status = 'Open';
        lead.IsUnreadByOwner = true;
        lead.Distributor_or_End_User__c = 'End User';
        insert lead;
       
        leadRound__c new1 = [SELECT LeadRoundNm__c FROM leadRound__c];
        roundAfter = integer.valueOf(new1.leadRoundNm__c);
     
        if (roundBefore < roundAfter) {
            updated = true;
        }
        System.assert(updated);
        test.stopTest();
    }
}

Here is the Apex Test Result Detail that is returned:

Class = RoundRobinLeadTest
Method Name = myUnitTest
Pass/Fail = Fail
Error Message = System.QueryException: List has no rows for assignment to SObject
Stack Trace = Class.RoundRobinLeadTest.myUnitTest: line 10, column 1

What do I need to change in the test class code above to resolve this error and (hopefully) get my Apex Trigger rolled out on my production site?

Once again, I cannot say how greatful I am for the assistance here! Thanks!!


Hi Community,

I have a Vf page embeded on the standard account page.
In Vf page I am displaying the list of partner  records. I provided the the partner name with the hyper link.
Up to here it is going fine when i click on the link it is opening a the partner record. on left click opening in a new tab.

The same thing when it comes to Salesforce1 mobile app.
When i click on the partner link it opens the whole vfpage with the list of all partner records.

Does any one came acrosss this and if so, please share the solution how you overcome this.

Thanks,
Sure
Hi Everyone, hoping there is someone that is seeing something I'm not.  I have the following trigger, setRegPartnerTrigger that calls the APEX Class setRegPartner. The test code is testSetRegPartner. The test code executes with no issues in sandbox, the test leads are inserted, updated and result in 95% plus coverage. When I try to deploy, the test code errors out telling me it can't insert the first lead. 

I have run the code from the trigger and the test lead insert in an execute anonomyous window successfully so am completely stumped.  Hoping someone sees something I'm missing. 

APEX CLASS: 
public class setRegPartner{

    public static void setPartnerLookUp(Set<Id> dealRegIds){
        system.debug('number of leads received by SetPartnerOnDealReg class>>>'+dealRegIds.size());
        List<Lead> dealRegs = new List<Lead>();
        //put the leads in the trigger into a list for processing
        dealRegs = [SELECT id, Name, FirstName, LastName, Email, Phone, City, State, PostalCode, Company,
                            Deal_Registration_Status__c, Deal_Product__c, Deal_Registration_Date__c, deal_exp_close_date__c,
                            Deal_Registration_Expiration__c, Registered_Reseller__c, Preferred_Reseller__c,
                            Reseller_Sales_Person__c, Reseller_Phone_Number__c, Registered_Partner_Rep_Email__c,
                            Reseller_Region__c, Distributor__c, Deal_Distributor__c, Reseller_Rep__c
                            FROM Lead WHERE id IN :dealRegIds];
        system.debug('Deal Reg '+dealRegs);
        system.debug('number of leads in dealRegs List>>>'+dealRegs.size());
        //put partner account and reps into maps for later retrieval
        Map<String, Account> ptnrAccts = new Map<String, Account>();
        Map<String, Contact> ptnrReps = new Map<String, Contact>();
        Map<string, Account> ptnrDomains = new map<String,Account>();
       
        Set<String> acctTypes = new Set<String>();
        acctTypes.add('Var- Other');
        acctTypes.add('Var- Preferred');
        acctTypes.add('DMR');
        acctTypes.add('Etail');
        List<Account> ptnrs = new List<Account>();
        ptnrs = [SELECT id, Name, Type, OwnerId, email_domain__c FROM Account WHERE
                 Type IN :acctTypes];

        system.debug('partner type VAR- Other'+ptnrs);
        set<id> ptnrAcctIds = new Set<id>();
        set<string> emailset = new set<string>();
       
            for(Account a : ptnrs){
                ptnrAccts.put(a.Id, a);
                ptnrAcctIds.add(a.id);
                if(string.isNotblank(a.email_domain__c)){
                    ptnrDomains.put(a.email_domain__c, a);
                }
            }
            List<Contact> repList = [SELECT id, AccountId, FirstName, LastName, Email,
                          Phone, Account.OwnerId FROM Contact
                          WHERE AccountId IN :ptnrAcctIds];
              
            for(Contact c : repList){
                    system.debug('email for rep>>>'+c.email);
                    ptnrReps.put(c.email, c);
                    emailset.add(c.email);
                }
           
            system.debug('contact emails----   '+emailset);
            List<Contact> contactsToInsert = new List<Contact>();
        for(Lead l : dealRegs)
        {
            if (emailset.contains(l.Registered_Partner_Rep_Email__c))
              system.debug('email exist');
              else
              system.debug('doesnt exist');
        }
        //system.debug('print partner Account'+ptnrAccts);
        //system.debug('print partner Contact'+ptnrReps);
       
       Map<String, Account> distyAccts = new Map<String, Account>();
   
    //put distributors accounts into map
       List<Account> distys = new List<Account>();
        distys = [SELECT id, Name, Type, OwnerId FROM Account WHERE Type = 'Distributor'];
            for(Account d : distys){
                distyAccts.put(d.Name, d);
                }

        list<Lead> leadsToUpdate = new List<Lead>();
       
        for(Lead l : dealRegs) {
          String email =  l.Registered_Partner_Rep_Email__c;
                list <String> extractEmail = email.split('@');
                system.debug('email array'+ extractEmail);
                email = extractEmail[1];
            if(emailset.contains(l.Registered_Partner_Rep_Email__c)) {
                           
                    string acctId = ptnrReps.get(l.Registered_Partner_Rep_Email__c).Accountid;
                    l.Reseller_Rep__c = ptnrReps.get(l.Registered_Partner_Rep_Email__c).id;
                    l.Registered_Reseller__c = acctId;
                    l.Deal_Distributor__c = distyAccts.get(l.Distributor__c).id;
                    l.OwnerId = ptnrReps.get(l.Registered_Partner_Rep_Email__c).Account.OwnerId;
                    leadsToUpdate.add(l);                        
               
            } else if(!emailset.contains(l.Registered_Partner_Rep_Email__c) && ptnrDomains.get(email) != NULL){
                system.debug('doesnt exist');
               
               
                        String fName = l.Reseller_Sales_Person__c.left(l.Reseller_Sales_Person__c.indexOf(' '));
                        String lName = l.Reseller_Sales_Person__c.right(l.Reseller_Sales_Person__c.length()-

            l.Reseller_Sales_Person__c.indexOf(' '));                                              
                       
                        Contact newContact = new Contact();
                        newContact.FirstName = fName;
                        newContact.LastName = lName;
                        newContact.Email =l.Registered_Partner_Rep_Email__c;
                        newContact.Phone = l.Reseller_Phone_Number__c;
                        newContact.AccountId = ptnrDomains.get(email).id;
                       
                        system.debug('insert contact ' +newContact);
                        insert newContact;
                      l.Reseller_Rep__c = newContact.id;
                      l.Registered_Reseller__c = newContact.AccountId;
                      l.Deal_Distributor__c = distyAccts.get(l.Distributor__c).id;
                      leadsToUpdate.add(l);
               
            } else {
                   l.Partner_Status__c = 'Not Found';
                    leadsToUpdate.add(l);                        
                }
            }
        update leadsToUpdate;
    }
}

TRIGGER: 
trigger setRegPartnerTrigger on Lead (after insert) {
  Set<id> leadIds = new Set<id>();

    for(Lead l : trigger.new){
         
        if(l.LeadSource == 'Deal Registration'){
              system.debug(l); 
            leadIds.add(l.id);
        }
    }
    system.debug('number of leads sent to setRegPartner class>>>'+leadIds.size());   
    setRegPartner.setPartnerLookUp(leadIds);
   
}

TEST CODE: 
@isTest (seeAllData=true)
public class testSetRegPartner{
 
    static testmethod void testRegPartner(){
       
       Account disty = new Account(Name='Ingram Micro', Type='Distributor', Customer_ID__c = 'ING4051', email_domain__c = 'ingram.com');
       insert disty;
       Account ptnr = new Account(Name='Partner', Type='VAR- Other', Customer_ID__c = 'other123', email_domain__c = 'partner.com');
       insert ptnr;
       Contact rep = new Contact(FirstName='Pard', LastName='Rep', Email = 'pard@partner.com', Accountid = ptnr.id);
         insert rep;
       Contact distyRep = new Contact(FirstName='disty', lastName='Rep', Email='disty@rep.com', Accountid=disty.id, Deal_Registration_Contact__c = 'yes');
        insert distyRep;
       
       String DealRegRecTypeId = [SELECT id FROM RecordType WHERE SobjectType = 'Lead' and Name ='Partner Deal Registrations'].id;
      Lead noRepAcct = new Lead();
          noRepAcct.RecordTypeId = DealRegRecTypeId;
            noRepAcct.LeadSource = 'Deal Registration';
            noRepAcct.FirstName = 'first';
            noRepAcct.LastName = 'last';
            noRepAcct.Email = 'a@b.com';
            noRepAcct.City = 'mapleton';
            noRepAcct.State = 'IL';
            noRepAcct.PostalCode = '12345';
            noRepAcct.Company = 'test';
            noRepAcct.Deal_Registration_Status__c = 'Submitted';
            noRepAcct.Deal_Product__c = 'B800i';
            noRepAcct.Deal_Registration_Date__c = date.today();
            noRepAcct.deal_exp_close_date__c = date.today().addDays(30);
            noRepAcct.Preferred_Reseller__c = 'testReseller';
            noRepAcct.Reseller_Sales_Person__c = 'Test Rep';
            noRepAcct.Reseller_Phone_Number__c = '123-123-1234';
            noRepAcct.Registered_Partner_Rep_Email__c = 'tr@tp.com';
            noRepAcct.Distributor__c = 'Ingram Micro';
            noRepAcct.deal_unit_qty__c = 5;
        insert noRepAcct;
       
        Lead acctNoRep = new Lead();
            acctNoRep.RecordTypeId = DealRegRecTypeId;
            acctNoRep.LeadSource = 'Deal Registration';
            acctNoRep.FirstName = 'first';
            acctNoRep.LastName = 'last';
            acctNoRep.Email = 'a@b.com';
            acctNoRep.City = 'mapleton';
            acctNoRep.State = 'IL';
            acctNoRep.PostalCode = '12345';
            acctNoRep.Company = 'test';
            acctNoRep.Deal_Registration_Status__c = 'Submitted';
            acctNoRep.Deal_Product__c = 'B800i 8TB';
            acctNoRep.Deal_Registration_Date__c = date.today();
            acctNoRep.deal_exp_close_date__c = date.today().addDays(30);
            acctNoRep.Preferred_Reseller__c = 'testReseller';
            acctNoRep.Reseller_Sales_Person__c = 'Test Rep';
            acctNoRep.Reseller_Phone_Number__c = '123-123-1234';
            acctNoRep.Registered_Partner_Rep_Email__c = 'tr@partner.com';
            acctNoRep.Distributor__c = 'Ingram Micro';
            acctNoRep.deal_unit_qty__c = 5;
        insert acctNoRep;
       
        Lead acctRep = new Lead();
          acctRep.RecordTypeId = DealRegRecTypeId;
            acctRep.LeadSource = 'Deal Registration';
            acctRep.FirstName = 'first';
            acctRep.LastName = 'last';
            acctRep.Email = '1@b.com';
            acctRep.City = 'mapleton';
            acctRep.State = 'IL';
            acctRep.PostalCode = '12345';
            acctRep.Company = 'test';
            acctRep.Deal_Registration_Status__c = 'Submitted';
            acctRep.Deal_Product__c = 'B800i';
            acctRep.Deal_Registration_Date__c = date.today();
            acctRep.deal_exp_close_date__c = date.today().addDays(30);
            acctRep.Preferred_Reseller__c = 'testReseller';
            acctRep.Reseller_Sales_Person__c = 'Test Rep';
            acctRep.Reseller_Phone_Number__c = '123-123-1234';
            acctRep.Registered_Partner_Rep_Email__c = 'pard@partner.com';
            acctRep.Distributor__c = 'Ingram Micro';
            acctRep.deal_unit_qty__c = 5;
        insert acctRep;
       
        system.assertEquals(acctNoRep.Partner_Status__c, NULL);
        system.assertEquals(acctRep.Partner_Status__c, NULL);
        system.assertEquals(noRepAcct.Partner_Status__c, NULL);
       
        Set<id> dealRegIds = new Set<id>();
        dealRegIds.add(acctRep.id);
       
        setRegPartner.setPartnerLookUp(dealRegIds);
        acctRep.Deal_Registration_Status__c = 'Approved';
        update acctRep;

       
    List<Lead> testLeads = new List<Lead>();
    testLeads.add(acctRep);
   
    convertLead c = new convertLead();
    c.convertLeads(testLeads);
    List<Lead> convLead = [SELECT id, Distributor__c, ConvertedOpportunityId FROM
                Lead WHERE id = :acctRep.id];
               
    Quote q = [SELECT id, Distributor__c FROM Quote WHERE OpportunityId = :convLead[0].ConvertedOpportunityId];
   
    c.sendDistyEmail(q);
   
    acctNoRep.Deal_Registration_Status__c = 'Approved';
        update acctNoRep;
       
    List<Lead> testLeads2 = new List<Lead>();
    testLeads2.add(acctNoRep);
   
    convertLead d = new convertLead();
    d.convertLeads(testLeads2);
    List<Lead> convLead2 = [SELECT id, Distributor__c, ConvertedOpportunityId FROM
                Lead WHERE id = :acctNoRep.id];
               
    Quote q2 = [SELECT id, Distributor__c FROM Quote WHERE OpportunityId = :convLead2[0].ConvertedOpportunityId];
    List<QuoteLineItem> qlis = [SELECT id FROM QuoteLineItem WHERE QuoteID = :q2.id];
        system.debug('test code qlis size is>>>'+qlis.size());
    system.assertEquals(qlis.size(), 1);
   
    }
}

I did try the query in Force.com Explore and get the result whoever when I ran the test this error comes up.  Please help!!!
Here is my code:

@istest
private class QuoteProductEntryTests {

    static testMethod void theTests(){
      
          
        QuoteLineItem qli = [select Id, PricebookEntryId, PriceBookEntry.Product2Id, QuoteId, Quote.OpportunityId from QuoteLineItem limit 1];
             
              
        ////////////////////////////////////////
        //  test QuoteProductEntry
        ////////////////////////////////////////
      
        // load the page     
        PageReference pageRef = Page.QuoteProductEntry;
        pageRef.getParameters().put('Id',qli.QuoteId);
        Test.setCurrentPageReference(pageRef);
      
        // load the extension
        QuoteitemExtension oPEE = new QuoteItemExtension(new ApexPages.StandardController(qli.Quote));
      
        // test 'getChosenCurrency' method
        if(UserInfo.isMultiCurrencyOrganization())
            System.assert(oPEE.getChosenCurrency()!='');
        else
            System.assertEquals(oPEE.getChosenCurrency(),'');

        // we know that there is at least one line item, so we confirm
        Integer startCount = oPEE.ShoppingCart.size();
        system.assert(startCount>0);

        //test search functionality without finding anything
        oPEE.searchString = 'michaelforce is a hip cat';
        oPEE.updateAvailableList();
        system.assert(oPEE.AvailableProducts.size()==0);
      
        //test remove from shopping cart
        oPEE.toUnselect = qli.PricebookEntryId;
        oPEE.removeFromShoppingCart();
        system.assert(oPEE.shoppingCart.size()==startCount-1);
      
        //test save and reload extension
        oPEE.onSave();
        oPEE = new QuoteItemExtension(new ApexPages.StandardController(qli.Quote));
        system.assert(oPEE.shoppingCart.size()==startCount-1);
      
        // test search again, this time we will find something
        oPEE.searchString = qli.PricebookEntry.Name;
        oPEE.updateAvailableList();
        system.assert(oPEE.AvailableProducts.size()>0);     

        // test add to Shopping Cart function
        oPEE.toSelect = oPEE.AvailableProducts[0].Id;
        oPEE.addToShoppingCart();
        system.assert(oPEE.shoppingCart.size()==startCount);
              
        // test save method - WITHOUT quanitities and amounts entered and confirm that error message is displayed
        oPEE.onSave();
        system.assert(ApexPages.getMessages().size()>0);
      
        // add required info and try save again
        for(QuoteLineItem o : oPEE.ShoppingCart){
            o.quantity = 5;
            o.unitprice = 300;
        }
        oPEE.onSave();
      
        // query line items to confirm that the save worked
        QuoteLineItem[] qli2 = [select Id from QuoteLineItem where QuoteId = :qli.QuoteId];
        system.assert(qli2.size()==startCount);
      
        // test on new Opp (no pricebook selected) to make sure redirect is happening
        Quote newQuote = new Quote(Name='New quote', OpportunityId=qli.Quote.OpportunityId);
        insert(newQuote);
        oPEE = new QuoteItemExtension(new ApexPages.StandardController(newQuote));
        System.assert(oPEE.priceBookCheck()!=null);
      
        // final quick check of cancel button
        System.assert(oPEE.onCancel()!=null);
      
      
        ////////////////////////////////////////
        //  test redirect page
        ////////////////////////////////////////
      
        // load the page

   
    }
}
Hi All, 

This is not a problem as such but rather something that I do not quite understand.
I have writted an apex and visualforce code that has operated correctly but I do not undertand why! Hope someone can clarify my misunderstanding?

I have a apex Controller class that has a inner custom wrapper class of objects that I called "AssetLine".

To make things simple, I used maps<string, AssetLine> where the key is the unique string name for each AssetLine.

Now I created a visualforce page which dumps out using <Apex:repeat> a LIST of AssetLine which obviously comes from the Map I created earlier. In this visualforce page contains inputText fields which allow me to manimulate the AssetLine individually and update the instance dynamically.

The ODD THING IS THIS: whenever I update the values in the inputText fields, these fields automatically update the corresponding Map<string, AssetLine> without me having to write any such code in the apex controller telling the LIST to update the corresponding AssetLine in the Map...

How is this possible that the MAP is automatically updated??!!!? 

Thanks.
Regards,
Joey Ho
Hi can anyone help,

I have created a map which represents the following

map<Id, Map<Id, SObject> myMap = new map<Id, Map<Id, SObject>();

I have populate the different keys and values but I'm having problems retrieving the values in the SObject without having to loop through the map.

Something like myMap.values().values()

I know I can use mymap.get().get() so there must be some sort of shortcut
HI i have a requirement.
i have 2 objects object A and object B object B is the master object and object A is child. on object B i need to create a custom button, onclick the custom button i need to popup a visualforce page we have fields along with save button . on entering the fields and on clicking the SAVE button the fields should get updated on the object A fields.

please let me know how to do it.. 


thanks in advance..
regards,
Santosh
i have a custom picklist Status__c with values 'Open' & 'Closed' and a date field Close_Date__c.

what should i do if i want the Status__c to update its value to 'Closed' whenever the value of Close_Date__c is less than or equal to today's date[system.today()] without editing/updating the record?

if i use a trigger then the record's Status__c will only update whenever the record is created or edited. i tried using a workflow rule for this but it didn't work. the evaluation criteria of the workflow rule is 'created, and any time it’s edited to subsequently meet criteria'. 

  • February 15, 2014
  • Like
  • 0
Hi,

I am including the following code to the trigger and it does not update the custom object. Please help me on this :(

if((trigger.isAfter && trigger.isInsert) || (trigger.isAfter && trigger.isUpdate))
    {
    list<Opportunity> opp = new list<Opportunity>();
    opp = [select id,Brand_Name1__c from opportunity where id  =: Trigger.new[0].OpportunityID__c];
       if(opp[0].Brand_Name1__r.Name.contains('sam') )
       {
            Trigger.New[0].Comments__c = '25';
            Trigger.New[0].Agency_Commission__c = 25;
       }
    }
Could someone please help why the following code is not working??

________

public class THUpdateLRO extends AbcTriggerHandler {
    private void updateLRO(List<License_Registration__c> newLROs) {
     

Set<id> AccIds = new Set<id>();

    for (License_Registration__c c : newLROs){
        AccIds.add(c.Current_Application__c);
    }

    Map<id, Application__c> AccIDmap = new Map<id, Application__c>([Select Id, Application_Outcome__c from Application__c
    Where Id in :AccIds]);
  
    for (License_Registration__c LicReg : newLROs){
       if(LicReg.Current_Application__c != null && LicReg.Current_Application__r.Application_Status__c == 'Withdrawn'){

       LicReg.Status__c = AccIDmap.get(LicReg.Current_Application__c).Application_Outcome__c; 
       }      
}
}

public override void OnBeforeInsert(SObject[] newObjects){
        updateLRO((List<License_Registration__c>)newObjects);
    }
public override void OnBeforeUpdate(SObject[]       newObjects,
                                       Map<Id,SObject> newObjectMap,
                                       SObject[]       oldObjects,
                                       Map<Id,SObject> oldObjectMap){
         updateLRO((List<License_Registration__c>)newObjects);
    }
}
  • February 15, 2014
  • Like
  • 0
Is this trigger bulkified im unable to bulk inset using data loader only the last recored in the csv file gets the field update properly

trigger urlattachmentupdate on Attachment (after insert,after update) {
list<contact>cc=new list <contact>();
set<attachment>a=new set<attachment>();
Public string attachmentid='';
Public string parentid='';

for(Attachment aa:trigger.new){
attachmentid=aa.id;
parentid=aa.parentid;
System.debug('Attchment IDDD'+attachmentid);
System.debug('ParentIDDDDDDDDDDD'+parentid);
}
cc=[Select id from contact where id =:parentid];
for(contact cc1:cc){
cc1.Member_Photo_URL__c='https://c.cs10.content.force.com/servlet/servlet.FileDownload?file='+attachmentid;
}
update cc;
}
Hello,

I want to get the owner name of my Notes object. I did <apex:outputField value="{!note.OwnerId}"/> which gives the Owner name but as hyperlink. I do not want the hyperlink.I tried <apex:outputText but it give the id not the name.
I am sure someone must have faced this issue.

Thanks
Ok, this is giving me head ache, I have so far been unable to get it correct. The below code works, but I really need to get the SOQL outside of the FOR loop, due to apex govenor limits. Can you assist please?

trigger CaseEquipmentStatus on Case (After Update) {
Set<Id> caseIds = new Set<Id>();
Set<Id> EquipIds = new Set<Id>();
       for (Case c: Trigger.New){
         if (c.Opportunity__c != null && c.Status == 'Request Completed' && c.Origin == 'PRM' )
         caseIds.add(c.Opportunity__c);
         }
         for (Equipment__c Eq: [select id, Opportunity__c, Statis__c from
         Equipment__c where Opportunity__c in :caseIds]) {
         if(eq.Statis__c == 'Programming Change Requested'){
         eq.Statis__c = 'Active';    }
         Update eq;
        } }
Is there a way to call out a standard controller for ex. "Account" from an already existing custom controller? What is the best practice for using a custom controller and standard controller together from one apex class. or is my thinking is all wrong? Thanks
  • February 11, 2014
  • Like
  • 0
Hey there,

I have a tabbed account VF page, each one of these tabs is a child to Account. I have created an extension which allows me to delete records from the tabs without being re-directed away from the open tab. My question is, how do I go about adding the "are you sure?" message or something of my choosing when the user clicks on the delete button? Is it something that I add on page level, to the extension or a combination where the extension decides when the page message will appear.

Thank you for your help. I can provide my extension and delete buttons on request.
JQuery mobile is not filtering my list. The list change with the select box works.
I cannot get the text filter to work.

The same code works elsewhere, but not on this project.

I tried updated the libraries to no avail.

Here is the Visualforce page:

<apex:page controller="OnlineStoreOrderController" showHeader="false"
sidebar="false">
<head>

<meta name="viewport"
  content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<apex:includeScript value="{!$Resource.jquery191}" />
<apex:includeScript value="{!URLFOR($Resource.jquerymobile130, 'jquery.mobile-1.3.0.min.js')}" />
<apex:stylesheet value="{!URLFOR($Resource.jquerymobile130, 'jquery.mobile-1.3.0.min.css')}" />


<script>

        $(document).ready(function() {

             $("#conference").on("change", function(){
                //$.mobile.showPageLoadingMsg();
               OnlineStoreOrderController.getSessions(this.value,handleGetSessions)
              //$.mobile.hidePageLoadingMsg();
              });

        });

  function handleGetSessions(result, event) {
      $("#sessionList").empty();
      $.each(result, function(index, value){
         $('#sessionList').
         append('<li data-filtertext="value.Name value.Session_Name__c" data-role=\"list-divider\">'+value.Name+' - ' + value.Session_Name__c+'</li>');

    });
    $("#sessionList").listview("refresh");
}

</script>
</head>
<select name="conference" id="conference">
  <option value="All">select a conference</option>
  <apex:repeat value="{!conferences}" var="conference">
   <option value="{!conference.Id}">{!conference.Name}</option>
  </apex:repeat>
</select>

<!-- page content -->
<div id="#content" data-role="content">
<ul id="sessionList" data-role="listview" data-filter="true"
  data-inset="true">
  <apex:repeat value="{!sessions}" var="session">
   <li data-theme="d"
    data-filtertext="{!session.Name} {!session.Session_Name__c}">
   {!session.Name} - {!session.Session_Name__c}</li>

  </apex:repeat>
</ul>
</div>
</apex:page>