• mmaxtra
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 22
    Questions
  • 16
    Replies

Hi:

   I have the following query:

 

SELECT Student__c, Name, MintoPass__c, Term,Subject FROM Courses Where Student__c='XXX'

 Which gives me table like this:

Subject AreaMinPassTerm 
Arts1.01 
Arts0.51 
English0.52 
Math0.51 
Science0.52 
Social Studies0.52 

 

I want to Group Arts together into one Line...

like 

Subjectarea MinPass Term

Arts                1.5        1

English             .5         1

 

Is there a way to break this table up into Terms???

I have place the query above into a List<Courses> student...

 

Thanks

 

 

 

 

Hi:

   I have a table that has a selectoption Picklist... and it is shown when a checkbox is true..

Now when you click off the checkbox , the picklist is hidden but the value stays in there as it was selected from the user....

 

Does anyone know a way to set the value of the picklist to a particular value if checkbox is not true????

 

Thanks 

Hi:

   I have an input Field and I wanted a help text next to it just like in regular saleforce. How would I do that???

LIke the little "i" blue icon.

 

How you bold one text out from the rest of the text in:

 

<apex:pageblock title="Information about Policy. " mode="edit">

 Like I need the Policy word bold?

Thanks 

 

 

Hi I am trying to get this testmethod to work for my SOSL and I can't figure out what am I doing wrong?I get 25% with an error...

public class SimpleStepSearchController { public PageReference Start() { PageReference SimpleStep = Page.SimpleStep1; SimpleStep.setRedirect(true); return SimpleStep; } String searchText; List<Account> results; List<Contact> resultsc; public String getSearchText(){ return searchText; } public void setSearchText(String s) { searchText = s.endsWith('*') ? s : s + '*'; //searchText = s; } public List<Account> getResults() { return results; } public List<Contact> getResultsc() { return resultsc; } public PageReference doSearch() { results = (List<Account>)[FIND :searchText IN NAME FIELDS RETURNING Account(Name,BillingState,BillingCity,Phone,Website,Id,RecordType.Name)] [0]; resultsc = (List<Contact>)[FIND :searchText IN NAME FIELDS RETURNING Contact(Name,Account.Name,Id,AccountId,Phone,Email,RecordType.Name)] [0]; return null; } public static testMethod void testSimpleStepSearchController() { //Create a reference to the VF Page being tested, this is needed if you are passing parameters in the URL //or if you are going to have actions on the page that direct to a different page. PageReference pageRef = Page.SimpleStepSearchPage; Test.setCurrentPage(pageRef); //Instantiate the controller SimpleStepSearchController controller = new SimpleStepSearchController(); String searchText; searchText= 'fa'; //searchText=controller.getItems(); //searchText=controller.getitems(); //push the button on the page String searchquery = 'FIND :searchText IN NAME FIELDS RETURNING Contact(Name,Account.Name,Id,AccountId,Phone,Email,RecordType.Name)'; List<List<SObject>> junkSearch = search.query(searchquery); controller.doSearch(); PageReference pageRef1 = Page.SimpleStep1; Test.setCurrentPage(pageRef1); } }

 


Hi all:

I have an issue where I am getting a Subtotal on a product family but my code is hard coded with the product family.

Now if the admin adds another product family I would have to go back to the code and hard code that family...

 

Is there an easier way to do the following:

 

quote = [Select s.Opportunity__r.Pricebook2Id, Quote_Amount_rollup__c, LastmodifiedDate,Decimal__c, (Select Unit_Price__c, Unit_Net_Price__c, ServiceDate__c, Sales_Discount__c, Quote__c, Qty_Ordered__c, Product2__c, Product2__r.Name, Product2__r.Family,Name, Id, Ext_Price__c, Ext_Net_Price__c, Ext_Price_tmp__c, Description__c From Quote_Lines__r order by name ), (Select Title, Body, CreatedDate From Notes), s.Opportunity__r.HasOpportunityLineItem, s.Opportunity__r.Sub_Partner__c, s.Opportunity__r.Name, s.Name,s.Partner_Direct__c, s.Opportunity__r.Id, s.Opportunity__r.License__c,s.Opportunity__c,s.Valid_Until__c From SFDC_520_Quote__c s where s.id = :id limit 1]; quoteLineItems = quote.Quote_Lines__r; for ( SFDC_520_QuoteLine__c ql : quoteLineItems ) { if(ql.Product2__r.Family=='ABC'){ sumSub += ql.Ext_Net_Price__c; } if(ql.Product2__r.Family=='CDE'){ sumSub2 += ql.Ext_Net_Price__c; } }

