• Suresh Raghuram
  • SMARTIE
  • 926 Points
  • Member since 2011
  • Sr Salesforce Consultant


  • Chatter
    Feed
  • 34
    Best Answers
  • 2
    Likes Received
  • 3
    Likes Given
  • 119
    Questions
  • 476
    Replies
Hi All,

I'm having trouble testing a trigger I have for my Opportunity objects.

I have a custom object 'QQ' which is in a master-detail relationship with my Opportunity, and whenever the 'Total' field in the QQ is changed, this rolled up to my Opportunity, which then updates the Opportunity Probability via the trigger.

The problem I'm having is inserting a QQ in my test class. Each time I run the test, I get the following error: 
System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Opportunity__c]: [Opportunity__c]

My test class code is the following:

@isTest
public class TestUpdateProbTrigger {
    static testMethod void insertNewOpp() {
        
       account acct = new account(Name = 'testing');
       insert acct;
       
       Opportunity o = new Opportunity(
               Name = 'testing',
               AccountId = acct.id,
               CloseDate = System.today(),
            StageName = 'Warm Prospect'
       );
        
       QQ__c q = new QQ__c (
            Name = 'test'
            S1_x__c = true,    //these 4 fields can be ignored
            L1_x__c = true,    
            C1_x__c = true,
            Q1_x__c = true,
            Opportunity__r = o,      
            Opportunity__c = o.Id     //here I provided the Opportunity__c field for the QQ object, and yet I still get that error
       );
         
       o.QQ__c = q.Id;   
        
        insert o;
        insert q;
        
        q.D1_x__c = true;
        update q;
        
        System.assertEquals('Qualify', o.StageName);    //this is just to verify that the stage name changed correctly
    }
}
 
There is also a lookup relationship between the QQ and the Opportunity, though I doubt that is relevant to this. Does anyone have any suggestions? Thanks in advance!

Best,
Jeff
 
  • February 20, 2015
  • Like
  • 0
I am creating a visualforce email template that needs to include the case thread id in it so end users are able to reply. 

I am reading that I should be using {!Case.Thread_Id} but when I use this, I get the following error: Unknown property 'core.email.template.EmailTemplateComponentController.Case' 

If I change this to {!relatedTo.Thread_Id} then I get Invalid field Thread_Id for SObject Case


Can someone please help me on this?    I would assume if I was using default templates that SalesForce could actually just input the ThreadID for me as it is an option on the Case > Settings options page but since were using custom VF templates, this wont work.

in my  contact  if edit and modify to a feild ,  the feild   in account object should need to be updated.....there is master detail relationship between them,how should we work when there is relation ship like this.

 

trigger contact_ac on Account (is insert,after insert,is update) {
contact ct=new contact();
for(account ac:trigger.new)
{

   if(ac.domain__c=='gmail')

    ct.mail='mail' ;
     update ct;

}

 

 

if  wrong so please help me...

Hi, 

I want to get some suggestions on one of the issues I am having. 

 

I want to change the data type for one of the custom objects. Currently, the field is picklist and is being used in multiple apex classes and triggers. I need to change it to Text field. I have come up with two solutions so far but I am not sure if any of these is the best practice. Please correct me if I am missing anything.

1) First solution is to comment the codes where the field is being used and then change the dataType and again uncomment back the codes. With this process, when I have to deploy it to production, it might be a bigger risk as it is being used in multiple places.

2) Second solution that I could think of is; creating a new field with datatype 'Text', and copying the existing records to this new field. Then replacing this new field with old field in the Apex classes and triggers.

 

Please suggest me if there are any other solutions.

Also, please suggest how would I revert this whole process if something goes wrong (any suggestion except the refresh of the sandbox would be appreciated).

 

Thanks in Advance!

Justin.

I have a class that makes some updates based on OpportunityPartner.  I am working on the test method but am not sure how to create an OpportunityPartner to use for the test.  When I try to insert an OpportunityPartner it says that DML is not allowed which makes sense because OpportunityPartner is a read only object.  So what I want to know is how do I run a test method when my class relies on at least 1 OpportunityPartner being created? 

How to create a simple VF Page with only one link in it which will upon clicking on it will take me to another VF Page2.

Please help.

Thanks

Sai

Hi

Just started learning SF so please help in ansering the new bie questions:

 

1. When creating a new visual force page from Setup --> Develop --> Pages --> New

There is a button called "Where is this used"

What is this used for as it does not show anything when i click on it.

 

A couple of more related to this:

2. What is Version Settings used for?

 

3. What is show dependencies used for?

 

Any help is really appreciated.

Thanks

Sai

Where could I find (or possibly generate)  a token (from salesforce) to connect another web application to my account in  salesforce?

I am using WSDL to connect to salesforce.

 

Hi

 


How many ways you can invoke an work flow?

Hi All,

 

I am new to Apex coding.  I need help with creating a test class for my trigger below.  Thanks in advance.

 

 

 

