• doravmon
  • NEWBIE
  • 174 Points
  • Member since 2015

  • Chatter
    Feed
  • 6
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 74
    Replies
Hi
I have this code that I am trying to increase the Code coverge from 70% to 80%, Anyone available to guide me through it please.
I have created the following dynamic picklist.
for(firepond__Configurable__c prod : [select id, name, firepond__Item_Id__r.name, firepond__Item_Id__c, firepond__Item_Id__r.Salesforce_Product__r.name, firepond__Item_Id__r.Salesforce_Product__r.id, firepond__Item_Id__r.firepond__Description__c, 
                                                                firepond__RecordType__c from firepond__Configurable__c where firepond__RecordType__c = 'Product'
                                                                and firepond__Item_Id__c<>'' and (Not firepond__Item_Id__r.name like '%Veryx%')]) {
                    
                    productNamesMap.put(prod.Id, prod.firepond__Item_Id__r.firepond__Description__c);
                    productIdsMap.put(prod.firepond__Item_Id__r.firepond__Description__c, prod.Id);
                    FPXProd.add(prod.firepond__Item_Id__r.Salesforce_Product__r.name);
                        }             
                    if(productNamesMap != null){
                    productNamesList = productNamesMap.values();
                    }

        for(Product2 prod : [ select id, name from product2 where not(name =:FPXprod)]){
                    productNamesList.add(prod.name);
                    produc
The end user can filter this picklist by typing keywords in the text field. If the end user selects a value without filtering the picklist, the system will not return the currect selected value. But if the user filters the picklist to a few values, they will recieve the selected value. Why does the size of the picklist affects whether the system will return the value the user selects?

Thanks,
ckellie
 
Hi everyone,

I am trying (through workflows) to update automatically a standard field name (Industry in the Account tab) when a specific Account Type Record value is chosen.
Is there any way to manage this without code?
How can i acces to the field names using Apex classes in triggers?


Thanks a lot,
Skender
I need to update some custom fields on the opportunity when certin products are selected. I just need the starting point to update the opportunity I believe that everything else is correct. 

If Pricebook2.Product2.Sales_Order_Group__c = 'Hotline Services' OR 'Policy Management Services' OR 'Incident Management Services' I need to update Implementation_Team__c to True 
Else if Pricebook2.Product2.Sales_Order_Group__c = 'ReadyTraining Services' I need to Update Training_Team__c to True

There are a couple more values but I am sure that I can figure that part out with a sample. Also I don't think the ELSE IF is right becuase it should be possible that both are selected. 

Any help would be greatly appricated. Below is what I have started but not sure if it is all correct. 


trigger Projectrollup on Opportunity (after insert, after update) {
    Map<PricebookEntry.Product2.Name,OpportunityLineItem> prod = new map<PricebookEntry.Product2.Name,OpportunityLineItem>();
        for(Opportunity o: trigger.new){
            if(o.HasOpportunityLineItem == true){
                string opptyId = o.id;
                OpportunityLineItem[] OLI = [Select UnitPrice, Quantity, PricebookEntry.Product2Id, 
                                             TotalPrice,
                                             PricebookEntry.Product2.Name, Description, Converted_to_Asset__c,Asset__c,
                                             PricebookEntry.Product2.Create_Asset__c, PricebookEntry.Product2.Sales_Order_Group__c
                                      From OpportunityLineItem 
                                      where OpportunityId = :opptyId
                                      And   PricebookEntry.Product2.Product_Reporting_Category__c = 'Services'];
 
How to write a formula to calculate Age in Years Months and Days when DOB is given using formula filed in salesforce?

Hi all,

I created a button of object A, and this button opens to a VF page. I added this button to the related list of object B. When I clicked on this button from the page layout of object B, it loads up the VF page and this URL:

https://domain.salesforce.com/apex/VFPageName?retURL=%2FRECORD_ID&wrapMassAction=1&scontrolCaching=1&id=RECORD_ID

(where RECORD_ID is the actual record ID, a 15 digit ID)

So I'm writing some code to get the record ID from the URL, by doing ApexPages.currentPage().getParameters().get('Id')

My question is can I rely on this "ID" parameter, that it will always show up on the URL? Or should I rely on retURL? Thanks.

Hello,
I have a question scroll my text in a console button. Here are the details:

sforce.console.setCustomConsoleComponentButtonText("{!ScrolledText}", scrollButtonText);
function scrollButtonText() 
        {                   
            sforce.console.scrollCustomConsoleComponentButtonText(80, 15, true);
        }

This works fine and did scroll my {!ScrolledText} , BUT!!!! The problem is : it didn't scroll all the text....for example, my text is:
abc def ghi jkl mno pqr stu vwx yz.    It will scroll to jkl, then refresh...and start from abc again..

When I check the html code behind, I have something like
<button type="button" id="ext-gen201" class=" x-btn-text" style="background: red;">
<div class="sd_widget_btn_text" style="width:470px;">
<span class="sd_widget_btn_text_positioner" id="ext-gen212" style="position: relative; left: 114px;">URGENT test</span>
</div>
</button>

any ideas?!~
Hi everyone, I have a question here:
in my apex page, I have a search field, user can serch for sth dynamiclly by typing. Here is the two code I use:
<apex:inputText id="inputField" value="{!serchFieldValue}" onchange="!myFunction">
<apex:actionFunction name="myFunction" action="{!getResult}" focus = "inputField"/>

After do the action, I want it focus back on the input field, but not select the input already there.....User-added image  
the focus should on the place after b.......... any ideas ?~
I'm running into two problems on my search page.  Nothing is happening when I click the 'Reset' button and I am getting this error when I search using a date field: 

System.QueryException: expecting a colon, found '('
Error is in expression '{!searchEng}' in component <apex:commandButton> in page engagement_search: Class.Engagements_Search_Controller.searchEngagementss: line 94, column 1
Class.Engagements_Search_Controller.searchEng: line 26, column 1
Class.Engagements_Search_Controller.searchEngagementss: line 94, column 1
Class.Engagements_Search_Controller.searchEng: line 26, column 1

Here is my code:
public with sharing class Engagements_Search_Controller {
public Engagements__c eng{get;set;}
public List<Engagements__c> engagementList {get;set;}

// create a list of strings to hold the conditions
List<string> conditions = new List<string>();
private integer totalRecs = 0;
private integer OffsetSize = 0;
private integer LimitSize= 25;
public integer total_size; //used to show user the total size of the list
public Integer totalPages{get;set;}


public Engagements_Search_Controller(){
system.debug('==>Engagements_Search_Controller  is calling==>');
 eng = new Engagements__c();
 //engagementList  = new List<refount>();
}

public void searchEng(){
totalRecs = 0;
OffsetSize = 0;
if(engagementList !=null && engagementList.size()>0){
 engagementList=null;
}
searchEngagementss ();
conditions.clear();
}


public Void searchEngagementss(){

System.debug('Total Records is ==>'+totalRecs);
System.debug('OffsetSize is ==>'+OffsetSize);

if(engagementList != null && !engagementList.isEmpty()){
  engagementList.clear();
}
 String strQuery ='SELECT Name,Pending_Go_No_Go_Canceled__c,Additional_SIC_Sector__c, Additional_SIC_Industry__c,What_We_Found__c,What_We_Did__c, SIC_Final__c, Unit_Name__c, Company_Name__c, Ultimate_Parent_Company__c, Country__c, BR_Start_Date__c, Project_Start_Date__c,Scope_of_BR_Area__c,Scope_of_BR_Theme__c  From Engagements__c ';
 
 if(eng.Name !=null && eng.Name !=''){
   conditions.add('Name Like \'%' +eng.Name +'%\' ');
 }
 if(eng.Additional_SIC_Sector__c !=null && eng.Additional_SIC_Sector__c !=''){
    conditions.add('Additional_SIC_Sector__c Includes (\'' +eng.Additional_SIC_Sector__c +'\') ');
 }
 if(eng.Additional_SIC_Industry__c !=null && eng.Additional_SIC_Industry__c !=''){
    conditions.add('Additional_SIC_Industry__c Includes (\'' +eng.Additional_SIC_Industry__c +'\') ');
 }
  if(eng.Scope_of_BR_Area__c !=null && eng.Scope_of_BR_Area__c !=''){
    conditions.add('Scope_of_BR_Area__c Includes (\'' +eng.Scope_of_BR_Area__c +'\') ');
 }
 if(eng.Scope_of_BR_Theme__c !=null && eng.Scope_of_BR_Theme__c !=''){
    conditions.add('Scope_of_BR_Theme__c Includes (\'' +eng.Scope_of_BR_Theme__c +'\') ');
 }
 if(eng.SIC_Final__c !=null && eng.SIC_Final__c !=''){
   conditions.add('SIC_Final__c Like\'%' +eng.SIC_Final__c +'%\' ');
 }

if(eng.Unit_Name__c !=null && eng.Unit_Name__c !=''){
   conditions.add('Unit_Name__c Like\'%' +eng.Unit_Name__c +'%\' ');
 }
if(eng.Company_Name__c !=null && eng.Company_Name__c !=''){
   conditions.add('Company_Name__c Like\'%' +eng.Company_Name__c +'%\' ');
 }
 if(eng.Ultimate_Parent_Company__c !=null && eng.Ultimate_Parent_Company__c !=''){
   conditions.add('Ultimate_Parent_Company__c Like\'%' +eng.Ultimate_Parent_Company__c +'%\' ');
 }
 if(eng.Country__c !=null && eng.Country__c !=''){
   conditions.add('Country__c Like\'%' +eng.Country__c +'%\' ');
 }

 if(eng.BR_Start_Date__c !=null){
    conditions.add('BR_Start_Date__c Like (\'' +eng.BR_Start_Date__c +'\') ');
 }
 if(eng.Project_Start_Date__c !=null){
    conditions.add('Project_Start_Date__c Like (\'' +eng.Project_Start_Date__c +'\') ');
 }
if(eng.What_We_Found__c !=null && eng.What_We_Found__c !=''){
   conditions.add('What_We_Found__c Like\'%' +eng.What_We_Found__c +'%\' ');
 }
 if(eng.What_We_Did__c !=null && eng.What_We_Did__c !=''){
   conditions.add('What_We_Did__c Like\'%' +eng.What_We_Did__c +'%\' ');
 }
 
 

  if (conditions.size() > 0) {
   strQuery += '  WHERE ' + conditions[0];
   for (Integer i = 1; i < conditions.size(); i++)
            strQuery += '  AND ' + conditions[i];
  }
 if(totalRecs !=null && totalRecs ==0){
    List<Engagements__c> engTemp = Database.query(strQuery);
    totalRecs = (engTemp !=null &&engTemp.size()>0)?engTemp.size():0;
 }

 system.debug('strQuery ==>'+strQuery );
 // add sort and limits at the end  
  strQuery += ' ORDER BY Name  ASC, Unit_Name__c DESC LIMIT :LimitSize OFFSET :OffsetSize';
  
  engagementList  =Database.query(strQuery);
  
   

  //conditions.clear();
  //return engagementList.size();
}


public void FirstPage()
{
OffsetSize = 0;
searchEngagementss();
}
public void previous()
{
OffsetSize = (OffsetSize-LimitSize);
searchEngagementss();
}
public void next()
{
OffsetSize = OffsetSize + LimitSize;
searchEngagementss();
}
public void LastPage()
{
OffsetSize = totalrecs - math.mod(totalRecs,LimitSize);
searchEngagementss();
}
public boolean getprev()
{

if(OffsetSize == 0){

return true;
}
else {

return false;
}
}
public boolean getnxt()
{
if((OffsetSize + LimitSize) > totalRecs){

return true;
}
else {

return false;
}
}

 public Integer getTotal_size() {
      return totalRecs;
   }

   public Integer getPageNumber() {
      return OffsetSize/LimitSize + 1;
   }

   public Integer getTotalPages() {
      if (math.mod(totalRecs, LimitSize) > 0) {
         return totalRecs/LimitSize + 1;
      } else {
         return (totalRecs/LimitSize);
      }
   }


}
VF Page:
<apex:page controller="Engagements_Search_Controller" action="{!searchEng}" >
<script type="text/javascript">
    window.onload=function() {
    // document.getElementById("{!$Component.thePb.thepbs.engName}").focus();
    }   
</script>
 <apex:form >
  <apex:pageBlock id="thePb" title="Engagements Details To Search">
   <apex:pageblockSection id="thepbs" columns="3" collapsible="true">
    <apex:inputField value="{!eng.Name}" required="false" id="engName"/>
    <apex:inputfield value="{!eng.Company_Name__c}"/>
    <apex:inputfield value="{!eng.Ultimate_Parent_Company__c}"/>
    <apex:inputfield value="{!eng.Unit_Name__c}"/>
    <apex:inputfield value="{!eng.Country__c}"/>
    <apex:inputfield value="{!eng.SIC_Final__c}"/>
   </apex:pageblockSection>  
   <apex:pageblockSection >
     <apex:inputField value="{!eng.Scope_of_BR_Area__c}"/>
     <apex:inputfield value="{!eng.Scope_of_BR_Theme__c}"/>
     <apex:inputField value="{!eng.Additional_SIC_Sector__c}"/>
     <apex:inputfield value="{!eng.Additional_SIC_Industry__c}"/>
     <apex:inputfield value="{!eng.BR_Start_Date__c}"/>
     <apex:inputfield value="{!eng.Project_Start_Date__c}"/>
     <apex:inputfield value="{!eng.What_We_Found__c}" style="width:85%;"/>
     <apex:inputfield value="{!eng.What_We_Did__c}" style="width:85%;"/>
   </apex:pageblockSection>
   <apex:pageblockButtons location="bottom">
      <apex:commandButton value="Search"  action="{!searchEng}"/>
      <apex:commandButton value="Reset" status="idStatus" onclick="this.form.reset();return false;" />
     </apex:pageblockButtons>  
  </apex:pageBlock>
  
   <apex:pageBlock title="Engagements Details" id="noRec" rendered="{! IF( engagementList != null && engagementList.size ==0 , true, false)}" >
  <apex:outputPanel >
    <h1>No Records Found </h1>
</apex:outputPanel>
  </apex:pageBlock>

  
  <apex:pageBlock title="Engagements Details (Total List Size: {!total_size})" id="details" rendered="{! IF( engagementList != null && engagementList.size >0, true, false)}" >

   <apex:pageBlockTable value="{!engagementList}" var="a">
   <apex:column headerValue="Engagements Name">
    <apex:outputLink target="_blank" value="/{!a.id}">{!a.Name}</apex:outputLink> 
   </apex:column>   
    <!--  If you want facet style you can add like this.
   <apex:column >
     <apex:facet name="header">Link Name</apex:facet>
     <apex:outputLink target="_blank" value="/{!a.id}">{!a.Name}</apex:outputLink> 
    </apex:column>
    -->
    
    <apex:column value="{!a.Pending_Go_No_Go_Canceled__c}" headerValue="Pending/Go/No-Go/Canceled"/>
    <apex:column value="{!a.Additional_SIC_Sector__c}" headerValue="Additional SIC Sector"/>
    <apex:column value="{!a.Additional_SIC_Industry__c}" headerValue="Additional SIC Industry"/>
    <apex:column value="{!a.SIC_Final__c}" headerValue="SIC Final"/>
    <apex:column value="{!a.Unit_Name__c}" headerValue="Unit Name"/> 
    <apex:column value="{!a.Company_Name__c}" headerValue="Company Name"/>
    <apex:column value="{!a.Ultimate_Parent_Company__c}" headerValue="Ultimate Parent Company"/> 
    <apex:column value="{!a.Country__c}" headerValue="Country"/> 
    <apex:column value="{!a.BR_Start_Date__c}" headerValue="BR Start Date"/> 
    <apex:column value="{!a.Project_Start_Date__c}" headerValue="Project Start Date"/>
   
    
   </apex:pageBlockTable>
   
    <apex:pageblockButtons >
        <apex:commandButton value="First Page" rerender="details" action="{!FirstPage}" disabled="{!prev}"/>
        <apex:commandButton value="Previous" rerender="details" action="{!previous}" disabled="{!prev}"/>
        <apex:commandButton value="Next" rerender="details" action="{!next}" disabled="{!nxt}"/>
        <apex:commandButton value="Last Page" rerender="details" action="{!LastPage}" disabled="{!nxt}"/>
        <apex:facet name="footer">Showing Page # {!pageNumber} of {!totalPages}</apex:facet>
        
    </apex:pageblockButtons>
   
  </apex:pageBlock>

 </apex:form>
</apex:page>

 
trigger trgset on contact (after insert)
{
    List<Contact> conToUpdate = new List<Contact>() ;
     for(Account acc : [Select Name,(Select id ,LastName from Contacts where id in: trigger.new ) from Account  ] )
     {
         for(Contact con : acc.Contacts)
         {
             con.LastName = acc.Name ;
             conToUpdate.add(con) ;
         }
    }
    if(conTOUpdate.size() > 0)
    {
       update conTOUpdate ;
    }
}
 
Trigger Childtoconupdate on ChildtoContact__c(after insert)
{
	List<ChildtoContact__c> ctlist=new List<ChildtoContact__c>();
	for(contact con:[Select lastname,(select id,name from ChildtoContactsrelation__r where id in:trigger.new)
		from Contact])
	{
		for(ChildtoContact__c ct:con.ChildtoContactsrelation__r)
		{
			ct.name=con.LastName;
			ctlist.add(ct);
		}
	}
	if(ctlist.size()>0)
	{
		Update ctlist;
	}
}

 


Hi Team,

I want to send email to number of users, for this I am storing 'toaddress' in custom label.
here is the code,
List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();

        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

        List<String> sendTo = new List<String>();
        sendTo.add(Label.CommunityContact);
        mail.setToAddresses(sendTo);
        
        mail.setReplyTo('noreply@salesforce.com');
    
        List<String> ccTo = new List<String>();
        mail.setCcAddresses(ccTo);
        
        String Sub = 'Application Submitted for Group : ' + groupname;

        mail.setSubject(Sub);
        String body = 'An application for group membership has been submitted with the following information:<br />';
      
        body += '<p><b>Name</b>: ' + firstName + ' ' + lastName + '<br>';
        body += '<b>Company:</b> ' + company + '<br>';
        body += '<b>Address:</b> ' + streetAddress + ' ' + streetAddressLine2 + '<br>';
        body += '<b>City:</b> ' + city + '<br>';
        body += '<b>State/Province/Region:</b> ' + stateProvinceRegion + '<br>';
        body += '<b>Postal/Zip Code:</b> ' + postalZip + '<br>';
        body += '<b>Country:</b> ' + country + '<br>';
        body += '<b>Email:</b> ' + email + '<br>';
        body += '<b>Job Title:</b> ' + jobTitle + '<br>';
        body += '<b>Regional Account Manager Name:</b> ' + AMFirstName + ' ' + AMLastName + '<br>';
        body += '<b>Disributor:</b> ' + Dist + '<br></p>';
        
        mail.setHtmlBody(body);
    
        mails.add(mail);
        Messaging.sendEmail(mails);

I am getting test class error shown below:-

System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_EMAIL_ADDRESS, Email address is invalid: amit@abc.com;sudeep@abc.com: [toAddresses, amit@abc.com;sudeep@abc.com] 
Stack Trace: Class.GroupRegistrationController.registerUser: line 95, column 1 Class.GroupRegistrationControllerTest.testGroupRegistrationController: line 40, column 1


Please help me to resolve this issue.

Thanks,

 
Good day, 

I have a visual force page included with another two visual force pages using apex:include .

Example

Page A is the main page. Page B & Page C are included in Page A.  Page B has separate class and Page C has separate class. 

These 2 pages are  rendering on Page A using onselect function. Page B is default page on Page A. 

If  Page B has no data, i am displaying messages & also  if Page C has no data , i am displaying messages. 

Now my problem is , 

If Page B has data & Page C has no data messages are working fine. In vice versa also working fine.  But when these 2 pages has no data, then two pages messages diplaying on page A at time. 

My requirement is when we select page B , only page b messages should display, similarlly for page C also. 

Please help. 
I have code that creates CaseShare records for the case based on some criteria from another class.

The code that creates the CaseShare is called both on update and creation of the case. It works smoothly when the case is updated, but not when it's created. When attempting to debug my issue I got confused because the debug logs apparently showed that the records were being inserted. In fact, the debug logs show the same exact things for when the case is inserted (the DML doesn't work then) as when the case is updated (the DML does work then).

Here is the debug log for both when the case is created (DML doesn't work then) and when the case is updated (DML does work) line 55 is where my insert is happening:
USER_DEBUG|[54]|DEBUG|Value of csShareList: (CaseShare:{CaseAccessLevel=Edit, CaseId=500180000050EsoAAE, UserOrGroupId=005E0000004JDY4IAO}, CaseShare:{CaseAccessLevel=Edit, CaseId=500180000050EsoAAE, UserOrGroupId=005E0000000dNNWIA2}, CaseShare:{CaseAccessLevel=Edit, CaseId=500180000050EsoAAE, UserOrGroupId=005E0000000dBqjIAE}, CaseShare:{CaseAccessLevel=Edit, CaseId=500180000050EsoAAE, UserOrGroupId=005E0000005aSlXIAU})
00:53:58.516 (755158871)|SYSTEM_METHOD_EXIT|[54]|System.debug(ANY)
00:53:58.516 (755161876)|STATEMENT_EXECUTE|[55]
00:53:58.516 (755228490)|DML_BEGIN|[55]|Op:Insert|Type:CaseShare|Rows:4
00:53:58.516 (755248812)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:20
00:53:58.516 (825013969)|DML_END|[55]

Additionally, here's the code that does the insert:
if (!csShareList.isEmpty()){
                System.debug('Value of csShareList: ' + csShareList);
                insert (csShareList);
                
            }

 
I tried using the following code as a base and modifying the profile to userID, I am not getting emails, Please advice
 
List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage> ();

List<Profile> userProfile = [select id from profile where Name='System Administrator'];

// getting email template id

List<Id> emailTemplateId = [select id from EmailTemplate where DeveloperName='My_Email_Template'].id; 

for(User sysAdminUser :[Select id from user where ProfileID IN:userProfile]) {
 Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
 string body = 'Hi '+ sysAdminUser.LastName;
 mail.setSubject('Test Subject');
 
// assign user
 
mail.setTargetObjectId(sysAdminUser.Id); 
 mail.setSaveAsActivity(false);
 
//email template id
 
mail.setTemplateId(emailTemplateId); 
 
//this is used to merge field values in email template

 mail.setWhatId( [select id from Account limit 1].id ); 
 mails.add(mail);

}
Messaging.sendEmail(mails);

 
How do I send an email to the partner Queue members using Apex?  Every memeber of that queue should get an email that a lead has been assigned to their queue and other memebers from other queues should not get nay notifications
Hi,

   I wrote a trigger on quotelines to update fields in quote below is the trigger when am creating quotelines for the first time trigger is not working as expected but after than its working please suggest me what is the mistake in the logic or code which i have written please let me know. 
 
trigger GenQuoteApproval on QuoteLineItem (After Insert, After Update) {
  
  Decimal LineMaxDiscount;
  Decimal LineMaxACV;
  Decimal SubLineMaxDiscount;
  Decimal SubLineMaxACV;
  Decimal SerLineMaxDiscount;
  Decimal SerLineMaxACV;
  Map<ID, Quote> ParentQuote = new Map<ID, Quote>();
  String SALREPID;
  String MRGID;
  String SALID;
  String CFOID;
  String Level;
  Integer GSublevel1Count;
  Integer GSublevel2Count;
  Integer GSublevel3Count;
  Integer GSublevel4Count;
  Integer GSerlevel1Count;
  Integer GSerlevel2Count;
  Integer GSerlevel3Count;

 List<Id> listIds = new List<Id>();
 //Set<Id> listIds = new Set<Id>();

 List<Quote> QuotetList = new List<Quote>();

 /* Get Quote ID */
 for (QuoteLineItem childquoteline :  Trigger.new)
 {
        listIds.add(childquoteline.QuoteId);
    }

 ParentQuote = new Map<Id, Quote>([SELECT id,Level_1__c,Level_2__c,Level_3__c,Level_4__c FROM Quote WHERE ID IN :listIds]);

  /* Get service list of all quote id */
  list<id> serviceid = new list<id>();
  for(QuoteLineItem getserviceid : [select id  from  QuoteLineItem
                                     where quoteid in :listIds and
                                           product2.Productcode  like 'CBSVC%'] )
   {
      serviceid.add(getserviceid.id);

   }

  /* Get subscription list of all quote id */
  list<id> subscriptionid = new list<id>();
  for(QuoteLineItem getsubscriptionid : [select id  from  QuoteLineItem
                                     where quoteid in :listIds and
                                           Subscription_Terms__c <> 0] )
   {
      subscriptionid.add(getsubscriptionid.id);

   }

 /* Subscription Discount and ACV */
    List<AggregateResult> MaxSubscription = [select max(Discount_Percent__c) SubQuoteLineMaxDiscount,sum(f_ACV__c) SubQuoteLineMaxACV
                                                   from  QuoteLineItem
                                                   where quoteid in :listIds and Subscription_Terms__c <> 0 and
                                                         ID not in :serviceid
                                                 ];

  for (AggregateResult SubQuoteMaxDiscount : MaxSubscription)
  {
  SubLineMaxDiscount = (Decimal)SubQuoteMaxDiscount.get('SubQuoteLineMaxDiscount');
  SubLineMaxACV = (Decimal)SubQuoteMaxDiscount.get('SubQuoteLineMaxACV');
  }

   system.debug('Subscription Line Discount  :' + SubLineMaxDiscount);
   system.debug('Subscription Line ACV  :' + SubLineMaxACV);

   /* Service Discount and ACV */
  List<AggregateResult> MaxService = [select max(Discount_Percent__c) SerQuoteLineMaxDiscount,SUM(UnitPrice) SerQuoteLineMaxACV
                                      from  QuoteLineItem
                                      where quoteid in :listIds and product2.Productcode  like 'CBSVC%' and
                                            id not in :subscriptionid];

  for (AggregateResult SerQuoteMaxDiscount : MaxService)
  {
  SerLineMaxDiscount = (Decimal)SerQuoteMaxDiscount.get('SerQuoteLineMaxDiscount');
  SerLineMaxACV = (Decimal)SerQuoteMaxDiscount.get('SerQuoteLineMaxACV');
  }

   system.debug('Service Line Discount  :' + SerLineMaxDiscount);
   system.debug('Service Line ACV  :' + SerLineMaxACV);

  Quote Qot = [select id,OpportunityID
               from quote
               where
               id in :listIds];

  Opportunity Opp = [select Subscription_Term__c,ownerid
                    from opportunity
                    where
                    id = :Qot.OpportunityId];

  system.debug('Subscription Term  :' + Opp.Subscription_Term__c);

   User Usr = [select managerid from user where id = :opp.ownerid];

 /* Subscription Query to get level 1..4 values */
   if ( Opp.Subscription_Term__c != null &&
        SubLineMaxACV != null &&
        SubLineMaxDiscount != null)
   {
       GSublevel1Count = ApprovalUtils.SubLevel1(Opp.Subscription_Term__c , SubLineMaxACV , SubLineMaxDiscount);

       system.debug('Subscription Level1 :' + GSublevel1Count);

       GSublevel2Count = ApprovalUtils.SubLevel2(Opp.Subscription_Term__c , SubLineMaxACV , SubLineMaxDiscount);

       system.debug('Subscription Level2 :' + GSublevel2Count);

       GSublevel3Count = ApprovalUtils.SubLevel3(Opp.Subscription_Term__c , SubLineMaxACV , SubLineMaxDiscount);

       system.debug('Subscription Level3 :' + GSublevel3Count);

       GSublevel4Count = ApprovalUtils.SubLevel4(Opp.Subscription_Term__c , SubLineMaxACV , SubLineMaxDiscount);

       system.debug('Subscription Level4 :' + GSublevel4Count);

    If( GSublevel1Count >= 1  )
     {
      SALREPID = Opp.OwnerId;
      Level = '1sub';
      }   
     
    If (GSublevel2Count >= 1 )
    {
      SALREPID = NULL;
      MRGID = Usr.managerid;
      Level = '2sub';
    }
       
    If ( GSublevel3Count >= 1)
    {
    SALREPID = NULL;
    MRGID = Usr.managerid;
    SALID = '00580000007jaoA';
    Level = '3sub';
    }
       
    If ( GSublevel4Count >= 1 )
    {
    SALREPID = NULL;
    MRGID = Usr.managerid;
    SALID = '00580000007jaoA';
    CFOID = '00580000006HV0w';
    Level = '4sub';
    }       
   }

    /* Service Query to get level 1..4 values */
   if (SerLineMaxACV != null && SerLineMaxDiscount != null)
    {
       GSerlevel1Count = ApprovalUtils.SerLevel1(SerLineMaxACV,SerLineMaxDiscount);

       system.debug('Service Level1 :' + GSerlevel1Count);

        GSerlevel2Count = ApprovalUtils.SerLevel2(SerLineMaxACV,SerLineMaxDiscount);

       system.debug('Service Level2 :' + GSerlevel2Count);

        GSerlevel3Count = ApprovalUtils.SerLevel3(SerLineMaxACV,SerLineMaxDiscount);

       system.debug('Service Level3 :' + GSerlevel3Count);
        
   If(   GSerlevel1Count >= 1 )
   {
    SALREPID = Opp.OwnerId;
     Level = '1ser';
     system.debug('GSerlevel1Count :' + GSerlevel1Count);
   } 

   else If (GSerlevel2Count >= 1  )
   {
    SALREPID = NULL;
    MRGID = Usr.managerid;
    Level = '2ser';
   }
  
   else If ( GSerlevel3Count >= 1 )
  {
    SALREPID = NULL;
    MRGID = Usr.managerid;
    SALID = '00580000007jaoA';
    Level = '3ser';
   }    
  }

  
    //system.debug('Which Level :' + Level);
    system.debug('Sales Rep :' + SALREPID);
    system.debug('Manager :' + MRGID);
    system.debug('Sales Ops :' + SALID);
    system.debug('CEO CFO :'  + CFOID);

for (QuoteLineItem gqtl : Trigger.new)
 {
   Quote MyParentQuote = ParentQuote.get(gqtl.QuoteId);

    MyParentQuote.Test_Sudhir__c = String.valueOf(LineMaxDiscount);
    MyParentQuote.Test_Sudhir_ACV__c = String.valueOf(LineMaxACV);
    MyParentQuote.Level_1__c = SALREPID;
    MyParentQuote.Level_2__c=MRGID;
    MyParentQuote.Level_3__c=SALID;
    MyParentQuote.Level_4__c=CFOID;
    MyParentQuote.Test_Sudhir_Level__c=Level;
  }

  update ParentQuote.values();


}

Thanks
Sudhir
I have created the following dynamic picklist.
for(firepond__Configurable__c prod : [select id, name, firepond__Item_Id__r.name, firepond__Item_Id__c, firepond__Item_Id__r.Salesforce_Product__r.name, firepond__Item_Id__r.Salesforce_Product__r.id, firepond__Item_Id__r.firepond__Description__c, 
                                                                firepond__RecordType__c from firepond__Configurable__c where firepond__RecordType__c = 'Product'
                                                                and firepond__Item_Id__c<>'' and (Not firepond__Item_Id__r.name like '%Veryx%')]) {
                    
                    productNamesMap.put(prod.Id, prod.firepond__Item_Id__r.firepond__Description__c);
                    productIdsMap.put(prod.firepond__Item_Id__r.firepond__Description__c, prod.Id);
                    FPXProd.add(prod.firepond__Item_Id__r.Salesforce_Product__r.name);
                        }             
                    if(productNamesMap != null){
                    productNamesList = productNamesMap.values();
                    }

        for(Product2 prod : [ select id, name from product2 where not(name =:FPXprod)]){
                    productNamesList.add(prod.name);
                    produc
The end user can filter this picklist by typing keywords in the text field. If the end user selects a value without filtering the picklist, the system will not return the currect selected value. But if the user filters the picklist to a few values, they will recieve the selected value. Why does the size of the picklist affects whether the system will return the value the user selects?

Thanks,
ckellie
 
how to Stop sending multiple email to lead,contacts which are used in campaign
Hi everyone,

I am trying (through workflows) to update automatically a standard field name (Industry in the Account tab) when a specific Account Type Record value is chosen.
Is there any way to manage this without code?
How can i acces to the field names using Apex classes in triggers?


Thanks a lot,
Skender
Hello , 
I want to create an Apex trigger when I create a task, It updates a field in related case , and also when I close that task , It also modified that field, and since the related object for the task may be either opportunity or case, I don't know how to do that.
I need help please.

Thank you so much.
Hi All,

Unable to query the records using dynamic query. Can any one help me to solve the below query..
Here selectionApiname and SelectionFieldId's are dynamic variables. 

if(id!=null){
selectionApiname = 'Id';
SelectionFieldId = ''\''001..'\'''
}
else{
selectionApiname = 'Name';
SelectionFieldId = ''\''TestName'\''';
}
Please find the below code

Datetime createdstartdate =2015-01-10T12:00:00Z ;
DateTime createdenddate =2015-01-30T12:00:00Z ;
String selectionApiname = 'Id';
String SelectionFieldId = '001.....'

String accountRecords = 'select Id From account'
                              + 'where (createdDate >= '
                              +createdstartdate.format('yyyy-MM-dd') + 'T' +     createdstartdate.format('hh:mm:ss') +   'Z'
                              + ' and createdDate <='
                              +createdenddate.format('yyyy-MM-dd') + 'T' + createdenddate.format('hh:mm:ss') + 'Z'+')'
                              + ' or '+'('+selectionAPIName+ ' In '+selectionFieldid+')'
                              +'limit 10';
List<Account> acc = Database.query(accountRecords);
Hi all,

I am trying to add some text to a field by pulling it from its parent record using a Onclick Javascipt button. Getting the URL no longer exists on refresh. Note the button is a custom button called from a VF page use apex:commandbutton
 
{!REQUIRESCRIPT("/soap/ajax/33.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/33.0/apex.js")} 

var c = new sforce.SObject("Patient_Session__c"); 
c.id ="{!Patient_Session__c.Id}";
var pgn = "{!Patient__c.Patient_Progress_Note__c}";
c.Treatment_Notes__c = pgn;

sforce.connection.update([c]); 
window.location= '/{!Patient_Session__c.Id}';

 

Hallo,
i am new in apex and i am trying to make a trigger for lead that automatically converts Leads with custom field LeadSource__c ='WebFormToTest' to an account if it doesnt exist and add a contact to this account. The lead i get from WebToLead Form. Some how my code doesnt work. Can you help me?

Code
LeadSource is just text field.
Trigger:

trigger NewLeadToContact on Lead (before insert) {
    
    List<Lead> leads=new List<Lead>();
    
    for(Lead newLead:Trigger.new){
		leads.add(newLead);
	}
  
	System.debug(LeanToContactHelpClass.createContactFromLead(leads));
}
HelpClass:
public class LeanToContactHelpClass {
	public static Boolean createContactFromLead(List<Lead> tempLeadList){
		List<Contact> contacts=new List<Contact>();
		for(Lead tempLead:tempLeadList){
			String str= String.ValueOf(lead.LeadSource__c);
			//== is used because it is case insensetive
		if(str.equals('WebFormToTest')){
			Account newAccount=null;
			try{
				//Can be thrown a QueryException when query returns not only one object
				newAccount = [Select name,id from Account  where Name=:tempLead.Company];
			
				System.debug('Account with needed Company name was found');
				
				//Create new contact associated with this account
				contacts.add(createContactFromAccountId(newAccount.id,tempLead));
					
			}catch(QueryException e){
				System.debug('Duplicates or Nothing found. Many Accounts for one Company found.');
				
				//If account doesnt exist we create a new one
				System.debug('Account with name '+lead.Company+' does not exist.');
				newAccount=createAccountFromLead(tempLead);
				
				insert newAccount;
				
				System.debug('New account was created');
				
				//Create new contact associated with this account
				contacts.add(createContactFromAccountId(newAccount.id,tempLead));
			}
		}
	}
	try{
		Database.insert(contacts);
		return true;
	}catch (Exception e) {
      return false;
	}
}
	
	private static Contact createContactFromAccountId(String accountId,Lead tempLead){
		//AccountId is used for connection this contact to an account
		System.debug('New contact will be created');
		Contact newContact= new Contact(
					FirstName = tempLead.firstname,
					LastName = tempLead.lastname,
					AccountId = accountId,
					Email = tempLead.email,
					Title = tempLead.title,
					Phone = tempLead.Phone);
		return newContact;			
	}
	
	private static Account createAccountFromLead(Lead tempLead){
		System.debug('New account will be created');
		Account newAccount = new Account(Name=String.ValueOf(lead.company));
		
		return newAccount;
	}
}

 
So, I'm tasked with a project and need some general guidance. Basically, here is what I am trying to accomplish...

1. Our Org has a custom object that when created, I would like to fire off a trigger
2. The Trigger (or class that the trigger calls) would then find the subscriber (because they should already exist in Exact Target) and add that subscriber to an existing List in Exact Target. 

My question is... Can this be done with Apex code? I've read the documentation around adding subscribers to a list using the API but I haven't found any examples using APEX. I guess the other option would be to Invoke a Callout?

Thoughts? Thanks in advance for your time and effort.

Casey