 Thanks

Happy New Year

 

 

How would one replace the ampersand in this:

R & S

so in an url for salesforce to pick it up it comes in as:

R+&+S

I tried:

String abc;
abc = c.name.replace('&', '+&+');

That did not work...

 

I am overriding a URL... 

Hi:

   I need to know which I can not find in my research is how to write a testmethod when a standard button is override which means that I have specified in my controller to override the URL.

Now the standard button is New on the Opportunity.

I am overriding the Opportunity URL, so that I can place in the Contact Name and fill it in automatically when they create a new Opp through Contact record.

 

In my test method I do not know how to write a testmethod for this part of my controller:

 

public newoppbutton(ApexPages.StandardController stdController){ string ret=ApexPages.currentPage().getParameters().get('RetURL'); ret=ret.substring(1,ret.length()); if(ret.startswith('003')){ try{ mycontact = [select id,name from contact where id=:ret]; gotcontact=true; }catch(QueryException q){ system.debug(q.getmessage()); } } }

 I am getting stuck at this:

 string ret=ApexPages.currentPage().getParameters().get('RetURL');
ret=ret.substring(1,ret.length());

 Can someone guide me or have an example of how to write this in a testmethod please?

I did try this in a testmethod which did not work:

 

//Now get the contact id redir='/'+ cc.id; PageReference p2 = new PageReference(redir); system.debug('PageReference p21:' + p2); Test.setCurrentPage(p2); string ret; String redire; ret=redir.substring(1); system.debug('PageReference p21d:' + ret); Contact cn=[Select name, id, firstname, lastname,recordtype.name from Contact where id=:ret];

 Which did not work when I called within my testmethod:

ApexPages.standardController sc = new ApexPages.standardController(new Opportunity());
newoppbutton controller = new newoppbutton(sc); 

 My page Reference in my controller is :

public PageReference init() {
String redirectUrl = '';
String recordTypeId = System.currentPageReference().getParameters().get('RecordType');


if (recordTypeId != null) {
redirectUrl = '/006/e?retURL=/006/o&RecordType=' + recordTypeId + '&nooverride=1';
}else if(gotcontact) {
redirectUrl = '/006/e?CF00N70000002RNNE='+mycontact.Name+'&nooverride=1';
}else{
redirectUrl = '/006/e?nooverride=1';
}
PageReference newOpp = new PageReference(redirectUrl);
return newOpp;
}

 So I have tried everything and keep failing on a attempt to de-ference a null...

Thanks

Happy Holidays to all

 

 

 

 

Hi:

   Does anyone know how to write a testmethod for retURL and redirect...

See my code below:

 

public class newoppbutton { String retURL; String oppId; public newoppbutton(ApexPages.StandardController stdController){ } public PageReference init() { retURL= ApexPages.currentPage().getParameters().get('retURL'); oppId = retURL.substring(1); Contact c = [Select lastname,firstname from Contact where id =:oppId]; String redirectUrl = ''; String recordTypeId = System.currentPageReference().getParameters().get('RecordType'); if (recordTypeId != null) { redirectUrl = '/006/e?retURL=/006/o&RecordType=' + recordTypeId + '&nooverride=1'; } else { redirectUrl = '/006/e?CF00N70000002RNNE='+c.firstname+'+'+c.lastname+'&nooverride=1'; } PageReference newOpp = new PageReference(redirectUrl); return newOpp; } } }

 VF Code:

<apex:page standardController="Opportunity" extensions="newoppbutton" action="{!init}"> </apex:page>