trigger ManagedCareProducts on Contract (after insert) {

//When Managed Care Contract is created, a list of Service Line items will be 
//inserted into the Contract record.

    List <Contract_Products__c> CPToInsert = new List <Contract_Products__c> (); 
    
    for (Contract cont : Trigger.new) {
        
        if(cont.RecordTypeId == '012Z00000004TIC')  {
     
        
        //New Service Line: Drug//
        Contract_Products__c CP1 = new Contract_Products__c (); 
            CP1.Name = 'Drug';
            CP1.Product__c = '01tZ0000000N38u';
            CP1.Contract__c = cont.Id;
           
      //New Service Line: E&M//
        Contract_Products__c CP2 = new Contract_Products__c (); 
            CP2.Name = 'E&M';
            CP2.Product__c = '01tZ0000000N38z';
            CP2.Contract__c = cont.Id;
            
      //New Service Line: Chemo Admin//
        Contract_Products__c CP3 = new Contract_Products__c (); 
            CP3.Name = 'Chemo Admin';
            CP3.Product__c = '01tZ0000000Npbs';
            CP3.Contract__c = cont.Id;
            
        //New Service Line: Radiation//
        Contract_Products__c CP4 = new Contract_Products__c (); 
            CP4.Name = 'Radiation';
            CP4.Product__c = '01tZ0000000NpcG';
            CP4.Contract__c = cont.Id;
            
        //New Service Line: Diagnostic//
        Contract_Products__c CP5 = new Contract_Products__c (); 
            CP5.Name = 'Diagnostic';
            CP5.Product__c = '01tZ0000000Npc1';
            CP5.Contract__c = cont.Id;
            
       //New Service Line: Gyn//
        Contract_Products__c CP6 = new Contract_Products__c (); 
            CP6.Name = 'Gyn';
            CP6.Product__c = '01tZ0000000Npc6';
            CP6.Contract__c = cont.Id;
            
        //New Service Line: PET//
        Contract_Products__c CP7 = new Contract_Products__c (); 
            CP7.Name = 'PET';
            CP7.Product__c = '01tG0000002mSlb';
            CP7.Contract__c = cont.Id;
            
       //New Service Line: Lab//
        Contract_Products__c CP8 = new Contract_Products__c (); 
            CP8.Name = 'Lab';
            CP8.Product__c = '01tZ0000000NpcB';
            CP8.Contract__c = cont.Id;
            
        //New Service Line: Surgical//
        Contract_Products__c CP9 = new Contract_Products__c (); 
            CP9.Name = 'Surgical';
            CP9.Product__c = '01tZ0000000NpcL';
            CP9.Contract__c = cont.Id;
            
        //New Service Line: Other//
        Contract_Products__c CP10 = new Contract_Products__c (); 
            CP10.Name = 'Other';
            CP10.Product__c = '01tZ0000000NpcQ';
            CP10.Contract__c = cont.Id;
             
        
                   
        CPToInsert.add(CP1);
        CPToInsert.add(CP2);
        CPToInsert.add(CP3);
        CPToInsert.add(CP4);
        CPToInsert.add(CP5);
        CPToInsert.add(CP6);
        CPToInsert.add(CP7);
        CPToInsert.add(CP8);
        CPToInsert.add(CP9);
        CPToInsert.add(CP10); 
        } //end if
        
    }//end for

     try {
        insert CPToInsert; 
    } catch (system.Dmlexception e) {
        system.debug (e);
    }

  • February 07, 2013
  • Like
  • 0

Hello! This is my trigger. If the Account filed on Contact is not equal to "Not Available" then it populates Parent Account Field on Contacts with the Account.Parent.

 

Trigger updateParentAccountName on Contact(before insert,before update){

List<Contact> conList = new List<Contact>();
List<Contact> accList = new List<Contact>();
List<Id> idList = new List<Id>();

for(Contact con :Trigger.new){
if(con.Account.Name != 'Not Available'){
idList.add(con.AccountId);

}
}

Map<Id,Account>accMap = new Map<Id,Account>([select ParentId from Account where id in:idList]);

for(Contact c : trigger.new){
if(c.Account.Name != 'Not Available'){
c.Parent_Name__c = accMap.get(c.AccountId).ParentId;
}
}
}

Can anyone help me write a test class for this?

 

I have written the following but doesnt seem to work.

 

@isTest
private class TestUpdateParentaccountName
{
  static testMethod void mytest()
  {
    //Create the 2 different categories the contact name may fall in
    List<Contact> testContacts = new List<Contact>();
    Contact testCase = new Contact();
    testCase.LastName = 'test1';
    testCase.Account.Name = 'Food and Drug Administration';
    testContacts.add(testCase);
    
    Contact testCase2 = new Contact();
    testCase2.LastName = 'test2';
    testCase2.Account.Name = 'Not Available';
    testContacts.add(testCase2);
    
    insert testContacts;
    
    }

  • February 06, 2013
  • Like
  • 0

Hello,

 

Can anyone help me bulkify the below trigger? I would like to insert the same Test_Opportunity__c records to the current opportunity record as was attached to the opportunity I cloned from (using the Opportunity_Clone_Id__c field).

 

 

trigger CreateOpportunityRelated on Opportunity (after insert) 
{ 

    for (Opportunity opp : Trigger.new)     
    { 
        ID cloneID = opp.Opportunity_Clone_ID__c; //OPPORTUNITY WE'RE CLONING FROM 
        ID oppID = opp.Id; //OPPORTUNITY WE CLONED INTO


        List<Test_Opportunity__c> tps = new List<Test_Opportunity__c>(); //EMPTY LIST OF TEST OPPORTUNITY OBJECTS 

        //POPULATE Test OPPORTUNITY OBJECTS
        for (Test_Opportunity__c test_opp : [SELECT Test_Number__c FROM Test_Opportunity__c WHERE Opportunity_Name__c = :cloneID])
        {
                        Test_Opportunity__c new_test_opp = New Test_Opportunity__c(
                        Opportunity_Name__c = oppId, 
                        Test_Number__c = test_opp.Test_Number__c);
                        tps.add(new_test_opp);
        }
        INSERT tps; //DO A SINGLE INSERT OF ALL Test OPPORTUNITY RECORDS 
    }
}

 Thank you!

  • February 04, 2013
  • Like
  • 0

Request help in multiplying values in Two  Fields (UnitPrice__c  & QuantitySold__c}

& display the value in edit mode in 3rd Field (TotalSale__c)

 

All the 03 Fields are  Number type

 

 -----------------------------------VF Page------------------------------------------------------------------------------
               
  <apex:inputField id="IDUnitPrice" value="{!opportunity.UnitPrice__c}" ></apex:inputField>
  <apex:inputField id="IDQtySold" value="{!opportunity.QuantitySold__c}"  onkeyup="javascript&colon;CalculateAmount();">  

  </apex:inputField>
  <apex:inputField id="IDTotalSale" label="Total Sale" value="{!opportunity.TotalSale__c}"></apex:inputField>
 ------------------------------------Script -----------------------------------------------------------------------------------

function CalculateAmount()
      {  
        
         var Price =  VALUE(UnitPrice__c.);
         var Qty = VALUE(QuantitySold__c);
         
         var Amount =  Price * Qty;      
      
         VALUE(TotalSale__c) = Amount;
      }
         

I'm new to SOQL, not at all new to SQL.

 

My error is - 19:54:07:150 FATAL_ERROR System.QueryException: unexpected token: AND

 

with this query:

SELECT
Id,
Name,
Shipper_Name__c,
Service__c,
Dispatch_Date__c,
Start_Time__c,
End_Time__c
FROM
Dispatch__c
WHERE
Shipper_LastName__c like '%load%'
OR Phone_1__c = 'load'
OR Phone_2__c = 'load'
OR GBL__c = 'load'
OR SIT__c = 'load'
OR SO__c = 'load'
OR REF__c = 'load'
OR BOL__c = 'load'
OR Service__c = 'load'
AND ( Dispatch_Date__c >= 2012-12-17 AND Dispatch_Date__c <= 2012-12-31 )
ORDER BY
Dispatch_Date__c DESC

 

But this works:

SELECT
Id,
Name,
Shipper_Name__c,
Service__c,
Dispatch_Date__c,
Start_Time__c,
End_Time__c
FROM
Dispatch__c
WHERE
 Dispatch_Date__c >= 2012-12-17 AND Dispatch_Date__c <= 2012-12-31 
ORDER BY
Dispatch_Date__c DESC

Basically what I'm trying to do is ensure a few custom object records are created whenever an opportunity is created for a certain group of user.

 

I have with great effort created a trigger which I absolutely have to deploy urgently but I need test coverage on it. I would greatly appreciate any help on it because I don't know where to start. 

 

Can someone please help me get even part of the way there?

 

Thanks so much

 

trigger JobAidsForRDGAD on Opportunity (after insert) {
  
  List<AD_Job_Aid_NeedsAssess__c> needs = new List<AD_Job_Aid_NeedsAssess__c>();
    List<Job_Aid_Retail_AD__c> interviewers = new List<Job_Aid_Retail_AD__c>();
  
    for (Opportunity newopp: Trigger.New) {
        if (newopp.Id!= null) {
            interviewers.add(new Job_Aid_Retail_AD__c(
                        opportunity_name__c = newopp.Id,
                        recordtypeid = '01280000000G7PFAA0',
                        Name = 'Opportunity Assessment'));                            
                        
              interviewers.add           (new Job_Aid_Retail_AD__c(
                        opportunity_name__c = newopp.Id,
                        recordtypeid = '01280000000UFvqAAG',
                        Name = 'Risk Assessment'));
                        
              interviewers.add(new Job_Aid_Retail_AD__c(
                        opportunity_name__c = newopp.Id,
                        recordtypeid = '01280000000UFeoAAG',
                        Name = 'Compelling Event'));
                        
              needs.add(new AD_Job_Aid_NeedsAssess__c(
                        opportunity__c = newopp.Id,
                        Name = 'Solution Needs'));
        }
    }
    insert interviewers;
    insert needs;
}

 

  • August 10, 2012
  • Like
  • 0

I have overwritten the custom object 'New' button, I would like to access the id of the record when they click the 'New' button. Is it possible to get the Id of the record before it is committed to the DB(sounds stupid..but i thought I will still go ahead and ask)

This is the contructor

 

private Sales__c salesesource;

public salesResourceController(ApexPages.StandardController controller) {
        salesesource = (Sales__c)controller.getRecord();
        System.debug('Called salesResourceController' +salesesource );
    }

Hello,

 

I just downloaded the Inline Account Hierarchy app in our test environment.  I am fairly new to Visualforce and need some help.  How can i modify this VF code so that a custom field (Account_ID__c) will be added next to the account name. 

 

 

<apex:page standardController="account" tabStyle="Account" >
<div style="height: 200px" class="bodyDiv" onclick="resizeFrame();">
<c:AccountHierarchyTree currentId="{!Account.id}" />
</div>
</apex:page>

 



  • July 25, 2012
  • Like
  • 0

Hi ,

I have created the below class and want to create sOject and assign value to it.

 

Can anyone guide me , why m i getting the compiler error "Invalid Invoice_Starement_c " type?

Below is my code

 

public

withvsharingvclassvObjectprac {

 

publicvstaticvvoidvobj()

{

sObject s =

newInvoice_Statement__c();

Invoice_Statement__c inv =

new Invoice_Statement__c(Description__c='Test Invoice',Status__c='Pending');

System.debug(

'Invoice'+ inv.Description_c);

}

 

}

Hi All,

 

I have 2 custom objects called Login_page__c and Candidate__c

 

when I click  on Newuser button in Login_page__c that is created in if page, then it should redirected to Candidate edit page for creating new candidate 

 

Thanks & Regards,

Bharath

Challenge Not yet complete... here's what's wrong: 
Ensure that test methods can't use live data.

@isTest (seeAllData=false)
private class Product2Tests {
@testSetup
public static void SetupTestData(){  
    
    CollaborationGroup ChatterGroup = new CollaborationGroup(
        Name = 'TEST'+constants.INVENTORY_ANNOUNCEMENTS,  
        CollaborationType = 'Public',
        CanHaveGuests = false,
        IsArchived = false,
        IsAutoArchiveDisabled = true
        );
    insert ChatterGroup;
     
}
    
@isTest
    static void Product2Extension_UnitTest(){
        PageReference pageRef = Page.Product2New;
        Test.setCurrentPage(pageRef);
        Product2 prod = new Product2(name='Test',isActive=true);        
        ApexPages.StandardController stdcontroller = new 
        ApexPages.StandardController(prod);        
        Product2Extension ext = new Product2Extension(stdcontroller);        
         System.assertEquals(Constants.DEFAULT_ROWS, ext.productsToInsert.size());
        
        ext.addRows();
        System.assertEquals(Constants.DEFAULT_ROWS * 2, 
        ext.productsToInsert.size());
        
        for (Integer i = 0; i < 5; i++) {
            Product2Extension.ProductWrapper wrapper = ext.productsToInsert[i];
            
            Product2 testProd = new Product2();
            testProd.Name = 'Test Product ' + i;
            testProd.IsActive = true;
            testProd.Initial_Inventory__c = 20;
            testProd.Family = Constants.PRODUCT_FAMILY[0].getValue();
            wrapper.productRecord = testProd;
            
            PricebookEntry testPBEntry = new PricebookEntry();
            testPBEntry.IsActive = true;
            testPBEntry.UnitPrice = 10;
            wrapper.pricebookEntryRecord = testPBEntry;
        }
        
        Test.startTest();
        ext.save();
        Test.stopTest();
        
        ext.GetFamilyOptions();
        ext.GetInventory();
        List<Product2> createdProducts = [
            SELECT
              Id
            FROM
               Product2
        ];
        System.assertEquals(5, createdProducts.size());
    }
    
   @isTest
    static void Product2Trigger_UnitTest(){
        TestDataFactory.InsertTestData(5); 
          test.startTest();
        
     
        Order rec = [select id, Status from Order limit 1];
        Product2 prod = [SELECT Family,Id,Name,Quantity_Ordered__c,Quantity_Remaining__c FROM  Product2 WHERE Name LIKE :'Test Product%' limit 1];
   
       rec.status = constants.ACTIVATED_ORDER_STATUS;      
       Update rec;
       Product2 updatedprod = [SELECT Family,Id,Name,Quantity_Ordered__c,Quantity_Remaining__c FROM Product2 limit 1];
        
  TestDataFactory.VerifyQuantityOrdered(prod,updatedprod,constants.DEFAULT_ROWS);
       Test.stopTest();
    
    }
}

***********************
/**
 * @name TestDataFactory
 * @description Contains methods to construct and/or validate commonly used records
**/
public with sharing class TestDataFactory {

    /**
     * @name ConstructCollaborationGroup
     * @description
    **/
    public static CollaborationGroup ConstructCollaborationGroup(){
        //ToDo: Ensure this method returns a single Chatter CollaborationGroup
        //    whose Name starts with 'TEST' followed by the INVENTORY_ANNOUNCEMENTS constant
        //    and configured so anyone can join, see and post updates.
        CollaborationGroup grp = new CollaborationGroup();
        
        grp.Name='TEST'+Constants.INVENTORY_ANNOUNCEMENTS;
        grp.CollaborationType='Public';
        grp.IsAutoArchiveDisabled = true;
        return grp;
    }

    /**
     * @name CreateProducts
     * @description Constructs a list of Product2 records for unit tests
    **/
    public static List<Product2> ConstructProducts(Integer cnt){
        //ToDo: Ensure this method returns a list, of size cnt, of uniquely named Product2 records
        //  with all the required fields populated
        //  and IsActive = true
        //  an Initial Inventory set to 10
        //  and iterating through the product family picklist values throughout the list.
        List<Schema.PicklistEntry> familyLst = Constants.PRODUCT_FAMILY;
        List<Product2> testPrdts = new List<Product2>();
        for(Integer i=0;i<cnt;i++){
            Integer index = Math.mod(i, familyLst.size());
            testPrdts.add(new Product2(Name='TEST_PRODUCT_'+i,isActive=TRUE,Initial_Inventory__c=10,Family=familyLst[index].getValue()));
        }
       return testPrdts;
    }

    /**
     * @name CreatePricebookEntries
     * @description Constructs a list of PricebookEntry records for unit tests
    **/
    public static List<PricebookEntry> ConstructPricebookEntries(List<Product2> prods){
        //ToDo: Ensure this method returns a corresponding list of PricebookEntries records
        //  related to the provided Products
        //  with all the required fields populated
        //  and IsActive = true
        //  and belonging to the standard Pricebook
      List<PricebookEntry> testPricebookEntries = new List<PricebookEntry>();
        for(Product2 prod:prods){
            testPricebookEntries.add(new PricebookEntry(Product2Id=prod.Id,PriceBook2Id=Constants.STANDARD_PRICEBOOK_ID,IsActive=TRUE,UnitPrice=5));
        }
        return testPricebookEntries;
    }

    /**
     * @name CreateAccounts
     * @description Constructs a list of Account records for unit tests
    **/
    public static List<Account> ConstructAccounts(Integer cnt){
        //ToDo: Ensure this method returns a list of size cnt of uniquely named Account records
        //  with all of the required fields populated.
        List<Account> testAcc = new List<Account>();
        for(Integer i=1;i<=cnt;i++){
            testAcc.add(new Account(Name='TEST_ACCOUNT_'+i));
        }
        return testAcc;
    }
    /**
     * @name CreateContacts
     * @description Constructs a list of Contacxt records for unit tests
    **/
    public static List<Contact> ConstructContacts(Integer cnt, List<Account> accts){
        //ToDo: Ensure this method returns a list, of size cnt, of uniquely named Contact records
        //  related to the provided Accounts
        //  with all of the required fields populated.
        List<Contact> testCnts = new List<Contact>();
        for(Integer i=0;i<cnt;i++){
            Integer index = Math.mod(i, accts.size());
            testCnts.add(new Contact(LastName='TEST_CONTACT_'+i,AccountId=accts[index].Id));
        }
        return testCnts;
    }

    /**
     * @name CreateOrders
     * @description Constructs a list of Order records for unit tests
    **/
    public static List<Order> ConstructOrders(Integer cnt, List<Account> accts){
        //ToDo: Ensure this method returns a list of size cnt of uniquely named Order records
        //  related to the provided Accounts
        //  with all of the required fields populated.
        List<Order> testOrds = new List<Order>();
        for(Integer i=0;i<cnt;i++){
            Integer index = Math.mod(i, accts.size());
            testOrds.add(new Order(PriceBook2Id=Constants.STANDARD_PRICEBOOK_ID,Name='TEST_ORDER'+i,AccountId=accts[index].Id,EffectiveDate=System.today()-10,Status='Draft'));
        }
        return testOrds;
    }

    /**
     * @name CreateOrderItems
     * @description Constructs a list of OrderItem records for unit tests
    **/
    public static List<OrderItem> ConstructOrderItems(integer cnt, list<pricebookentry> pbes, list<order> ords){
        //ToDo: Ensure this method returns a list of size cnt of OrderItem records
        //  related to the provided Pricebook Entries
        //  and related to the provided Orders
        //  with all of the required fields populated.
        //  Hint: Use the DEFAULT_ROWS constant for Quantity as it will be used in the next challenge
        List<OrderItem> testOrdItms = new List<OrderItem>();
        for(Integer i=0;i<cnt;i++){
            Integer indexP = Math.mod(i, pbes.size());
            Integer indexO = Math.mod(i, ords.size());
            testOrdItms.add(new OrderItem(PricebookEntryId=pbes[indexP].Id,OrderId=ords[indexO].Id,Quantity=Constants.DEFAULT_ROWS,UnitPrice=10));
        }        
        return testOrdItms;
    }

    /**
     * @name SetupTestData
     * @description Inserts accounts, contacts, Products, PricebookEntries, Orders, and OrderItems.
    **/
    public static void InsertTestData(Integer cnt){
        //ToDo: Ensure this method calls each of the construct methods
        //  and inserts the results for use as test data.
        List<Account> acts = ConstructAccounts(cnt);
        insert acts;
        List<Contact> cnts = ConstructContacts(cnt, acts);
        insert cnts;
        List<Product2> prds = ConstructProducts(cnt);
        insert prds;
        List<PricebookEntry> prcbookEntries = ConstructPricebookEntries(prds);
        insert prcbookEntries;
        List<Order> ords = ConstructOrders(cnt,acts);
        insert ords;
        List<OrderItem> ordItems = ConstructOrderItems(cnt,prcbookEntries,ords);
        insert ordItems;
    }
    
    public static void VerifyQuantityOrdered(Product2 originalProduct, Product2 updatedProduct, Integer qtyOrdered){        
        System.assertEquals(originalProduct.Quantity_Ordered__c+qtyOrdered,updatedProduct.Quantity_Ordered__c);
    }

}
 
I need help  in writing test class on the following WSDL generated apex class.
I also provided testclass that I started and where I am stuck and not able to make move.
I posted this in stackflow  too http://salesforce.stackexchange.com/questions/93522/test-class-for-the-wsdl2apex-class

@isTest
private class ContractMockCalloutTest {
testmethod static void SFDCGatewayWSDLSOAPQSPort_SearchCustomerContractTest() {
Test.startTest(); Test.setMock(WebServiceMock.class, new ContractListMockWebServiceCallout()); wwwmysiteComsfdcContract.wwwmysiteComsfdcContract stub = new wwwmysiteComsfdcContract.wwwmysiteComsfdcContract();
//Here I am stuck dont know to make a move when I refer stub.inner class it is throwing invalid type.
}
}


public class wwwmysiteComsfdcContract {
public class sfdcContractWSDLSOAPQSPort {
public String endpoint_x = 'http://sfdc2-osb-dit.us.mysite.com:80/sfdc/Contract/Services'; public Map < String, String > inputHttpHeaders_x;
public Map < String, String > outputHttpHeaders_x;
public String clientCertName_x; public String clientCert_x;
public String clientCertPasswd_x; public Integer timeout_x;
public wwwmysiteComsfdcGilHeaderdataxmlsCONTRACT.headerData_element request_header; private String request_header_hns = 'headerData=http://www.mysite.com/sfdc/GIL/HeaderDataXMLS';
private String[] ns_map_type_info = new String[] { 'http://www.mysite.com/sfdc/Contract/types', 'wwwmysiteComsfdcContractTypes', 'http://www.mysite.com/sfdc/Contract/', 'wwwmysiteComsfdcContract', 'http://www.mysite.com/sfdc/Contract/GetContractDetails/types', 'wwwmysiteComsfdcContractGetcontractdet', 'http://www.mysite.com/sfdc/GIL/HeaderDataXMLS', 'wwwmysiteComsfdcGilHeaderdataxmlsCONTRACT', 'http://www.mysite.com/sfdc/Contract/CreateMessage', 'wwwmysiteComsfdcContractCreatemessage' };
public wwwmysiteComsfdcContractTypes.SearchResultType Search_x(String Region, String ContractNumber, String ssnum, String PhoneNumber, String CreditApplicationNumber, String SerialTagNumber, String InvoiceNumber, String mysiteOrderNumber, String ContactName, String TaxIdNumber, String PONumber, String CustomerName, wwwmysiteComsfdcContractTypes.Pagination_element Pagination) {wwwmysiteComsfdcContractTypes.SearchRequestType request_x = new wwwmysiteComsfdcContractTypes.SearchRequestType(); request_x.Region = Region; request_x.ContractNumber = ContractNumber; request_x.ssnum = ssnum; request_x.PhoneNumber = PhoneNumber; request_x.CreditApplicationNumber = CreditApplicationNumber; request_x.SerialTagNumber = SerialTagNumber; request_x.InvoiceNumber = InvoiceNumber; request_x.mysiteOrderNumber = mysiteOrderNumber; request_x.ContactName = ContactName; request_x.TaxIdNumber = TaxIdNumber; request_x.PONumber = PONumber; request_x.CustomerName = CustomerName; request_x.Pagination = Pagination; wwwmysiteComsfdcContractTypes.SearchResultType response_x; Map < String, wwwmysiteComsfdcContractTypes.SearchResultType > response_map_x = new Map < String, wwwmysiteComsfdcContractTypes.SearchResultType > (); response_map_x.put('response_x', response_x); WebServiceCallout.invoke( this, request_x, response_map_x, new String[] { endpoint_x, 'http://www.mysite.com/sfdc/Contract/Search', 'http://www.mysite.com/sfdc/Contract/types', 'SearchRequest', 'http://www.mysite.com/sfdc/Contract/types', 'SearchResponse', 'wwwmysiteComsfdcContractTypes.SearchResultType' }); response_x = response_map_x.get('response_x'); return response_x; } public wwwmysiteComsfdcContractGetcontractdet.GetContractDetailsResponseType GetContractDetails(String Region, String ContractNumber) { wwwmysiteComsfdcContractGetcontractdet.GetContractDetailsRequestType request_x = new wwwmysiteComsfdcContractGetcontractdet.GetContractDetailsRequestType(); request_x.Region = Region; request_x.ContractNumber = ContractNumber; wwwmysiteComsfdcContractGetcontractdet.GetContractDetailsResponseType response_x; Map < String, wwwmysiteComsfdcContractGetcontractdet.GetContractDetailsResponseType > response_map_x = new Map < String, wwwmysiteComsfdcContractGetcontractdet.GetContractDetailsResponseType > (); response_map_x.put('response_x', response_x); WebServiceCallout.invoke( this, request_x, response_map_x, new String[] { endpoint_x, 'http://www.mysite.com/sfdc/Contract/GetContractDetails/types', 'http://www.mysite.com/sfdc/Contract/GetContractDetails/types', 'GetContractDetailsRequest', 'http://www.mysite.com/sfdc/Contract/GetContractDetails/types', 'GetContractDetailsResponse', 'wwwmysiteComsfdcContractGetcontractdet.GetContractDetailsResponseType' }); response_x = response_map_x.get('response_x'); return response_x; } public wwwmysiteComsfdcContractCreatemessage.CreateMessageResponseType CreateMessage(Boolean asynchronous, wwwmysiteComsfdcContractCreatemessage.RegionType Region, wwwmysiteComsfdcContractCreatemessage.CommentsType Comments) { wwwmysiteComsfdcContractCreatemessage.CreateMessageRequestType request_x = new wwwmysiteComsfdcContractCreatemessage.CreateMessageRequestType(); request_x.asynchronous = asynchronous; request_x.Region = Region; request_x.Comments = Comments; wwwmysiteComsfdcContractCreatemessage.CreateMessageResponseType response_x; Map < String, wwwmysiteComsfdcContractCreatemessage.CreateMessageResponseType > response_map_x = new Map < String, wwwmysiteComsfdcContractCreatemessage.CreateMessageResponseType > (); response_map_x.put('response_x', response_x); WebServiceCallout.invoke( this, request_x, response_map_x, new String[] { endpoint_x, 'http://www.mysite.com/sfdc/Contract/CreateMessage/action', 'http://www.mysite.com/sfdc/Contract/CreateMessage', 'CreateMessageRequest', 'http://www.mysite.com/sfdc/Contract/CreateMessage', 'CreateMessageResponse', 'wwwmysiteComsfdcContractCreatemessage.CreateMessageResponseType' }); response_x = response_map_x.get('response_x'); return response_x; } } }
Hi Community,

I am doing Heroku integration workbook and I came across this issue.
When I am doing the #3 tutorial from work book I executed this command 
heroku config:add OAUTH_CLIENT_KEY=PUBLICKEY OAUTH_CLIENT_SECRET=PRIVATEKEY
The miske I made first time is I entered scret key for both private and public.
Later I realised and entered right one but no use, I am already came across the sercer side error.
https://sheltered-savannah-2269.herokuapp.com
Above URL can take you to my heroku app.
Please let me know how can I over come this. I already posted this question stackflow.

Thanks,
Suri
Hi Community,

I am trying to populate  a datetime value from the custom javascript button on a standard pagelayout.
I can populate the check box but datetime field is not getting a value.
any help is appricated.

var UpdateRtProd = new sforce.SObject("RtProd__c");
                        var datTime = '{!NOW()}';

                        HERE THE datTime IS COMMING in the following format 2/05/2015 11:44 AM
 
            UpdateRtProd .Id = RatingProdsRecords[r].Id;
            UpdateRtProd .UWRTR_IND__c = true;
            UpdateRtProd .UWRT_SUBMT_TS__c = datTime ;
            UpdateRtProd .push(update_RatingProduct);
result = sforce.connection.update(UpdateRtProd );
 
HI 

I want to check weather a user belongs to specific group or not.
Here Roles are added as groupMembers, I tried as follows but I did not get them. 

Id groupId = [Select Id from Group where Name like 'Home Support' limit 1].Id;

        // store the results in a set so we don't get duplicates
        Set<Id> result=new Set<Id>();
        set<string> grpResult= new set<string>();
        String userType = Schema.SObjectType.User.getKeyPrefix();
        String groupType = Schema.SObjectType.Group.getKeyPrefix();
        String RoleType = Schema.SObjectType.UserRole.getKeyPrefix();
        system.debug('******userType :'+userType+': groupType :'+groupType+': Role Type :'+RoleType);
        // Loop through all group members in a group
        for (GroupMember m : [Select Id, UserOrGroupId From GroupMember Where GroupId = :groupId])
        {
           /* 
            // If the user or group id is a group
            // Note: there may be a problem with governor limits if this is called too many times
            else */if (((String)m.UserOrGroupId).startsWith(groupType))
            {
                // Call this function again but pass in the group found within this group
                //result.addAll(GetUSerIdsFromGroup(m.UserOrGroupId));
                grpResult.add(m.UserOrGroupId);
            }
        }
    system.debug('************USR Ids:'+result+'group Ids :'+grpResult);
     for (GroupMember m : [Select Id, UserOrGroupId From GroupMember Where GroupId IN: grpResult])
        {
             // If the user or group id is a user
            if (((String)m.UserOrGroupId).startsWith(groupType))
            {
                result.add(m.UserOrGroupId);
            }              
        }
    system.debug('************USR Ids:'+result);

Thanks.
Hello Community,

I had to set Account To NULL when a case is being created by Email to Case future.
Any work around using triggers. Please let me know. 
If this is a impossible thing, point me to the right direction .

Thanks,
Suresh.
<apex: repeat value="{!WrapperList}" var="rec">
<input type="checkbox" id="chkbx"/>
</apex:repeat>
instead of the following code
<apex: repeat value="{!WrapperList}" var="rec">
<apex:inputCheckbox value={!rec.selected}" id="select"/>
</apex:repeat>
Here my question is how can I pass the checkbox values to the wrapper class list.
Hi Communuty,

I want build a table with horizontal and vertical scroll bars which follow the following conditions conditions.

1) when I scroll vertical the headers should be locked and the entire rows can scroll up and down.
2) when I scroll horizontal the first column should be locked and the entire columns with headers can scroll.

