• bprakash
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 43
    Replies

How can i get the difference of two sets?

Set<Id> A,Set<Id>B

 

i need to find difference between A & B

 

PLease suggest on this

 

Thanks

Hi 

Iam trying to find number of assets on account with some coditions

i had used aggregate funtion,its not giving the correct results.Please i need help on this,waiting for the reply

  AggregateResult[] groupedResults1 =([SELECT AccountId,COUNT(ID)ct FROM Asset where accountid in:contId AND Status != 'Returned' AND Type__c !='Converted'  group by AccountID,Status,Type__c]);

MPS 00:E0:81:C2:DA:55 [days] [r]

 

this is the string i want the first space length so that i can use in my apex code.This all iam doing in a class,i had find a function on fromula fields but it has no use in apex.

can any tell me how to find first space in a string(means position of space in string)

Thanks

Bhanu

I have an account and it has 10 assets,i have a formula field number called support,in apex i want to sort it out so that i can get the max number value on support.

It says that formula fields are decimal so i had given list type as decimal and i sorted that,what i found in the debug log is 0,0,0,0...

I had cleared that one in the loop,Please help me out...

Thanks

Bhanu

can anyone please tell how the test class for pricebook is defined?

i am some kind of trouble with the test code

 Pricebook2 standardPB = [select name, isactive from Pricebook2 where IsStandard = true limit 1];
          


         // Pricebook2 standardPB = new Pricebook2(Name = 'Standard Price Book 2009', Description = 'Price Book 2009 Products', IsActive = true,isStandard=true);  (SHOWING ERROR HERE error here no lists found)


         // insert standardPB;
        Pricebook2 pb = new Pricebook2(Name = 'Standard Price Book 2009', Description = 'Price Book 2009 Products', IsActive = true);
        insert pb;
        Product2 prod = new Product2(Name = 'Anti-infectives 2007', Family = 'Best Practices', IsActive = true);
        insert prod;

        PricebookEntry standardPrice = new PricebookEntry(Pricebook2Id = standardPB.Id, Product2Id = prod.Id, UnitPrice = 10000, IsActive = true, UseStandardPrice = false);
        insert standardPrice;

        PricebookEntry pbe = new PricebookEntry(Pricebook2Id = pb.Id, Product2Id = prod.Id, UnitPrice = 10000, IsActive = true, UseStandardPrice = false);
        insert pbe;

 

 

Can someone please expalin me how to overcome this.

Please tell me how to make this working?

I'm writing a unit test on the opportunity and opportunity line item.  I am getting the error "No standard price is defined".

 

Here is my test method:

 

public static testMethod void test3() 
    { 
    	Pricebook2 pb = new Pricebook2(Name = 'Standard Price Book 2009', Description = 'Price Book 2009 Products', IsActive = true);
    	insert pb;
    	Product2 prod = new Product2(Name = 'Anti-infectives 2007', Family = 'Best Practices', Practice__c = 'GP/BP', Service_Level__c = 'Partial Service', Product_Abbrev__c = 'CMR_Antiinfect', Sales_Unit__c = 'Each', Standard_Unit__c = 'Each', Product_Year__c = '07', Item_Type__c = 'Non-Inventory (Sales only)', IsActive = true);
    	insert prod;
    	PricebookEntry pbe = new PricebookEntry(Pricebook2Id = pb.Id, Product2Id = prod.Id, UnitPrice = 10000, IsActive = true, UseStandardPrice = false);
    	insert pbe;
    	Opportunity opp = new Opportunity(Name = 'Test Syndicated 2010', Type = 'Syndicated - New', StageName = 'Planning', CloseDate = system.today());
    	insert opp;
    	OpportunityLineItem oli = new OpportunityLineItem(opportunityId = opp.Id, pricebookentryId = pbe.Id, Quantity = 1, UnitPrice = 7500, Description = '2007 CMR #4 - Anti-Infectives');
    	insert oli;
		List<OpportunityLineItem> olis = [Select Id From OpportunityLineItem Where OpportunityId =: opp.Id];
		update olis[0];
    }

 

The error is thrown on the line where I try and insert the PricebookEntry record:

 

PricebookEntry pbe = new PricebookEntry(Pricebook2Id = pb.Id, Product2Id = prod.Id, UnitPrice = 10000, IsActive = true, UseStandardPrice = false);
    	insert pbe;

 

I'm not sure what I'm missing. 

 

Thanks for any help.

Regards.

 

I have a query

public Pricebook2 getPricebook2()
{
Opportunity opp_info = getOpportunity();
Pricebook2 pricebook_info = [select Id, P.Name, P.IsActive, P.Description from Pricebook2 P
where P.id = : opp_info.Pricebook2Id];
return pricebook_info;

 

How would I test this in my test class?

 

This is what I have in my test class

 

Pricebook2 pb_info = new Pricebook2 (name='testbook',description='asdsdfsf', IsActive=true);
insert pb_info;
controller.getPricebook2();

 where controller is an object of the visualforce controller I'm trying to test.

 

But I get an error message that says

 

 

Class.myOpportunityController.getPricebook2: line 40, column 37 Class.myOpportunityTestClass.myControllerTest: line 67, column 10 System.QueryException: List has no rows for assignment to SObject

 

 

 

 

 

 

Message Edited by teknicsand on 04-02-2009 04:03 AM
I want to convert DateTime Value to Date Value , Please help me out ????????????