 Thank you

 

 

 

Hi all:

Happy Holidays...

 

Basically something is wrong with my URL redirect that I keep getting the following error:

Attempt to de-reference a null object

 

 

public class newoppbutton { Contact contact{get;set;} public newoppbutton(ApexPages.StandardController stdController){ } public PageReference init() { String redirectUrl = ''; String recordTypeId = System.currentPageReference().getParameters().get('RecordType'); if (recordTypeId != null) { redirectUrl = '/006/e?retURL=/006/o&RecordType=' + recordTypeId + '&nooverride=1'; } else { // redirectUrl = '/006/e?nooverride=1'; redirectUrl = '/006/e?CF00N70000002RNNE='+contact.Name+'&nooverride=1'; } PageReference newOpp = new PageReference(redirectUrl); return newOpp; } } }

 Could someone tell me wz up with my code...or the correct URL to use for an user to go to a regular Opp page with the contact name filled in?

Thanks

 

 

Hi:

   I have override the new button on the Opportunity with a VF page.

If the User Profile is not XX profile then it will take the user to the regular Opportunity page.

The thing is the User is creating the new opportunity page off the Contact. So the user is on the contact and then from the related opportunity list click on New Opportunity.

 

So if it is a regular user, does anyone know the URL 

so far I have:

 '/006/e?'

but I need to place in the Contact in the URL so it follows through on the Opportunity Record...

 

Thanks

 

I am getting the SOQL Query 21 Error and I really do not know what to do can someone please suggest what I should do....

I know the For loop has something to do with my query being in it, but if I take it out I do not know what to do or how to actual do this then...

 

I am getting my error :

 

for (opportunitylineitem oppline : opp.OpportunityLineItems) { i++; OpportunityLineItem sf = [SELECT Id, Product_Family__c FROM OpportunityLineItem where Id=:oppline.Id];

 This is my class...

 

 

 

public static void copyLineItemsFromOpp(List<SFDC_520_Quote__c> qs) { // We will modify and update the quotes with totals at the end, so we clone it // first since Trigger.new records cannot be modified in after triggers. Notice that // we use the deepClone method on the list as clone for sobjects creates a shallow // copy which is still read-only. List<SFDC_520_quote__c> quoteList = qs.deepClone(true); try { // By setting the inQuoteTrigger class variable, this method tells // the quoteLine trigger that it should disable itself during this // operation (the quoteLine trigger is described in Example 3) inQuoteTrigger = true; //Now the method creates an empty array of quote line items List<SFDC_520_QuoteLine__c> quoteItemList = new List<SFDC_520_QuoteLine__c>(); // Next get the opportunity line items for the respective Opportunities. // This demonstrates the aggregate relationship query pattern for getting // children correlated back to their parent. You could also query // OpportunityLineItem directly but would then have to correlate the items // back to their respective parents (opportunity) inside the code manually. // We are constructing a map so the respective opportunity // (with its line items) can be easily correlated back to quote as we process // them below. Map<Id, Opportunity> opportunityMap = new Map<Id, Opportunity>( [select Id,Partner__c, (Select Id, OpportunityId, SortOrder, PricebookEntryId, Quantity, TotalPrice, UnitPrice, ListPrice, ServiceDate, Description, CreatedDate, CreatedById, LastModifiedDate, LastModifiedById, SystemModstamp, IsDeleted , PricebookEntry.Name, PricebookEntry.Product2id,CurrencyIsoCode from opportunitylineitems order by createddate) from Opportunity where Id IN :getOpportunityIds(quoteList)]); // Iterate through the quotes in the bulk operation. for(SFDC_520_Quote__c quote:quoteList) { // Next, the method manually calculates the overall total for the quote // by iterating over an array of OpportunityLineItem records from the // preceeding SOQL query. The query selects the data from opportunity // line items that match the opportunity associated with the quote. Double tot = 0; // The running total Integer i = 0; // Number the line items // Get the respective opportunity and its line items from the map. Opportunity opp = opportunityMap.get(quote.opportunity__c); // If this quote is not associated to an opportunity then skip it. if(opp == null) continue; for (opportunitylineitem oppline : opp.OpportunityLineItems) { i++; OpportunityLineItem sf = [SELECT Id, Product_Family__c FROM OpportunityLineItem where Id=:oppline.Id]; // For each opportunity line item, the method // calculates the running total if (oppline.unitprice != null && oppline.quantity != null) tot += oppline.unitprice * oppline.quantity; // And then it adds a new quote line item to the quoteitems, // array, initializing it with values. Reseller__c[] r =[Select Name, License__c from Reseller__c where Name=:quote.Partner_Direct__c]; if(r.isEmpty()){ quoteItemList.add(new SFDC_520_quoteline__c( quote__c = quote.id, // The method uses the counter variable to number // the line items. Because the SOQL query ordered // them by the date they were created with an ORDER BY // clause, they will be numbered that way as well. //name = String.valueOf(i), // The method then uses the values for product, unit // price, quantity, total price, and color from the // opportunity line item. Sales_Discount__c = 0.0, Qty_Ordered__c = oppline.Quantity, Unit_Price__c = oppline.UnitPrice, Description__c = oppline.Description, ServiceDate__c = oppline.ServiceDate, Product2__c = oppline.PricebookEntry.Product2id, CurrencyIsoCode = oppline.CurrencyIsoCode ));} // The method uses the counter variable to number // the line items. Because the SOQL query ordered // them by the date they were created with an ORDER BY // clause, they will be numbered that way as well. //name = String.valueOf(i), // The method then uses the values for product, unit // price, quantity, total price, and color from the // opportunity line item. if(!r.isEmpty() && sf.Product_Family__c =='License'){ quoteItemList.add(new SFDC_520_quoteline__c( quote__c = quote.id, Sales_Discount__c = r[0].License__c, Qty_Ordered__c = oppline.Quantity, Unit_Price__c = oppline.UnitPrice, Description__c = oppline.Description, ServiceDate__c = oppline.ServiceDate, Product2__c = oppline.PricebookEntry.Product2id, CurrencyIsoCode = oppline.CurrencyIsoCode )); } if(!r.isEmpty() && sf.Product_Family__c <>'License'){ quoteItemList.add(new SFDC_520_quoteline__c( quote__c = quote.id, Sales_Discount__c = 0.0, Qty_Ordered__c = oppline.Quantity, Unit_Price__c = oppline.UnitPrice, Description__c = oppline.Description, ServiceDate__c = oppline.ServiceDate, Product2__c = oppline.PricebookEntry.Product2id, CurrencyIsoCode = oppline.CurrencyIsoCode )); } } } //The method adds the whole array of quote line items //to the database with a single insert statement. insert quoteItemList; update quoteList; } finally { // To clean up the working variable, the method resets inQuoteTrigger to false; inQuoteTrigger = false; } }

 

 

 

Hi:

 Is there a way to find out the day off from a given date?

I have a Date Field called X, If X were to equal 10/01/09 which was Thursday. So like I would like for it to tell me what day is it?

 

I need to write some conditions in my class and I do not know how to get the day from the date.

 

Thanks

MMA

My test coverage is 100% but average is 86% with 1 failure...

I dont understand this error:

System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Record Type ID: id value not valid for the users profile: {0}: [RecordTypeId]

 

I do not understand ...

Hi:

    I have written an apex controller and VF page off a custom object. Now when an user click on New Order button it takes them to a new VF page that I created and the page tells the user how many customers are there at the top of the page already.

It would say Total Customers=3.

 

Now, I have 10 picklist and all have the same exact value in it. in Order Picklist_1__c to Picklist_10__c.

 

Since Customers=3 I need to render only 2 picklist, so on the page Picklist_1__c, Picklist_2__c should come up. One of the picklist is standard and always shows no matter what....

 

Does anyone know how to render something like this?

 

Second question is After the ORder has been saved and they go and hit Edit it takes them to the original page layout and shows them all 10 picklist fields. Do I have to create an another VF Page for the edit as well?

 

Please if there is an easier way then please let me know, or if anyone has something please let me know...

Thank You

MMA

Hi :

   Is there a way to hide the Edit button when the Status equals complete ....

Thanks

MMA

Hi:

   I wanted to know, can I create a button that would prevent a record from being created when one exist already for the child object.

If yes, does anyone have an example to lead me off.

Thanks

MMA

  • September 16, 2009
  • Like
  • 0

Hi:

   I have an s-control which is linked to a button which is linked to a VF page.

"/apex/editQuoteLineBatch?Id={!xxx__c.Id}"

 

How do I get the xxx ID into the VF page input box?

 

Thanks for your help in advance.

 

  • September 07, 2009
  • Like
  • 0

Hi:

   I have a dropdown which contains the record types. Now I would like to display fields off that record type based on what the user selected. Does anyone have an example of this? 

Thanks

MMA

Does anyone know how do i group by Product2__r.Family in this statement in Apex Code? In the end I want to create a VF Page that would be in a PageTableBlock to break it down by Family withSubtotal..

 

void queryQuoteLines(id id) { quote = [Select s.Opportunity__r.Pricebook2Id, Quote_Amount_rollup__c,LastmodifiedDate, (Select Unit_Price__c, Unit_Net_Price__c, ServiceDate__c, Sales_Discount__c,CurrencyIsoCode, Quote__c, Qty_Ordered__c, Product2__c, Product2__r.Family, Product2__r.Name, Product_Family__c,Name, Id, Ext_Price__c, Ext_Net_Price__c, Ext_Price_tmp__c, Description__c From Quote_Lines__r order by name ), (Select Title, Body, CreatedDate From Notes), s.Opportunity__r.HasOpportunityLineItem, s.Opportunity__r.Sub_Partner__c,s.Opportunity__r.Name, s.Name,s.Partner_Direct__c, s.Opportunity__r.Id, s.Opportunity__r.License__c,s.Opportunity__c,s.Valid_Until__c From SFDC_520_Quote__c s where s.id = :id limit 1];

 

 

 

Hi:

   I have the following query:

 

SELECT Student__c, Name, MintoPass__c, Term,Subject FROM Courses Where Student__c='XXX'

 Which gives me table like this:

Subject AreaMinPassTerm 
Arts1.01 
Arts0.51 
English0.52 
Math0.51 
Science0.52 
Social Studies0.52 

 

I want to Group Arts together into one Line...

like 

Subjectarea MinPass Term

Arts                1.5        1

English             .5         1

 

Is there a way to break this table up into Terms???

I have place the query above into a List<Courses> student...

 

Thanks

 

 

 

 

Hi:

   I have an input Field and I wanted a help text next to it just like in regular saleforce. How would I do that???

LIke the little "i" blue icon.

 

Hi all:

I have an issue where I am getting a Subtotal on a product family but my code is hard coded with the product family.

Now if the admin adds another product family I would have to go back to the code and hard code that family...

 

Is there an easier way to do the following:

 

quote = [Select s.Opportunity__r.Pricebook2Id, Quote_Amount_rollup__c, LastmodifiedDate,Decimal__c, (Select Unit_Price__c, Unit_Net_Price__c, ServiceDate__c, Sales_Discount__c, Quote__c, Qty_Ordered__c, Product2__c, Product2__r.Name, Product2__r.Family,Name, Id, Ext_Price__c, Ext_Net_Price__c, Ext_Price_tmp__c, Description__c From Quote_Lines__r order by name ), (Select Title, Body, CreatedDate From Notes), s.Opportunity__r.HasOpportunityLineItem, s.Opportunity__r.Sub_Partner__c, s.Opportunity__r.Name, s.Name,s.Partner_Direct__c, s.Opportunity__r.Id, s.Opportunity__r.License__c,s.Opportunity__c,s.Valid_Until__c From SFDC_520_Quote__c s where s.id = :id limit 1]; quoteLineItems = quote.Quote_Lines__r; for ( SFDC_520_QuoteLine__c ql : quoteLineItems ) { if(ql.Product2__r.Family=='ABC'){ sumSub += ql.Ext_Net_Price__c; } if(ql.Product2__r.Family=='CDE'){ sumSub2 += ql.Ext_Net_Price__c; } }

 Thanks

Happy New Year

 

 

Hi I am overriden a new button using Apex Code and VF for redirect...

When the name in the contact is :

FirstName = Me & Marry

LastName = Yo

Total Name = Me & Marry Yo

 

My code works when it is Me Yo

My code ends when it is Me & Marry Yo?

 

redirectUrl = '/006/e?CF00N70000002RNNE='+c.name+'&nooverride=1';

 Any Suggestions I also tried:

 

redirectUrl = '/006/e?CF00N70000002RNNE='+c.firstname+'+'+c.lastname+'&nooverride=1';

 Did not work...

Thanks

 

 

 

Hi:

   Does anyone know how to write a testmethod for retURL and redirect...

See my code below:

 

public class newoppbutton { String retURL; String oppId; public newoppbutton(ApexPages.StandardController stdController){ } public PageReference init() { retURL= ApexPages.currentPage().getParameters().get('retURL'); oppId = retURL.substring(1); Contact c = [Select lastname,firstname from Contact where id =:oppId]; String redirectUrl = ''; String recordTypeId = System.currentPageReference().getParameters().get('RecordType'); if (recordTypeId != null) { redirectUrl = '/006/e?retURL=/006/o&RecordType=' + recordTypeId + '&nooverride=1'; } else { redirectUrl = '/006/e?CF00N70000002RNNE='+c.firstname+'+'+c.lastname+'&nooverride=1'; } PageReference newOpp = new PageReference(redirectUrl); return newOpp; } } }

 VF Code:

<apex:page standardController="Opportunity" extensions="newoppbutton" action="{!init}"> </apex:page>

 Thank you

 

 

 

Hi all:

Happy Holidays...

 

Basically something is wrong with my URL redirect that I keep getting the following error:

Attempt to de-reference a null object

 

 

public class newoppbutton { Contact contact{get;set;} public newoppbutton(ApexPages.StandardController stdController){ } public PageReference init() { String redirectUrl = ''; String recordTypeId = System.currentPageReference().getParameters().get('RecordType'); if (recordTypeId != null) { redirectUrl = '/006/e?retURL=/006/o&RecordType=' + recordTypeId + '&nooverride=1'; } else { // redirectUrl = '/006/e?nooverride=1'; redirectUrl = '/006/e?CF00N70000002RNNE='+contact.Name+'&nooverride=1'; } PageReference newOpp = new PageReference(redirectUrl); return newOpp; } } }

 Could someone tell me wz up with my code...or the correct URL to use for an user to go to a regular Opp page with the contact name filled in?

Thanks

 

 

I am getting the SOQL Query 21 Error and I really do not know what to do can someone please suggest what I should do....

I know the For loop has something to do with my query being in it, but if I take it out I do not know what to do or how to actual do this then...

 

I am getting my error :

 

for (opportunitylineitem oppline : opp.OpportunityLineItems) { i++; OpportunityLineItem sf = [SELECT Id, Product_Family__c FROM OpportunityLineItem where Id=:oppline.Id];

 This is my class...

 

 

 

public static void copyLineItemsFromOpp(List<SFDC_520_Quote__c> qs) { // We will modify and update the quotes with totals at the end, so we clone it // first since Trigger.new records cannot be modified in after triggers. Notice that // we use the deepClone method on the list as clone for sobjects creates a shallow // copy which is still read-only. List<SFDC_520_quote__c> quoteList = qs.deepClone(true); try { // By setting the inQuoteTrigger class variable, this method tells // the quoteLine trigger that it should disable itself during this // operation (the quoteLine trigger is described in Example 3) inQuoteTrigger = true; //Now the method creates an empty array of quote line items List<SFDC_520_QuoteLine__c> quoteItemList = new List<SFDC_520_QuoteLine__c>(); // Next get the opportunity line items for the respective Opportunities. // This demonstrates the aggregate relationship query pattern for getting // children correlated back to their parent. You could also query // OpportunityLineItem directly but would then have to correlate the items // back to their respective parents (opportunity) inside the code manually. // We are constructing a map so the respective opportunity // (with its line items) can be easily correlated back to quote as we process // them below. Map<Id, Opportunity> opportunityMap = new Map<Id, Opportunity>( [select Id,Partner__c, (Select Id, OpportunityId, SortOrder, PricebookEntryId, Quantity, TotalPrice, UnitPrice, ListPrice, ServiceDate, Description, CreatedDate, CreatedById, LastModifiedDate, LastModifiedById, SystemModstamp, IsDeleted , PricebookEntry.Name, PricebookEntry.Product2id,CurrencyIsoCode from opportunitylineitems order by createddate) from Opportunity where Id IN :getOpportunityIds(quoteList)]); // Iterate through the quotes in the bulk operation. for(SFDC_520_Quote__c quote:quoteList) { // Next, the method manually calculates the overall total for the quote // by iterating over an array of OpportunityLineItem records from the // preceeding SOQL query. The query selects the data from opportunity // line items that match the opportunity associated with the quote. Double tot = 0; // The running total Integer i = 0; // Number the line items // Get the respective opportunity and its line items from the map. Opportunity opp = opportunityMap.get(quote.opportunity__c); // If this quote is not associated to an opportunity then skip it. if(opp == null) continue; for (opportunitylineitem oppline : opp.OpportunityLineItems) { i++; OpportunityLineItem sf = [SELECT Id, Product_Family__c FROM OpportunityLineItem where Id=:oppline.Id]; // For each opportunity line item, the method // calculates the running total if (oppline.unitprice != null && oppline.quantity != null) tot += oppline.unitprice * oppline.quantity; // And then it adds a new quote line item to the quoteitems, // array, initializing it with values. Reseller__c[] r =[Select Name, License__c from Reseller__c where Name=:quote.Partner_Direct__c]; if(r.isEmpty()){ quoteItemList.add(new SFDC_520_quoteline__c( quote__c = quote.id, // The method uses the counter variable to number // the line items. Because the SOQL query ordered // them by the date they were created with an ORDER BY // clause, they will be numbered that way as well. //name = String.valueOf(i), // The method then uses the values for product, unit // price, quantity, total price, and color from the // opportunity line item. Sales_Discount__c = 0.0, Qty_Ordered__c = oppline.Quantity, Unit_Price__c = oppline.UnitPrice, Description__c = oppline.Description, ServiceDate__c = oppline.ServiceDate, Product2__c = oppline.PricebookEntry.Product2id, CurrencyIsoCode = oppline.CurrencyIsoCode ));} // The method uses the counter variable to number // the line items. Because the SOQL query ordered // them by the date they were created with an ORDER BY // clause, they will be numbered that way as well. //name = String.valueOf(i), // The method then uses the values for product, unit // price, quantity, total price, and color from the // opportunity line item. if(!r.isEmpty() && sf.Product_Family__c =='License'){ quoteItemList.add(new SFDC_520_quoteline__c( quote__c = quote.id, Sales_Discount__c = r[0].License__c, Qty_Ordered__c = oppline.Quantity, Unit_Price__c = oppline.UnitPrice, Description__c = oppline.Description, ServiceDate__c = oppline.ServiceDate, Product2__c = oppline.PricebookEntry.Product2id, CurrencyIsoCode = oppline.CurrencyIsoCode )); } if(!r.isEmpty() && sf.Product_Family__c <>'License'){ quoteItemList.add(new SFDC_520_quoteline__c( quote__c = quote.id, Sales_Discount__c = 0.0, Qty_Ordered__c = oppline.Quantity, Unit_Price__c = oppline.UnitPrice, Description__c = oppline.Description, ServiceDate__c = oppline.ServiceDate, Product2__c = oppline.PricebookEntry.Product2id, CurrencyIsoCode = oppline.CurrencyIsoCode )); } } } //The method adds the whole array of quote line items //to the database with a single insert statement. insert quoteItemList; update quoteList; } finally { // To clean up the working variable, the method resets inQuoteTrigger to false; inQuoteTrigger = false; } }

 

 

 

Hi:

   I have a dropdown which contains the record types. Now I would like to display fields off that record type based on what the user selected. Does anyone have an example of this? 

Thanks

MMA

I have a custom object called "Overrides".  I've been developing a VisualForce page and custom controller that would allow users to data enter as many rows that they want of Overrides objects, at one time -- basically set them all up before clicking "Save".  On save each Overrides object row is saved.  This all works just as I want.

Now I need to add RecordTypes into the mix.  Ideally I want to have a dropdown at the top of the page where they will choose the record type of all of the Overrides objects they are creating for this particular "Save" operation.  I'm new to Apex and am having a hard time figuring this out.

Can someone show some sample code how to:

1) setup the controller to populate the RecordType dropdown box
2) set the dropdown box RecordType selection to each Overrides object when saving

Here is my controller:

Code:
public class multiOverrideInsertController{ 
      
    public List<Override__c> over{get; set;}   
    
    public multiOverrideInsertController(){        
        over= new List<Override__c>();        
        over.add(new Override__c());    
    }        

    public void addrow(){        
        over.add(new Override__c());    
    }     
    
    public void removerow(){  
        Integer i = over.size();      
        over.remove(i-1);    
    }        

    public PageReference save(){       
        insert over;        
        PageReference home = new PageReference('/a00/o');        
        home.setRedirect(true);        
        return home;    
    }
}

Here's my VisualForce page:

Code:
<apex:page controller="multiOverrideInsertController">    
    <apex:form >        
    <apex:pageBlock title="Insert Multiple Overrides">                    
        <apex:pageBlockButtons >                
            <apex:commandButton value="Save" action="{!save}" rerender="error,table"/>            
        </apex:pageBlockButtons>                    
        <apex:pageMessages ></apex:pageMessages>
    <apex:pageBlockTable value="{!over}" var="a" id="table">      
        <apex:column headerValue="Opportunity">                    
            <apex:inputField value="{!a.Opportunity__c}" required="true" />                         
        </apex:column>     
        <apex:column headerValue="Institution">                    
            <apex:inputField value="{!a.Institution__c}" required="true" />                         
        </apex:column> 
        <apex:column headerValue="Advisor (Rep)">                    
            <apex:inputField value="{!a.Advisor_Rep__c}" required="true" />                         
        </apex:column>                              
        <apex:column headerValue="Override Date">                      
            <apex:inputField value="{!a.Override_Date__c}" required="true" />                          
        </apex:column>
        <apex:column headerValue="Override Amount">                    
            <apex:inputField value="{!a.Override_Amount__c}" required="true" />                           
        </apex:column>                                          
     </apex:pageBlockTable>   
     <apex:pageblockButtons location="bottom">   
         <div style="text-align:right;margin-right:30px;font-weight:bold;">             
            <apex:commandLink value="Add Row" action="{!addRow}" rerender="table,error" immediate="true" /> &nbsp;|&nbsp;&nbsp;  
            <apex:commandLink id="RemoveRow" value="Remove Row" action="{!removeRow}" rerender="table,error" immediate="true" />
         </div>      
     </apex:pageblockButtons>                      
    </apex:pageBlock>    
    </apex:form>
</apex:page>




Hello everyone, just wanted to share with the community this custom component I made and give something back for the help I've received. :smileyhappy:

The purpose of the component is to enable autocomplete in lookup fields. I used the autocomplete js created by Jim Roos:
(http://www.jimroos.com/2007/05/ajax-autocomplete.html) but made some modifications to it so that it could interact with an Apex controller among some other things...

So my idea was that if you were making a VF page that had an inputfield that was related to a lookupfield you would just insert this autocomplete component to that inputfield. Something like this:

Code:
           <apex:inputField value="{!Contact.accountid}" id="accname" styleClass="cField">
<c:autocomplete ObjectName="Accounts" InputId="{!$Component.accname}" AutoCompleteId="accACid" ClassName="autocomplete300"/>
</apex:inputField>

The component has 4 parameters:

The name of the object or custom object that the inputfield relates to (new objects must be added inside the apex classes since i had some problems constructing a dynamic query).
The InputId which is used to relate the component to the input field
The id for the Component
A classname parameter that basically just defines the width of the suggestions menu.

Here's a screenshot of how it looks like in action:




Here's a link to the file containing the required files:

AutoCompleteComponent



Jonathan.


Message Edited by jonathan rico on 08-16-2008 01:55 PM

Message Edited by jonathan rico on 08-17-2008 09:04 AM
Message Edited by jonathan rico on 01-02-2010 05:01 PM