Please share your suggestions and links.

Thanks.


Hi Community,

I have a Multi picklist, My reqirement is as follows.

when I select from left options and move them to the right, I should display the the left options as it is and show the selected in right ---------> I amgood with this.

The issue is when I select options from the right and move them to the left issue is over there.

If i click the unselect button even with out pointing a specific element in the right options, bottom most element get removed from the right options. 
Smple code of the unSelect button.
<apex:panelGrid columns="4" id="grid2">              
                   
                    <apex:selectList id="sel3" value="{!leftSelectedRatProds}" multiselect="true" style="width:120px" size="15">
                        <apex:selectOptions value="{!unSelectedRatProductValues}" />
                    </apex:selectList>
       
                        <apex:panelGroup >
       
                            <br/>
                            <apex:image id="rightrat" value="{!$Resource.RightArrowButton}" width="30px" height="30px">
                                <apex:actionSupport event="onclick" action="{!selectRatProduct}" reRender="grid2"/>
                            </apex:image>
       
                            <br/>
                            <apex:image id="leftrat" value="{!$Resource.LeftArrowButton}" width="30px" height="30px" >
                                <apex:actionSupport event="onclick"  action="{!unselectRatProduct}" reRender="grid2"/>
                            </apex:image>
       
                        </apex:panelGroup>
       
                    <apex:selectList id="sel4" value="{!rightSelectedRatProds}" multiselect="true" style="width:120px" size="15">
       
                        <apex:selectOptions value="{!SelectedRatProductValues}"  />
       
                    </apex:selectList>
                   
                </apex:panelGrid>
