• Ryanh
  • NEWBIE
  • 30 Points
  • Member since 2009

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 12
    Replies
Can anybody please tell me wether we can capture signature in visualforce page.
Anyone know how to filter out the meta data xml files from the file list? I see a "*-meta.xml" file for each tigger, class, page, etc I've imported to the IDE... kinda annoying.

I know I'm missing something but why can't I create a custom controller?

 

<apex:page controller="MyController" > 
<apex:pageBlock title="Contacts">
</apex:pageBlock>
</apex:page>

 

In the tutorial is says if I put that code in a Page and hit save, I'll have a Controller option available but I don't.  I get an error message "Error: Apex class 'MyController' does not exist."  What am I missing here?

 

I'm on SalesForce Pro if that makes a difference.

 

Thanks

Hi,

 

I've been advised this is the best place to post this...

 

I've installed Quote Line Items (Version 0.7) from Appexchange and want to edit the page "Quote PDF" so that it looks similar to our existing quote template as we're looking to run our quote process through Salesforce.com.  The application is great and I've been given the go ahead to roll it out to everyone as long as the quote PDF can look more like our original version.  This is where I'm falling down - I've managed to add our logo to the template instead of the standard Visualforce one but can't get my head around adding a table and some standard text to the template. I know it's only a simple template and if it was HTML I'd be able to do it but I just can't figure out Visualforce.

 

Can anybody help with this at all please?  E.g. does anyone have a standard table I can copy & paste and then edit?  If I identify which fields need to be included, could someone guide me through how to enter them in to the table?  Is there a way of adding a standard header & footer to the page?

 

Thanks,

Cherie

If I want a method in Apex controller to return to the prior page, what should I return for the page reference?

 

I would assume I can return a URL with the id that was passed in but that would open a new instance of a page.  I'd rather just go back.

 

Hi All

 

I have a before update trigger on a object. I am getting a list of all records matching a particular id (trigger.old) and looping through the list .

 

The problem is while looping thorugh if a particualr check box is checked I want to uncheck it. So I do that add it to another list and do a update and run into the recursive update issue .

 

 I am stuck. This is the offending code in the class which is called by the before update trigger

 

 

public static void beforeUpdate(List<Contact__c> ContactList){ i Set<Id> accountIds = new Set<Id> (); for (Contact__c con: ContactList){ if (con.account__c!=null) accountIds.add(con. account__c); } List< Contact__c > updateContacts = new List< Contact__c >(); List< Contact__c > ExistingContactList = ([Select Id, e.Name,active__c from Contact__c e where e.account__c.Id in : accountIds order by name desc]); for(Contact__c contactcounter : ExistingContactList ){ if (contactcounter .active__c == true){ contactcounter .active__c = false; updateContacts.add(contactcounter ); } }//for loop //update updateContacts; }

 

 

 

 When I execute this I get the recursive error as I am callin the update updateocntacts inside a before update trigger. But I want to change the value of all contact records active value if its true to false . How to achieve that?

 

Thankss 


 

I'm trying to test a trigger that sets a value in a custom field on the OpportunityLineItem object after it's inserted based on details in the OpportunityLineItemSchedule records added. The trigger's working fine, but for some reason, my unit test isn't.

 

The unit test code is below, but it's failing on the second assertion (at the very bottom). "Contract_duration__c" is set by the trigger to "schedule.size()" where schedule is:

 

List<OpportunityLineItemSchedule> schedule = [select ScheduleDate from OpportunityLineItemSchedule where OpportunityLineItemId = :LI.Id];

 

I expect that the number of OpportunityLineItemSchedule records will be 12 because that's what I've defined on the instantiated Product2 object (NumberofRevenueInstallments=12). But it's actually coming out with zero records. I'm sure the problem is with my assumptions -- any help?

 

Test Method

 

static testMethod void testScheduledProduct() {
Account account = new Account(name='Unit Test Account',BillingState='CA');
insert account;

Opportunity opportunity = new Opportunity(
AccountId=account.Id,
name='Unit Test Opportunity',
CloseDate=date.today(),
StageName='Decision Maker Interested'
);
insert opportunity;

Product2 product = new Product2(
Name='Unit Test Product',
isActive=true,
CanUseRevenueSchedule=true,
// default scheduling settings
RevenueScheduleType='Repeat',
NumberofRevenueInstallments=12,
RevenueInstallmentPeriod='Monthly'
);
insert product;

Pricebook2 pricebook = [SELECT Id, Name FROM Pricebook2 WHERE isStandard=true AND isDeleted=false AND isActive=true];

PricebookEntry pbentry = new PricebookEntry(
Pricebook2Id=pricebook.Id,
Product2Id=product.Id,
isActive=true,
UnitPrice=0,
UseStandardPrice=false
);
insert pbentry;

OpportunityLineItem opp_product = new OpportunityLineItem(
OpportunityId=opportunity.Id,
PriceBookEntryId=pbentry.Id,
Quantity=1,
UnitPrice=200
);
insert opp_product;

// Setup complete
// Test that the Monthly amount and Contract duration were set correctly
opp_product = [SELECT Monthly_amount__c, Contract_duration__c FROM OpportunityLineItem WHERE Id = :opp_product.Id];

System.assert(opp_product.Monthly_amount__c==200);
System.assert(opp_product.Contract_duration__c==12);
}

 

Trigger

 

trigger setMonthlyAmountAndDuration on OpportunityLineItem (after insert, after update) {
if(!SetMonthlyAmountHelper.hasAlreadySetMonthlyAmount()) {
for (OpportunityLineItem LI : trigger.new) {
PricebookEntry pbentry = [select Product2Id from PricebookEntry where Id = :LI.PriceBookEntryId];
Product2 prod = [select CanUseRevenueSchedule, NumberOfRevenueInstallments from Product2 where Id = :pbentry.Product2Id];

if (prod.CanUseRevenueSchedule==true && prod.NumberofRevenueInstallments>0) {
OpportunityLineItem opp_prod = [select Monthly_amount__c, Contract_duration__c from OpportunityLineItem where Id = :LI.Id];
List<OpportunityLineItemSchedule> schedule = [select ScheduleDate from OpportunityLineItemSchedule where OpportunityLineItemId = :LI.Id];

if (schedule.size()==0)
opp_prod.Monthly_amount__c = LI.UnitPrice;
else
opp_prod.Monthly_amount__c = LI.UnitPrice / schedule.size();

opp_prod.Contract_duration__c = schedule.size();

SetMonthlyAmountHelper.setAlreadySetMonthlyAmount();
Update opp_prod;
}
}
}
}

 

 

 

Given that unit test methods are required to be static and void, I find that I have a lot of duplicated code for the test setup. If I write 3 unit tests for one method because there are different branches in the logic of that method, I'm copying and pasting the data setup portion of the test case into each of the three unit tests.

 

There's gotta be a better way! Help? Ideas?

 

Thanks 

I need to display the Opportunity Products related list on a VF page with a custom controller. I don't know the exact name of the list though, and I can't find a reference for each of the standard object's valid related lists. Here's the code I'm using on the page:

 

<apex:relatedList subject="{!opportunity}" list="OpportunityProducts" title="Products"/>

 

And I get an error saying:

'OpportunityProducts' is not a valid child relationship name for entity Opportunity

 

I've tried "Products", "OpportunityProducts", and "Opportunity Products". Again, if someone could point me to the list of all available related lists -- or how to find it through debugging -- I would appreciate it.