• sunny kapoor
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 7
    Replies

How can I call a vf page by clicking on a image?

I have to write a test class for a trigger which includes aggregate functions like SUM,is there any specific method to proceed?

I have created a lookup field in a page with standard controller.

 

Now i want to filter the result of lookup,how can i do this?

 

 

Can we integrate windchill with salesforce?

How can I call a vf page by clicking on a image?

I have created a lookup field in a page with standard controller.

 

Now i want to filter the result of lookup,how can i do this?

 

 

Hello everyone,

 

We are trying to use the new API Salesforce made available during Winter '13: Test.setMock.

We followed the documentation, but encountered the following issue that we were unable to resolve: a System.CalloutException, complaining that we had "uncommitted work pending".

 

Of course we do, our testmethod starts by setting up some Test Data that's necessary for the test to work, and that includes inserting and updating data.

In an actual execution, there would be no data creation, as the data would already be present. Actually doing the callout doesn't raise the Uncomitted work pending exception, so the Test Data really is at fault.

 

We did use Test.startTest() and Test.stopTest() to differentiate Test Data creation from Test Execution but this (as expected) didn't work.

We also tried some hacks, including the System.runAs(new User( Id = UserInfo.getUserId()){} that had, in the past, allowed us to circumvent "Mixed DML operations". This didn't work either.

 

We considered using the Test.loadData method, but we're inserting related objects and couldn't figure out a clean enough way to make it work (maybe we should try using ExternalID's?).

 

 

For the moment, our workaround is to modify the class generated from the WSDL, adding a if (Test.isRunningTest()) {} else {}, but that means we have to modify the autogenerated code, which is suboptimal.

 

 

Did anyone try to use this new API and run into the same issue? How did you solve it?

hi

To create a lookup filter for to display only parent accounts its child inlookup relation of specfic account in salesforce .......

thanks in advances

 

  • May 03, 2012
  • Like
  • 0

I am new to test writing test methods and was hoping I could figure this one out on my own, but at some point I have to give in! I am getting 48% coverage on this controller. It is based on the dynamic search page provided by Jeff Douglas (http://blog.jeffdouglas.com/2010/07/13/building-a-dynamic-search-page-in-visualforce/). For now I have  place the test method in the controller. Here is the controller with test method:

 

 

public with sharing class ProductSearchController {
 
  // the soql without the order and limit
  private String soql {get;set;}
  // the collection of products to display
  public List<NRProducts__c> products {get;set;}
 
  // the current sort direction. defaults to asc
  public String sortDir {
    get  { if (sortDir == null) {  sortDir = 'asc'; } return sortDir;  }
    set;
  }
 
  // the current field to sort by. defaults to NRCode
  public String sortField {
    get  { if (sortField == null) {sortField = 'name'; } return sortField;  }
    set;
  }
 
  // format the soql for display on the visualforce page
  public String debugSoql {
    get { return soql + ' order by ' + sortField + ' ' + sortDir + ' limit 200'; }
    set;
  }
 
  // init the controller and display some sample data when the page loads
  public ProductSearchController() {
    soql = 'select Name, FBA_Total_Value__c, Total_Qty_Purchased__c,  Create_PO__c, isFBA__c, Vendors__c, VendorID__c, Total_Sold__c, FBA_Inventory__c, Open_Qty__c, Total_Qty__c, Inventory_Burn__c, FBA_Turn__c,   Reorder_Point__c, Reorder__c, Reorder_Amount__c, Reorder_Cost__c  from NRProducts__c where isFBA__c = True';
    runQuery();
  }
 
  // toggles the sorting of query from asc<-->desc
  public void toggleSort() {
    // simply toggle the direction
    sortDir = sortDir.equals('asc') ? 'desc' : 'asc';
    // run the query again
    runQuery();
  }
 
  // runs the actual query
  public void runQuery() {
 
    try {
      products = Database.query(soql + ' order by ' + sortField + ' ' + sortDir + ' limit 200');
    } catch (Exception e) {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'));
    }
 
  }
 
  // runs the search with parameters passed via Javascript
  public PageReference runSearch() {
    

    String name = Apexpages.currentPage().getParameters().get('name');
    String lastSold = Apexpages.currentPage().getParameters().get('lastSold');
    String vendors_id = Apexpages.currentPage().getParameters().get('vendors_id');
    String fbaInventory = Apexpages.currentPage().getParameters().get('fbaInventory');
    String openQty = Apexpages.currentPage().getParameters().get('openQty');
    String totalQty = Apexpages.currentPage().getParameters().get('totalQty');
    String inventoryBurn = Apexpages.currentPage().getParameters().get('inventoryBurn');
    String fbaTurn = Apexpages.currentPage().getParameters().get('fbaTurn');
    String reorderPoint = Apexpages.currentPage().getParameters().get('reorderPoint');
    String reorder = Apexpages.currentPage().getParameters().get('reorder');
    String reorderAmount = Apexpages.currentPage().getParameters().get('reorderAmount');
    String reorderCost = Apexpages.currentPage().getParameters().get('reorderCost');    
                      

 
    soql = 'select Name, isFBA__c, Total_Qty_Purchased__c, FBA_Total_Value__c, Create_PO__c, Vendors__c, VendorID__c, Total_Sold__c, FBA_Inventory__c, Open_Qty__c, Total_Qty__c, Inventory_Burn__c, FBA_Turn__c,   Reorder_Point__c, Reorder__c, Reorder_Amount__c, Reorder_Cost__c  from NRProducts__c where isFBA__c = True';

    if (!name.equals(''))
      soql += ' and name LIKE \''+String.escapeSingleQuotes(name)+'%\'';
    if (!vendors_id.equals(''))
          soql += ' and VendorID__c LIKE \''+String.escapeSingleQuotes(vendors_id)+'%\'';
   if (!lastSold.equals(''))
      soql += ' and Total_Sold__c >= '+lastSold+'';
         if (!fbaInventory.equals(''))
      soql += ' and FBA_Inventory__c >= '+fbaInventory+'';
         if (!openQty.equals(''))
      soql += ' and Open_Qty__c >= '+openQty+'';     
         if (!totalQty.equals(''))
      soql += ' and Total_Qty__c >= '+totalQty+'';     
         if (!inventoryBurn.equals(''))
      soql += ' and Inventory_Burn__c >= '+inventoryBurn+'';      
         if (!fbaTurn.equals(''))
      soql += ' and FBA_Turn__c >= '+fbaTurn+'';      
         if (!reorderPoint.equals(''))
      soql += ' and Reorder_Point__c >= '+reorderPoint+'';      
          if (!reorder.equals(''))
          soql += ' and Reorder__c LIKE \''+String.escapeSingleQuotes(reorder)+'%\'';       
         if (!reorderAmount.equals(''))
      soql += ' and Reorder_Amount__c >= '+reorderAmount+'';      
          if (!reorderCost.equals(''))
      soql += ' and Reorder_Cost__c >= '+reorderCost+'';
    // run the query again
    runQuery();
 
    return null;

}

    ///////////////////////////////////////////////
    // 
    // Unit Tests
    //
    ///////////////////////////////////////////////
    
    public static testMethod void testController()
    {

        
        // instantiate the controller
        ProductSearchController ctrl=new ProductSearchController();

       // instantiate the controller
        //ctrl.runSearch();
        System.assert(ctrl.runSearch() == null);

    }
}

 I have color coded based on what the testing shows. Blue = coverage, Red = no coverage.

 

Thank you for your help!

 

 

 

 

  • May 24, 2011
  • Like
  • 0