********************************************
public PageReference unselectRatProduct(){
    
       // leftSelectedRatProds.clear();
     for(Integer i=0;i<=rightSelectedRatProds.size(); i++){
      if(rightRatProds != null && rightRatProds.size()>0){
     rightRatProds.remove(i);
      }
   }
         
        for(String s : rightSelectedRatProds){  
         //rightRatProds.remove(s);
         leftRatProds.add(s);
        }
      
        return null;   
    }

Please share some idea or suggest the code changes in the above given method or vf script.
Thanks,

<apex:pageBlockSectionItem >
            <apex:outputLabel value="Product Group" for="prodgroup"/>
            <apex:selectList id="prodgroup" value="{!selectedProductGroup}" size="1" title="ProductGroup">
               <apex:selectOptions value="{!productGroupOptions}"></apex:selectOptions>
            </apex:selectList>
        </apex:pageBlockSectionItem>

public string selectedProductGroup{get;set;}
public List<selectOption> getProductGroupOptions() {
        List<selectOption> options = new List<selectOption>();
        //options.add(new selectOption('', '- None -'));
        for (Product_List__c ProdGroup : [Select Id, Name from Product_List__c]) {
            options.add(new selectOption(ProdGroup .name, ProdGroup .Name));
        }
        options.sort();
        return options; //return the picklist options
    }
so far it is fine. I am gettiing values in the Picklist .
But the issue is When I want to use the selected picklist value and show another picklist values.
I noticed I am not getting a value into selectedProductGroup of the picklist.

Can some one correct me where I am making wrong.
Hi Community,

I have a requirtement where one opportunity should have only one case of one record type.

I tried to achieve this usinig a trigger by showing an error message, but I ran into a issue when the case record with same record type is adding from the opportunity with a javascript button. It is hitting this error but not showing and navigating to the home page.

Any Ideas please.

Thanks.
Hi Community,

When I am saving the records on  VF Page it is hitting Too Many Soql quries:101 Exception on {!saveRecords}.

I can see this error in all the browsers except IE. In IE loading symbol is continously running where as in other browsers it is breaking and howing the above said error.
But I had to catch this error and show in the page messages.

I tried in the Try catch block and failed.
When I walk thru the debug logs I noticed the control is going to the case object and hitting the Too Many Soql queries error and not going in to the Try catch block.

So please share your ideas, code snippets.

Thanks.
Hi Community,

I came across the following the situation.

I created an opportunity for the test data and I updated the stage of the opportunity. Expected a value to be changed on the other object.
Sample of my code is as follows.

My issue is in Bold letters. The old map is picking the updated value. where i need to compare old value with new value. but after update the old Map is also takinig new value.
What I am doing wrong.

@isTest
private class opporutnityBusinessLogicTest{

static testmethod void mytestmethod1(){
  Ilist<Account> lstAccount = new list<Account>();
            list<Opportunity> lstOpportunity = new  list<Opportunity>();
            list<PP_OPRTY_PRODT__c> lstOpportunityProd =new list<PP_OPRTY_PRODT__c>();
          
            final string BrokerRecType='Customer';
            schema.describesobjectresult r=account.sobjecttype.getdescribe();
            map<string,schema.recordtypeinfo> m=r.getrecordtypeinfosbyname();
            id brkerRecType= m.get(BrokerRecType).getrecordtypeid();
          
             Integer intNoOfRecord=1;
            for(integer i=0; i < intNoOfRecord; i++){
                account a=new account(Name='Test Customer Account'+i,Broker_Id__c='B99999'+i,PP_ID__c='99999BROKER'+i,Start_Date__c=date.today(),End_Date__c=date.today()+5,recordtypeId=brkerRecType);
                lstAccount.add(a);                
            }
            insert lstAccount;
          
            for(integer i=0;i< intNoOfRecord;i++){
                 Opportunity a=new Opportunity
                                            (CloseDate=date.ValueOf('2015-04-28'),Name='Test Opty ' + i
                                               ,StageName='Lead', Strategy__c='Life Insurance'
                                               ,Sub_Type__c='New', AccountId = lstAccount[0].Id
                                               ,Type='New'                                             
                                            );
                lstOpportunity.add(a);    
            }
            insert lstOpportunity;
          
            for(integer i=0;i< intNoOfRecord;i++){
                PP_OPRTY_PRODT__c oppProd = new PP_OPRTY_PRODT__c(Name='Dental'+i
                                                                        , PRODT_STAGE_NM__c ='Lead'
                                                                        , OPRTY_ID__c=lstOpportunity[0].Id);
                lstOpportunityProd.add(oppProd);
            }
            insert lstOpportunityProd;
                               
            List<Opportunity> opt= [Select id, StageName from Opportunity where Id =:lstOpportunity[0].Id];
         
                              
            List<Opportunity> updateOpp = new List<Opportunity>();
                    
            test.startTest();
            Opportunity oppRecord;
            Id oppRecId;
            for(Opportunity oppRec : opt){
                 oppRecId=oppRec.id;
                 oppRecord=oppRec;
            }
            map<Id,Opportunity> oldMap=new map<Id,Opportunity>();        
            oppMap.put(oppRecId,oppRecord);
             system.debug('*************  Opty Map: '+oldMap);
                 
             if(opt != null){                          
                 for(Opportunity op:opt){                                                      
                     op.StageName = 'Closed Deferred';
                     updateOpp.add(op);                    
                 }              
                update updateOpp;
              
             }
             system.debug('*************  Opty Map: '+oldMap);         
             OpportunityArchitectureBusinessLogic.updateOpportunityProduct(updateOpp, oldMap);
           
            test.stopTest();
}
}
hi Community,

I am populating a hyper link from the formula filed to the vf page and i need to show the font of the hyper link bold on the vfpage.

HYPERLINK(Id,"textto dispaly",_parent);

in ouputText tag it will be diapslyed.

Any thoughts how to show this in a bold font.
I can not make it bold on vfpage because the ouputtext tag will also prinnt many other messages which should no be bold.

Thanks,
suree.

Hi Community,

I am navigating from one vf page to another vfpage and passing parametrs through URL and trying to capture the parameters in the other controller.

My Url looks like this.
https://c.cs16.visual.force.com/apex/AgreementAdvanceFilterPage?AccountId=001f000000H0HGAAA3

I used the following methods
string str = ApexPages.currentPage().getUrl() ;
string accountId = ApexPages.currentPage().getParameters().get('AccountId');

Above both did not work for the above said scenario.

What is the issue and how can i over come it.
Please share your thoughts and ideas.

Thanks,
Suree 
Hi Community,

Below is the sample code
List<User> salesOffice = [Select id, Sales_Office__c, profile.Name from User  where Sales_Office__c != null];

for(User usr: salesOffice){

this.pickList.add(new salesOffice(usr.Sales_Office__c, usr.Sales_Office__c));

}
From the above process I am getting the duplicate values in the picklist and displaying in the alphabetical order. 

Any Ideas please.

Thanks,
Suresh.

Hi Community,

I have a need to create a multiselect picklist on vfpage which gets values by soql query.

I have one in handy with static values, is there any way I can make this get populated by soql. 
I tried but run into errors.

Please share your ideas and comments.
here is the one which i have working.
http://sfdc2u.blogspot.com/2013/05/custom-multi-select-picklist-field-in.html
Hi Comminity,

I have a requirement where i had to show different fields from 3 different objects into a single pageblock table with checkbox select option. so I am using a wrapper class. My code is below. Can any correct me where I am making the mistake.

public List<AccountTeamWrapper> getAgreementList(){
        if(AgreementList == null){
            agreementList = new List<AccountTeamWrapper>();
           for(Agreement__c agr:[select Id, name, Administrative_Source_System__c from Agreement__c where Customer__c=: accountId]){
                agreementList.add(new AccountTeamWrapper(agr, null));           
           }
List<Agreement_Rep__c> aggRepList = [select Id, Name, Agreement__r.Id, Agreement__r.Name, Agreement__r.Administrative_Source_System__c, REP_AGRMT_BEGIN_DT__c,  REP_AGRMT_END_DT__c
                                                    from Agreement_Rep__c where Agreement__r.Customer__c =: accountId];
            system.debug('************* Agreement size:'+aggRepList.size());
            system.debug('************* Agreement :'+aggRepList);                                                   
            for(Agreement_Rep__c aggRep: aggRepList){
                //aggIds.add(aggRep.Agreement__r.Id);
                agreementList.add(new AccountTeamWrapper(null, aggRep));
            }
return agreementList;
        }
        return null;
    }
public class AccountTeamWrapper{       
        public Agreement__c agreement{get;set;}
        public Agreement_Rep__c agreementRep{get;set;}       
        public Boolean selected{get;set;}       
       
        public AccountTeamWrapper(Agreement__c agr, Agreement_Rep__c aggRep){
            agreement = agr;
            agreementRep = aggRep;
            selected = false;
        }       
    }
}
Hi Community,

Can any body say me where I am making the mistake. onclcik is working upto closing the popup. but the alert is not showing up.

<apex:commandLink onclick="closePopup();alert(ok);" onmouseover="openPopup('{!ag.agreement.Id}');" onmouseout="closePopup();"> {!ag.agreement.Name}</apex:commandLink>

thanks,
Suree
Hi Community,

I wrote a vf page to display the list of records.
When i do onmouse over on the name of a record which is acting like hyperlink I am getting a popup. 
so far good. 
But I am not able to capture the id of the record on which i do mouse over.
I used apexPages.CurrentPage().getParameters().get('AgrI');
But no use can any body share yours thoughts to capture id of the record on which i do mouse over.

Thanks,
Suree
hi Community,

I am populating a hyper link from the formula filed to the vf page and i need to show the font of the hyper link bold on the vfpage.

HYPERLINK(Id,"textto dispaly",_parent);

in ouputText tag it will be diapslyed.

Any thoughts how to show this in a bold font.
I can not make it bold on vfpage because the ouputtext tag will also prinnt many other messages which should no be bold.

Thanks,
suree.

Hi

 

I am new to the Visualforce

 

I want to populate a picklist called Security_Question__C which is a field on the MyContact__c custom object.

 

 

I tried different way , but it is not working could any body suggest me a solutution with code.

 

I created a lightning component to override the standard "new" opportunity. The problem is that when I implement the force:hasRecordId interface, the recordId shows in my debugger as "undefined". I need to use the current id of the account or contact to pre-populate fields in my component. How can I do this?

Here is the documentation I found, which seems to explain that recordId is undefined in my situation.

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_interfaces_force_hasrecordid.htm

The recordId attribute is set only when you place or invoke the component in an explicit record context. For example, when you place the component directly on a record page layout, or invoke it as an object-specific action from a record page or object home. In all other cases, such as when you invoke the component as a global action, or create the component programmatically inside another component, recordIdisn’t set, and your component shouldn’t depend on it.
These unsupported contexts include a few contexts that might seem like they should have access to the current record. Examples of these other contexts include the following:
Invoking the component from a global action (even when you’re on a record page)
Invoking the component from header or footer navigation in a community (even if the page shows a record)
force:hasRecordId and force:hasSObjectName are unsupported in these contexts. While the marker interfaces still add the relevant attribute to the component, accessing either attribute generally returns null or undefined.

Thanks for helping.
Hi All,

I'm having trouble testing a trigger I have for my Opportunity objects.

I have a custom object 'QQ' which is in a master-detail relationship with my Opportunity, and whenever the 'Total' field in the QQ is changed, this rolled up to my Opportunity, which then updates the Opportunity Probability via the trigger.

The problem I'm having is inserting a QQ in my test class. Each time I run the test, I get the following error: 
System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Opportunity__c]: [Opportunity__c]

My test class code is the following:

@isTest
public class TestUpdateProbTrigger {
    static testMethod void insertNewOpp() {
        
       account acct = new account(Name = 'testing');
       insert acct;
       
       Opportunity o = new Opportunity(
               Name = 'testing',
               AccountId = acct.id,
               CloseDate = System.today(),
            StageName = 'Warm Prospect'
       );
        
       QQ__c q = new QQ__c (
            Name = 'test'
            S1_x__c = true,    //these 4 fields can be ignored
            L1_x__c = true,    
            C1_x__c = true,
            Q1_x__c = true,
            Opportunity__r = o,      
            Opportunity__c = o.Id     //here I provided the Opportunity__c field for the QQ object, and yet I still get that error
       );
         
       o.QQ__c = q.Id;   
        
        insert o;
        insert q;
        
        q.D1_x__c = true;
        update q;
        
        System.assertEquals('Qualify', o.StageName);    //this is just to verify that the stage name changed correctly
    }
}
 
There is also a lookup relationship between the QQ and the Opportunity, though I doubt that is relevant to this. Does anyone have any suggestions? Thanks in advance!

Best,
Jeff
 
  • February 20, 2015
  • Like
  • 0
Hi All,

I have an Object X__c which is having related list R__c. R__c has two fields F1, F2. I need to query these fields and update the field values in X__c s1, s2 field.

Need help.

Regards
Hi Community,

I am doing Heroku integration workbook and I came across this issue.
When I am doing the #3 tutorial from work book I executed this command 
heroku config:add OAUTH_CLIENT_KEY=PUBLICKEY OAUTH_CLIENT_SECRET=PRIVATEKEY
The miske I made first time is I entered scret key for both private and public.
Later I realised and entered right one but no use, I am already came across the sercer side error.
https://sheltered-savannah-2269.herokuapp.com
Above URL can take you to my heroku app.
Please let me know how can I over come this. I already posted this question stackflow.

Thanks,
Suri
Hi All

I have one question, In my Production there is an connected app and I have Secret and consumer Key for that Application to access production environment of salesforce, but in sandbox I dont have any connected apps still that 3rd party application was able to access the sandbox environment.

so my question is the consumer and secret key are not unique with respect to orgs?
using production consumer and secret key will they access all the sandboxs?

please clarify!

Thanks in Advance!!!
 
Here is the fomula that I have now. I'm trying to include multiple profile names in the formula so the validation rule error will appear for all profiles. I've gotten it to work if I just have one profile name listed, but I need to account for all the profile names in my example formula below.

IF(AND($Profile.Name == "Field Sales - MD 7132010 - Comm AE,Field Sales - MD 7132010,Field Sales - Higher Ed,Field Sales - Commercial East,Inside Sales", BMXQ__Proposal_Template__r.Name == "LEGAL 1. Order Form: New Customer"),true,false)

Thanks,
 
Hi,

I tried to find the max value of some different value. Late I will replace the numbers with variables.
MaxValue = Math.max (1,4,5,2,10);
Compile Error: Method does not exist or incorrect signature: Math.max(Integer, Integer, Integer, Integer, Integer)

Could you help me please.

Thanks,
Sascha
I would like assistance in developing a formula for either a field or to place in a workflow to update a field for the following criteria:

Account 'Status' field changes to 'Alumni'

Field to update: Graduation Date (formula will automatically populate this on the date of the above field change)
I am creating an HTML email template and some of the merge fields I want to use are URL's.
I would like to turn those URL's into something that is easier to read (right now the email comes over with these long URLs)

i.e. In our approval process an automated email gets sent to a SVP and it shows up in their inbox with a
Click Here to review: https://na3.salesforce.com/p/process/ProcessInstanceWorkitemWizardStageManager?id=04i500000039egG
The problem is that that URL always changes because they are for different approvals so I cant write
<a href="https://na3.salesforce.com/p/process/ProcessInstanceWorkitemWizardStageManager?id=04i500000039egG">Click here to review</a>

Any ideas how I would turn these merge fields into a clickable text field??
Here is one of the URL fields {!ApprovalRequest.External_URL} 
  • December 09, 2014
  • Like
  • 0
I am new to triggers and I'm working on a trigger that will

1.       On new Project create,
2.       No other criteria
Actions:
1.       Follow the Account lookup field on the Project to update the Account.“Most Recent Project” lookup field with the new project
2.       Follow the Wind Energy Site lookup to update the Account. “Most Recent Project” lookup field with the new project

I havnen't had any luck. In what ways can this be accomplished?

Thank you in advance! 
Wayne
@isTest(SeeAllData=false)
private class OrderProductComponentController_sindtest {
   public static NA_Order__c orderTest;
   public static Account accTest;
 
  static testMethod void testWithProduct() {
    initalize();

    OrderProductComponentController_sind controller = new OrderProductComponentController_sind();

    Test.startTest();

      Map<String, Set<String>> cropVarietyMap = controller.cropVarietyMap;
      controller.queryTECP();
      Map<String, Map<String, Map<String, Set<String>>>> TECPMapofMapTest = controller.TECPMapofMap;
      NA_Order_Line_Item__c orderLineTest = controller.orderLine;
      List<SelectOption> cropOptionsTest = controller.cropOptions;
      List<SelectOption> varietyOptionsTest = controller.varietyOptions;
      List<SelectOption> treatmentOptionsTest = controller.treatmentOptions;
      List<SelectOption> enhancementOptionsTest = controller.enhancementOptions;
      List<SelectOption> carrierOptionsTest = controller.carrierOptions;
      List<SelectOption> packagingOptionsTest = controller.packagingOptions;
      String cropTest = controller.crop;
      String varietyTest = controller.variety;
      controller.validateQuantity();

    Test.stopTest();
  }
   public static void initalize() {
    accTest = TestUtils.createAccount('AccForTestingOrderProductPicker', 'USD', true);
    orderTest = TestUtils.createOrder('Spot Order', Date.today(), 'UPS', 'OrderForTestingOrderProductPicker', 'Created', accTest.Id, true);

    PageReference orderProductPicker = Page.Order;
    orderProductPicker.getParameters().put('Id', orderTest.Id);

    Test.setCurrentPage(orderProductPicker);
  }
}
I have 8 visualforce pages that all contain a relatively simple extended APEX controller handing things like save, pagereferences and SOQL to derive fields from a parent object. This is my first unit testing exercise. Do I just need to test each extended controller ? All of the controllers are very similar to function just extending different standard controllers. Also, the visualforce pages rely on upper level objects Account | Audt (custom object.) the first visualforce page (Sample Policy - custom object) is created from the 'Audit' (custom object .) Subsequent visualforce pages are created as related list children of the Sample Policy object. SOQl queries are used to pull in fields from the grandparent (Audit) object for rendering control.  

Also, would appreciate any suggestions on how to best test the SOQL response for null or more than 1 resulting record.

Below is a sample.  Would appreciate any guidance. Thanks.

 
public with sharing class ParentChildExtensionDRIVERsample_New {

/*

FUNCTION:
Receives parent ID (accID) aandd Sample ID passed via commandbutton or custom button on parent related list.
AccId must be passed via URL since we are instantiating a new object reccord which is not saved.
accID is needed to query parent fields that are used on the visualforce page for rendering.
SampleId is needed to load the related field on the object. 
A list object is used for the SOQL query to the parent. The result set is used in the visualforce page for setting control variables for rendering. 
The Sample ID is loaded into the related list field on the instanitated object to establish relationship when saved. 
*/

public Audit__c driver{get;set;}
Auto_Drivers__c record;
private ApexPages.StandardController controller;

String accId;
String sampleId;

public ParentChildExtensionDRIVERsample_New(ApexPages.StandardController standardController)
{
 this.controller = standardController;
//set sample to current record.
this.record = (Auto_Drivers__c)standardController.getrecord();

accID=ApexPages.currentPage().getParameters().get('AccId');
sampleID=ApexPages.currentPage().getParameters().get('sampleId');

List< Audit__c> drivers = [ select Id, Driver_Information__c, Age__c, Gender__c, Marital_Status__c, Named_Insured_Add_Driver__c, Occupation__c, Business_Use__c                
           from Audit__c where Id = :ApexPages.currentPage().getParameters().get('accId')]; 
If (drivers.isEmpty() == false) driver = drivers[0];

//Load the parent Name (ID) into the Audit field for newly instantiated object record. 
record.Auto_Audit_Sample_Policy__c = ApexPages.currentPage().getParameters().get('sampleId');
} 
//return user back to the audit sample to add new record.
public PageReference saveAndReturn()
    {
     controller.save(); 
     PageReference pr = Page.PROD_Audit_Auto_PolicySample_Open;
     pr.getParameters().put('id', sampleId);
     pr.setRedirect(true);
     return pr;
    }
}


 
Hello,
I have an output field in a VF page. When the page is loaded, if the output field is empty, then javascript must output a text value of "Anonymous". I can get the output to generate when the page is loaded, but it is not considering whether the output field is null or not. I tried using ".value" at the end of var x, but it doesn't work. Any help? Thanks

<apex:outputfield id="first" value="{!c.FirstName__c}"/>
           
            <output id="firstname"></output>

<script>
 
  var x = document.getElementById('{!$Component.first}');
 
window.onload = function(){
     
if ( x !== undefined ) {
   document.getElementById('firstname').value="Anonymous";
     
}
   }
</script>
Hello Community,

I had to set Account To NULL when a case is being created by Email to Case future.
Any work around using triggers. Please let me know. 
If this is a impossible thing, point me to the right direction .

Thanks,
Suresh.
Hello,

When I attempt to save any changes to any Apex class from the Developer Console in a Sandbox instance, I get this error:

CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY: Failed to create deployment: entity type cannot be inserted: Container Async Request
User-added image

Does anyone know what's going on?
I created a lightning component to override the standard "new" opportunity. The problem is that when I implement the force:hasRecordId interface, the recordId shows in my debugger as "undefined". I need to use the current id of the account or contact to pre-populate fields in my component. How can I do this?

Here is the documentation I found, which seems to explain that recordId is undefined in my situation.

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_interfaces_force_hasrecordid.htm

The recordId attribute is set only when you place or invoke the component in an explicit record context. For example, when you place the component directly on a record page layout, or invoke it as an object-specific action from a record page or object home. In all other cases, such as when you invoke the component as a global action, or create the component programmatically inside another component, recordIdisn’t set, and your component shouldn’t depend on it.
These unsupported contexts include a few contexts that might seem like they should have access to the current record. Examples of these other contexts include the following:
Invoking the component from a global action (even when you’re on a record page)
Invoking the component from header or footer navigation in a community (even if the page shows a record)
force:hasRecordId and force:hasSObjectName are unsupported in these contexts. While the marker interfaces still add the relevant attribute to the component, accessing either attribute generally returns null or undefined.

Thanks for helping.
hello Team ,
can yhou please tell me when do we use Aura :handler in lightning , what is the purpose , in what cirucmstanses we use it ??
Here is the fomula that I have now. I'm trying to include multiple profile names in the formula so the validation rule error will appear for all profiles. I've gotten it to work if I just have one profile name listed, but I need to account for all the profile names in my example formula below.

IF(AND($Profile.Name == "Field Sales - MD 7132010 - Comm AE,Field Sales - MD 7132010,Field Sales - Higher Ed,Field Sales - Commercial East,Inside Sales", BMXQ__Proposal_Template__r.Name == "LEGAL 1. Order Form: New Customer"),true,false)

Thanks,