• Raj.ax1558
  • NEWBIE
  • 60 Points
  • Member since 2012

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 44
    Replies

trigger eee on Contact (before insert, after update) {
            
        boolean b1 = false;
        public list<Contact> allstatuses = new List<Contact>();
        public list<string> adds = new List<string>();
        public Set<id> cidd = new Set<id>();
        public List<string> allstats = new List<string>();

                        allstats.add('A');
                        allstats.add('B ');
                                         

 for(Contact c: Trigger.New) {
 
        cidd.add(c.AccountId);
    }
    

     
    
      allstatuses  = ([Select c.CrowdTorch_Contact_Status__c From Contact c where id in : cidd]);
     
         for(String c1 : allstats)
         
         {
                 
         for(contact cc : allstatuses)
     
         {
            
                       
         if(c1  == cc.CrowdTorch_Contact_Status__c)
         adds.add(c1);     
         b1 =  true;
         break;
         
        }
         if(b1 == true)
         {
         break;          
         }
       
      }
      public list<Account> a1 = new List<Account>([select a1.id, a1.CT_Account_Status__c from Account a1]);
      
        for(Account aa : a1)
        
        {
        
        aa.CT_Account_Status__c = adds.get[0]; //System.ListException: List index out of bounds
        
        }
   
   }

Hi All,

 

<apex:image url="{!$Resource.Google}" width="180" height="180"/>

 

 

Thanks,

Chenna--India

I am working on customer portal, I am facing a problem which is explained as below -

 

Problem: I need to access CategoryNode on customer portal. CategoryNode is related to Solution Standard Object. Salesforce provides access of solution fields on Customer Portal but CategoryNode can't be access (according to this: http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_categorynode.htm ).

 

Please give me a way for access CategoryNode on customer portal

 

Regards -

Raj Jha 

 

 

Having an issue when adding product to an opportunity in the portal.  I have 2 input fields that are not displaying after I do an item selection.  These fields are visible if I am performing the same action from my base org.  We are just now preparing to turn on portal users, and this is a major issue for them being able to successfully enter a complete opportunity.  They can add the product without all the information, then edit the line item and enter the missing information.  I have checked the field level security for the profile, and all the fields are visible and not read-only.  This is not a formula field.

 

I am trying update a field on a on an account record from a value on a child record.  Normally I would use a Roll Up summary field, but my Child record criteria field is a formula field and I cannot use a formula field as a roll up summary criteria.

 

My scenario is this.  On the account field I have a field :  "number of lives", a simple numeric field.  The then have a child object that have pricing values depending on the # of lives from the parent account.  Each Child record has a Min # of Lives Field and a Max # of Lives Field and if the Account.number of lives falls between the two, a formula field on the Pricing record returns a value of true.  

 

Whichever record has the true value, I want to return the Pricing__c.Total__c to the Account.Total_Price__c field.  Since the Number of lives updates on the Account record, I built the trigger on the account record:

 

trigger UpdatePricing on Account (before update) {
For (Account acct:Trigger.new){

String AcctId = acct.id;

List<Account> AccountToUpdate = new List<Account>();

For(Pricing__c pri: [Select id, Total__c from Pricing__c where Account__c =: acctid 
                                                         and Active__c = 'True' ]){

//AccountToUpdate.Total_Price__c = pri.total__c;
	Update AccountToUpdate;                         
}
}
}

But I can not for the life of me figure out how to make this work.  This is one of the error messages I am getting:

Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger UpdatePricing caused an unexpected exception, contact your administrator: UpdatePricing: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 001i000000Crwx6AAB; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = 001i000000Crwx6) is currently in trigger UpdatePricing, therefore it cannot recursively update itself: []: Trigger.UpdatePricing: line 10, column 1

 

Any help would be greatly appreciate.  

 

Hi,

How would I write a try catch that needs to catch a custom exception that happens down stream from within a class method that I am calling?

 

For example, my called class would be something like this...

 

try {

  calledClass.mymethod;

catch ( ??THIS NEEDS TO TRAPPED THE CALLED CLASS CUSTOM EXCEPTION?? e) {

   ??HERE I WOULD LIKE A USER FRIENDLY MESSAGE??

catch (System.Exception e) {

   String FatalError = 'Whatever I want the user to see on the visualforce page';

   ApexPages.addmessage( new ApexPages.message(ApexPages.severity.FATAL, FatalError);

}

 

 

 

public  Calledclass {

   ...

   class CalledclassException extends Exception {}

   ...

   ...

   public myMethod {

      ...

      ...

      if ( some condition ) {

         throw new CallingClassException('ERROR IN CalledClass');

      }

   }

}

 

Hi All, 

I want to split a string based on the character on the string lets say(B, and F)

for example i want to break the string "B001B0002B000005F0006" to a string array like  this {"B001", "B0002", "B000005", "F0006" }

 

how can i do this

Hi i am having a custom button "convert" once i click convert if the record exists it must must show that the account already exists. This convert button is similar as lead convert button.

Thanks ,

Regards,

Lavanya.

 

Hi,

 

I have a History Object with createdDate as DateTime data type which is in this format 2005-10-08T01:02:03Z

Now my requirement is that i need to get the current time with date in the format 2005-10-08T01:02:03Z and pass it on to the SOQL.

 

I have tried to dynamically get the current DataTime as shown below

 String str = DateTime.now().format('yyyy-MM-dd\'T\'hh:mm:ss\'z\'');

 

but the problem is that i cannot assign this string to my created datatime as shown below

SELECT Id
FROM Account
WHERE CreatedDate =: str

 

I have tried to print DateTime.now(), System.now() in the console but they all throw the output in this fashion - YYYY:MM:DD HH:mm::SS. 

 

Can i please know how do i resolve this or is there any function which can directly fetch me datetime in this format 2005-10-08T01:02:03Z.

 

Appretiate your help.

 

Thanks,

Hemanth

Helo All,

I would like to know if there's way to load Home Page Components in the Standard Console Tab's sidebar?

As far as we know, the console tab's side bar display only the 'Recent Items' & 'Recycle' standard components.

 

Basically, we have some HTML Home Page Component (Narrow) that run in every salesforce pages - BUT for pages such as the console we're not able to generate the JS file / HTML code in the component as SF not loading it.

 

As far as I know in the Service Console Tab it's a bit different situation as we can develop specific custom home page component, but our questions refers to the regular console tab.

 

Thanks in advance,

 

  • April 09, 2013
  • Like
  • 0

public class AutoDeleteSubscriptions2
{
public List<User> usr ;
public List<EntitySubscription> es ;
public Map<String,ID> m1 = new Map<String,ID>();
public Map<String,ID> m2 = new Map<String,ID>();

public List<EntitySubscription> es1;

public List<Group> grp ;
public void deleteSubscriptions()
{
usr = [SELECT Id FROM User];
es = [SELECT Id,SubscriberId FROM EntitySubscription];

grp = [SELECT Id FROM Group];

System.debug('************GRoup****************'+grp);

System.debug(' Entity Subscription size : '+es.size()+' User Size : '+ usr.size());

for(User u : usr)
{
m1.put(u.Id,u.Id);
}
System.debug('***********User Ids**********'+m1.values()+'*****Map Size****'+m1.size());

System.debug(' Entity Subscription size : '+es.size());

for (EntitySubscription e : es)
{
m2.put(e.SubscriberId,e.SubscriberId);
}

System.debug('*************Entity Subscription User Ids***********'+m2.values()+'*****Map Size****'+m2.size());
// Comparing two map values
Set<String> ls = m1.keySet();

Set<String> ls1 = m2.keySet();
System.debug('**************List Elements*****************'+ls.size()+'*************'+ls1.size());

for (Id i :ls)
{
for ( Id j : ls1)
{
System.debug(' I = '+i +' J = '+j);
if ( i == j)
{
System.debug(' Both are equal ' + i +'***************** '+ j);
List<EntitySubscription> es = [select Id from EntitySubscription where SubscriberId =: j]; //50th line
System.debug('**************************List Size ***********************'+es.size());

if(es.size() > 490)
{
es1 = [select Id from EntitySubscription where SubscriberId =: j and ParentId NOT IN :usr order by CreatedDate limit 25];
delete es1;
}
}
}
}
}
}

 

I am moving this class to production am getting the following error "System.LimitException"  Too Many SOQL Queries 101.

Class.AutoDeleteSubscriptions2.deleteSubscriptions:line 50,column 1

  • April 09, 2013
  • Like
  • 0

I have a validation rule on lead object which is for our users to set them as owner for the lead.i written a trigger on task object to update the lead fields with task fields here i'm getting an error

 

activitycall2:execution of AfterInsert caused by: System.DmlException: Update failed. First exception on row 0 with id 00QE000000ExKxvMAF; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION.

 

how can i make my trigger free form this validation rule through Apex.

Hi I am having a custom button"Convert", I need to disable this button once it has clicked. Kindly anyone tell how resolve this either by apex code & Visualforce code. Kindly reply me to resolve this issue.

 

Thanks ,

Regards,

Lavanya.

trigger eee on Contact (before insert, after update) {
            
        boolean b1 = false;
        public list<Contact> allstatuses = new List<Contact>();
        public list<string> adds = new List<string>();
        public Set<id> cidd = new Set<id>();
        public List<string> allstats = new List<string>();

                        allstats.add('A');
                        allstats.add('B ');
                                         

 for(Contact c: Trigger.New) {
 
        cidd.add(c.AccountId);
    }
    

     
    
      allstatuses  = ([Select c.CrowdTorch_Contact_Status__c From Contact c where id in : cidd]);
     
         for(String c1 : allstats)
         
         {
                 
         for(contact cc : allstatuses)
     
         {
            
                       
         if(c1  == cc.CrowdTorch_Contact_Status__c)
         adds.add(c1);     
         b1 =  true;
         break;
         
        }
         if(b1 == true)
         {
         break;          
         }
       
      }
      public list<Account> a1 = new List<Account>([select a1.id, a1.CT_Account_Status__c from Account a1]);
      
        for(Account aa : a1)
        
        {
        
        aa.CT_Account_Status__c = adds.get[0]; //System.ListException: List index out of bounds
        
        }
   
   }

Bonojur,

 

I am getting some content from an external webservice and trying to display as a pdf file.

 

As a response I am getting a String and I have decoded the string using EncodingUtil.base64Decode(response) and assigned it to a blob variable.

 

Now I am trying to print that blob variable in vf page using renderAs pdf and instead of rendering as pdf it is displaying in bytes as core.filemanager.byteblobvalue@23F6123c

 

I have tried using Blob.toPdf() and Blob.valueOf() to get a pdf output.

And also I dont want to save it as an attachment in salesforce..because it may create excess attachments.

Saving as an attachment is working fine and displaying as pdf.

 

Any suggestions would be appreciated!!!!

 

Thanks,

Rajj

 

 

 

 

 

 

 

  • April 08, 2013
  • Like
  • 0

Hello Friends,

I am  having partner portal.In sales force i have created two lead layout. just say A and B.   A is for salesforce crm and B is for partner portal.When i am creating the lead from salesforce it is auto matically taking lead record type A. But when i am creating the lead from partner portal  i have to select record type from the picklist.
I dont want the record type picklist  or just default value B(not editable) .


How can i do the same????????


Thanks

  • April 05, 2013
  • Like
  • 0

hi

I created vf page

i have some opportunities,

opportunity names are command links

in the click of opportunity name am poupalting the related objects records

when i click the opportunity name i want highlight the row

how can i do it

i use some jquerys but it applying for entire pagebloc table

i want highlight only selected opprtunity name

 

here is the my code can any one tel  me where am doing mistake.

 

 

<style>
datahighlight {
       background-color:pink !important;
}

</style>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  <script>
 $(document).ready(function(){
        $('.dataRow').click(function(){
           $(".dataRow").removeClass('datahighlight');
           $(this).addClass('datahighlight');
        });
      });

  </script>
     
             <apex:pageBlock mode="inlineEdit"  rowClasses="datahighlight">
            
                         <apex:pageBlockTable value="{!opp}" var="op">
                            <apex:column headerValue="Opportunity Name">
                             <apex:outputPanel >
                             <apex:commandLink action="{!request}" value="{!op.name}" >
                             <apex:param value="{!op.id}" name="abc" ></apex:param>
                             </apex:commandLink>
                             </apex:outputPanel>
                             </apex:column>
                             <apex:column headerValue="Company Name">
                            <apex:outputField value="{!op.AccountId}">
                            <apex:inlineEditSupport showOnEdit="saveButton, cancelButton"  
                hideOnEdit="editButton" event="ondblclick"  
                    changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
                    </apex:outputField>
                            </apex:column>
                             <                      
                     </apex:pageBlockTable>
           </apex:pageBlock>

 

Can any one help me.

 

Regards

venky.

Apex Test Result Detail  

Time Started 4/4/2013 1:28 PM Class QuoteManager_Test Method Name invokeTestMethod Pass/Fail Fail Error Message System.NullPointerException: Attempt to de-reference a null object Stack Trace Class.QuoteManager.updatePartnerCBMDetails: line 43, column 1
Class.QuoteManager_Test.invokeTestMethod: line 41, column 1

 

Please advice me what should I do to successfully run my test case.

===================================================================================

public with sharing class QuoteManager {

  /* REPLACES trigger QuoteFieldUpdates on Quote__c (before insert, before update)*/
  
   private static List<Opportunity> OppList;

    public static List<Opportunity> getOppISVTeamMembersDetails(Set<Id> opportunityIds)
    {
        if (OppList == null){
            OppList = [SELECT Partner_CBM__c, End_User_Account_Owner__c FROM Opportunity WHERE Id in:opportunityIds];
        }
        return OppList;
    }
    
    private static List<Quote_Part__c > QuotePartsList;

    public static List<Quote_Part__c> getQuotePartsDetails(Set<Id> requiredQuoteIDs)
    {
        if (QuotePartsList == null){
            QuotePartsList = [SELECT Product_Category__c, 
                              Margin_Percent__c,Product_Code__c, 
                              Quote_Ref__c,Margin_Net_Dollars__c,CurrencyISOCode 
                              FROM Quote_Part__c
                              WHERE Quote_Ref__c =: requiredQuoteIDs 
                              AND Product_Category__c != 'Multi Product Accessory' 
                              AND Product_Category__c != 'Media' 
                              AND Product_Category__c != 'Service' 
                              AND Product_Category__c != 'Software' 
                              AND Product_Category__c != 'ProductLinks' 
                              AND Product_Category__c != 'OEM' 
                              AND Margin_Net_Dollars__c != null
                              ORDER BY Margin_Net_Dollars__c];
        }
        return QuotePartsList;
    }
    
    public static void updatePartnerCBMDetails(List<Quote__C> newQuote)
    {
        Map<Id, Opportunity> oppMap = new Map<Id, Opportunity>();
        
        List<Opportunity> oppsData = new List<Opportunity>();
       
        Set<ID> opportunityIds = new Set<ID>();                            // this line I am getting an error while running the test case.
         
        if (trigger.isUpdate && !QuotePartManager.isInsert)
        {
            for (Quote__c quote :newQuote)
            {
            opportunityIds.add(quote.Opportunity_Name__c);
            }
            /*oppsData = [SELECT Partner_CBM__c, End_User_Account_Owner__c FROM Opportunity WHERE Id in :opportunityIds];*/
            oppsData =getOppISVTeamMembersDetails(opportunityIds);
            
            for(Opportunity opp : oppsData) {
            oppMap.put(opp.Id, opp);
            }  
        }
  
        for (Quote__c quote :newQuote)
        {
            if (trigger.isInsert)
            {
              quote.Owner_Lookup__c = quote.OwnerID;  
            }
            if (trigger.isUpdate)
            {
              if(quote.Owner_Lookup__c != quote.OwnerId)
              {
                quote.Owner_Lookup__c = quote.OwnerID;  
              }
              if(oppMap.get(quote.Opportunity_Name__c) != null)
              {
                if(oppMap.get(quote.Opportunity_Name__c).Partner_CBM__c != quote.Partner_CBM__c)
                {
                  quote.Partner_CBM__c = oppMap.get(quote.Opportunity_Name__c).Partner_CBM__c;  
                }
                if(oppMap.get(quote.Opportunity_Name__c).End_User_Account_Owner__c != quote.End_User_Account_Owner__c)
                {
                  quote.End_User_Account_Owner__c = oppMap.get(quote.Opportunity_Name__c).End_User_Account_Owner__c;  
                }
              }  
            }
    }
    }
    
  /* REPLACES trigger QuoteBeforeDelete on Quote__c (before delete)*/
    public static void QuoteBeforeDelete(List<Quote__c> oldQuotes)
    {
    for (Quote__c quote : oldQuotes)
    {
      if (quote.Main_Quote__c)
      {
        if(!Test.isRunningTest())
        {
          quote.addError('You cannot delete a Main Quote. Uncheck the Main Quote checkbox on the Quote prior to deleting.');
        }
      }
    }
    }

 
  /*
    
    REPLACES trigger populateMarginsFromQuoteParts on Quote__c (before update)
    Trigger to assign field values "Lowest_Margin_Percent__c" and "Highest_Margin_Net_Value__c" on EDIT of a Quote:
    IF(Quote__c.Quote_Type__c EQUALS 'Hardware' AND PE.Approval_Stage__c EQUALS 'In Review') 
    ONE:
    o   Evaluate all HW Quote Parts WHERE Product_Category__c NOT EQUALS Media, Service, Software, ProductLinks, OEM:
    o   return item with lowest overall margin percentage (Margin_Percent__c)
    o   Capture that Item's corresponding Product_Code__c, Margin_Net_Dollars__c, and Margin_Percent__c into text field(s) on the Quote
    TWO:
    o   Evaluate all HW Quote Parts WHERE Product_Category__c NOT EQUALS Multi Product Accessory, Media, Service, Software, ProductLinks, OEM:
    o   return item with highest total margin dollar value (Margin_Net__Dollars__c) that has the lowest margin percentage (Margin_Percent__c)
    o   Capture that Item's corresponding Product_Code__c, Margin_Net_Dollars__c, and Margin_Percent__c into text field(s) on the Quote 
    
  */
  public static void populateMarginsFromQuoteParts(List<Quote__c> newQuotes)
  {
    /*Set of Quote IDs for which the Margins from Quote Parts should be calculated*/
    Set<Id> requiredQuoteIDs = new Set<Id>();
    Quote__c[] Quotes = new Quote__c[]{};
    for(Integer i=0; i < newQuotes.size(); i++)
    {
        if(newQuotes[i].HW_Approval_Stage__c == 'In Review')
        {
            system.debug('Approval is IN REVIEW');
            requiredQuoteIDs.add(newQuotes[i].Id);
            Quotes.add(newQuotes[i]);
        }
    }
    
    /*     
     Map of Quote ID and List of Quote Parts under that Quote - Lowest Margin Percent       
    */
    
    Map<Id,List<Quote_Part__c>> quotePartsMapLowestMarginPercent = new Map<Id,List<Quote_Part__c>>();
    
    /*    
    Map of Quote ID and List of Quote parts under that Quote - HIghest Margin Dollar Value    
    */
    
    Map<Id,List<Quote_Part__c>> quotePartsMapHighestMarginValue = new Map<Id,List<Quote_Part__c>>();
    
    /*    
    Query through all Line Items (WHERE Product_Category__c NOT EQUALS Media, 
    Service, Software, ProductLinks, OEM)    
    */
    if (!requiredQuoteIDs.isEmpty()){
      system.debug('requiredQuoteIDs contains ID');
      
    /*  
     FIRST ELEMENT --> LOWEST MARGIN PERCENT*
    */
    for(Quote_Part__c qpLi:getQuotePartsDetails(requiredQuoteIDs))
      {
          if(quotePartsMapLowestMarginPercent.get(qpLi.Quote_Ref__c) == null)
          {
              quotePartsMapLowestMarginPercent.put(qpLi.Quote_Ref__c, new List<Quote_Part__c>{ qpLi });
          }
          else
          {
              quotePartsMapLowestMarginPercent.get(qpLi.Quote_Ref__c).add(qpLi);
          }
          
      }
      system.debug('LowestMarginPercent map size is '+quotePartsMapLowestMarginPercent.size());
      /*
      Query through all Quote Parts (WHERE Product_Category__c NOT EQUALS Multi Product Accessory, Media, Service, Software, ProductLinks, OEM)
      */
     for(Quote_Part__c qpLi:getQuotePartsDetails(requiredQuoteIDs))
      {
          if(quotePartsMapHighestMarginValue.get(qpLi.Quote_Ref__c) == null)
          {
              quotePartsMapHighestMarginValue.put(qpLi.Quote_Ref__c, new List<Quote_Part__c>{ qpLi });
          }
          else
          {
              quotePartsMapHighestMarginValue.get(qpLi.Quote_Ref__c).add(qpLi);
          }
      }
      system.debug('HighestMarginValue map size is '+quotePartsMapHighestMarginValue.size());
    }
    /*Loop through Price Exceptions being updated and assign Value*/
    if (!Quotes.isEmpty())
    {
      system.debug('Quotes Loop begins');
      for(Quote__c Quote: Quotes)
      {
          if(quotePartsMapLowestMarginPercent.get(Quote.Id) != null && quotePartsMapLowestMarginPercent.get(Quote.Id).size() > 0)
          {
              system.debug('Lowest Percent Margin Percent is '+quotePartsMapLowestMarginPercent.get(Quote.Id)[0].Margin_Percent__c);
              String marginValueFormat = quotePartsMapLowestMarginPercent.get(Quote.Id)[0].Margin_Net_Dollars__c.format();
              system.debug('Lowest Percent marginNetDollars is '+quotePartsMapLowestMarginPercent.get(Quote.Id)[0].Margin_Net_Dollars__c.format());
              system.debug('Lowest Percent marginValueFormat is '+marginValueFormat);
              if(marginValueFormat.contains('.'))
              {
                  List<String> marginDecimals = marginValueFormat.split('\\.');
                  
                  if(marginDecimals.size() == 2)
                  {
                      if(marginDecimals[1].length() == 1)
                      {
                          marginValueFormat = marginValueFormat + '0';
                      }
                  }
              }
              else
              {
                  marginValueFormat = marginValueFormat + '.00';
              }
              
              String lowestMarginPercent = 'P/N ' + String.valueOf(quotePartsMapLowestMarginPercent.get(Quote.Id)[0].Product_Code__c) + 
                             ', Margin Value=' + quotePartsMapLowestMarginPercent.get(Quote.Id)[0].CurrencyISOCode + ' ' + marginValueFormat + 
                             ', Margin %=' + String.valueOf(quotePartsMapLowestMarginPercent.get(Quote.Id)[0].Margin_Percent__c);
              
              //Assign to Field
              Quote.Quote_Part_Lowest_Lowest_Margin__c = lowestMarginPercent;
          }
          
          if(quotePartsMapHighestMarginValue.get(Quote.Id) != null && quotePartsMapHighestMarginValue.get(Quote.Id).size() > 0)
          {
              Integer index = quotePartsMapHighestMarginValue.get(Quote.Id).size() - 1;
              
              String marginValueFormat = quotePartsMapHighestMarginValue.get(Quote.Id)[index].Margin_Net_Dollars__c.format();
              system.debug('Highest Value marginNetDollars is '+quotePartsMapHighestMarginValue.get(Quote.Id)[index].Margin_Net_Dollars__c.format());
              system.debug('Highest Value marginValueFormat is '+marginValueFormat);
              if(marginValueFormat.contains('.'))
              {
                  List<String> marginDecimals = marginValueFormat.split('\\.');
                  
                  if(marginDecimals.size() == 2)
                  {
                      if(marginDecimals[1].length() == 1)
                      {
                          marginValueFormat = marginValueFormat + '0';
                      }
                  }
              }
              else
              {
                  marginValueFormat = marginValueFormat + '.00';
              }
              
              String highestMarginValue = 'P/N ' + String.valueOf(quotePartsMapHighestMarginValue.get(Quote.Id)[index].Product_Code__c) + 
                            ', Margin Value=' + quotePartsMapHighestMarginValue.get(Quote.Id)[0].CurrencyISOCode + ' ' + marginValueFormat + 
                            ', Margin %=' + String.valueOf(quotePartsMapHighestMarginValue.get(Quote.Id)[index].Margin_Percent__c);
              
              //Assign to Field
              Quote.Quote_Part_Highest_Margin_Lowest_Marg__c = highestMarginValue;
          }
      }
    }
  }
}

 

 

===============================================================================

 

This is my test class

 

@isTest
public with sharing class QuoteManager_Test {
    
    static testMethod void invokeTestMethod()
    {
    List<Account> alist = TestUtil.createTestAccounts(1, true);
    
    List<Opportunity> olist = TestUtil.createTestOpportunities(1, true, alist.get(0));
    
    Quote__c quote = new Quote__c(Opportunity_Name__c = olist.get(0).Id,Multiple__c = 100,Discount__c = 0,
                              Valid_Until__c = system.today().addDays(28),Sync_Required__c=true,Is_Portal_Quote__c=true,
                              HW_Approval_Stage__c='In Review',
                              Main_Quote__c=true,Type__c='Master',Status__c='Live'); 
    List<Quote__c> quoteList = new List<Quote__c>();
    
    quoteList.add(quote);
    
    //QuoteManager.QuoteBeforeDelete(quoteList);
    
   QuoteManager.populateMarginsFromQuoteParts(quoteList);
   QuoteManager.QuoteBeforeDelete(quoteList);
    
   //Opportunity[] testopps = TestUtil.createTestOpportunities(1, false, testaccts.get(0));
      
     Opportunity[] testopps = TestUtil.createTestOpportunities(1, false, alist.get(0));
    for (Opportunity to : testOpps)
    {
        to.PR_Admin__c = alist.get(0).Id;
        to.OwnerId = UserInfo.getUserId();
        to.End_User_Location_RCSM__c = alist.get(0).Id;
        to.End_User_Location_RVP__c = alist.get(0).Id;
        to.End_User_Account_Owner__c = alist.get(0).Id;
        to.Partner_CBM__c = alist.get(0).Id;
        to.Partner_CBM_Manager__c = alist.get(0).Id;
    }
    
    if(quoteList.get(0).HW_Approval_Stage__c == 'In Review'){
    
    }
    
    QuoteManager.updatePartnerCBMDetails(quoteList);
    }
    
    static testMethod void testupdatePartnerCBMDetails(){
     
    }
}

 

==================================================================

 

staff,

I wish my Visualforce page was built according to the form elements. Show an accurate information block from a value of a field. I did so, but it does not work: (When passed a single parameter, it works, but as I used the formula OR, did not work)

 

<apex:pageBlockSection title="Produtos e Acessoria Técnica" columns="3" rendered="OR({!Pesquisa_de_mercado__c.Canal_de_Distribui_o__c == 'CONCRETEIRA'},{!Pesquisa_de_mercado__c.Canal_de_Distribui_o__c == 'INDUSTRIA'} )" >

 

 

Does anyone know a way to accomplish?

 

thank you

Please help me.I need to get the ids of the parend object with a condition in the grandchild object records.

 

note: We should use only one query(can have inner queries) and should not use maps and sets to first get the child records and then get the grandchild records.

 

Thank You 

I want to insert a record into a custom object when a TASK record is created.
Can we acheive this by a trigger ?

Hi All,

 

I have Visualforce Page to list the case and have function to send email with attachment below the cases but I got the error like this:

 

Attempt to de-reference a null object

Error is in expression '{!send}' in component <apex:page> in page sendemailpage
 
public class outboundMessage {
	
    public Id cid;
    public Contact contact;
    public list<Case> cases {get; set;}
    public String attId{get;set;}
    public String addresses{ get; set;}

    // Create a constructor that populates the Account object 
    
    public outboundMessage() {
    	cid = ApexPages.currentPage().getParameters().get('id');
    	getContact();
    	getCases();        
    }
	
    public void getContact() {
    	contact = [Select	Contact.Id,
				Contact.Name,
				Contact.FirstName,
				Contact.LastName,
				Contact.Phone,
				Contact.Email,
				Contact.MailingStreet,
   				Contact.MailingCity,
   				Contact.MailingState,
   				Contact.MailingPostalCode,
   				Contact.MailingCountry
   		    From	Contact
                    WHERE       Contact.Id = :cid];
    }
    
    public void getCases(){
    	if(cid != null){
    	cases = [Select	Case.Id,
			Case.CaseNumber,
			Case.Subject,
			Case.CreatedDate,
			Case.Description,
			Case.ClosedDate,
   			(SELECT	Attachment.Id, Attachment.Name	    					 
			FROM	Case.Attachments)
    		From	Case
    		Where	Case.ContactId = :cid];
    	}
    }
    
	public String attstrMessage{
        get{
             if(attstrMessage != null){
                return  attstrMessage;
              }else{
                  return '';
              }          
         }
          private set;
        } 
         
    public PageReference send() {
    	PageReference pageReference =  ApexPages.currentPage();        
    	try{
    	Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); 
        
        List<Messaging.EmailFileAttachment> efas = new List<Messaging.EmailFileAttachment>();
		
   	    for(Attachment a : [select	Attachment.Id,
   	    				Attachment.Name,  
   	    				Attachment.Body 
   	    			from 	Attachment 
   	    			where 	Attachment.Id = :attId]){
    	
	    	Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
	    	efa.setFileName(a.Name);
	    	efa.setBody(a.body);
			efas.add(efa);
   	   }
		
		String[] toAddresses = addresses.split(':', 0);	
		
        // Sets the paramaters of the email 
    
        email.setTargetObjectId(cid);        
        email.setSaveAsActivity(false);       
        email.setTemplateId('00X90000000fCao');
        email.setToAddresses( toAddresses );        
        email.setFileAttachments(efas);
		
	Messaging.SendEmailResult[] results = Messaging.sendEmail(new Messaging.SingleEmailMessage[] { email });
	        if (results[0].isSuccess()) {
	               if(efas.size() > 0){
	                    pageReference.getParameters().put('message',' Email has been resent successfully with attachments.');
	               }else{
	                pageReference.getParameters().put('message',' Email has been resent successfully .');
	               }
	               attstrMessage=''; 	                      
	         } else {
	             ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,  'Failed to resend Email.'));
	             pageReference.getParameters().put('messagefail',' Failed to resend Email.');
	         }
	         ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM,  'Email has been resent successfully '+attstrMessage+'.'));
		}catch(System.EmailException ex ){
             system.debug('============== email exception caught!!!============='+ex.getMessage());
              pageReference.getParameters().put('messagefail',' Failed to resend Email.');
              ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,  'Failed to resend Email.'));
        }
		return ApexPages.currentPage();
    }
}

 

 
<apex:page showHeader="false" standardStylesheets="false" sidebar="false" Controller="outboundMessage" >
<apex:messages />
	
	<apex:repeat value="{!cases}" var="c">
    	<ul class="your-docs docs">
        <li  class="your-doc doc">
           <h4 class="doc-title">
           	<apex:outputText value="{!c.CaseNumber}"/> <apex:outputText value="{!c.Subject}"/>&raquo;
           </h4>
           <div class="doc-desc">{!c.Description}</div>
		<div class="record" id="recordEmail">
			<div class="data-wrapper">
				<ul class="doc-operations">
				<li>Edit</li>
		               	<li class="operations"><a href="#">Email</a></li>
		               	<li>Print</li>
				</ul>
			</div>
			<div class="form-wrapper">
				<apex:form >
					<apex:outputLabel value="email" for="Addressed"/>:
					<apex:inputText value="{!addresses}" id="addresses" maxlength="80"/>			<apex:repeat value="{!c.Attachments}" var="att">							 
					attachment name: <apex:outputText value="{!att.name}"/>
					<div class="form-actions">
                        	            <button class="cancel">Cancel</button>
					    <apex:commandButton value="Send Email" action="{!send}" styleClass="button-medium">
					    <apex:param name="attSend" value="{!att.Id}" assignTo="{!attId}"></apex:param>	
					   </apex:commandButton>
		                        </div>
					</apex:repeat>	 
				    </apex:form>
				</div>
			</div>
		</li>
		</ul>
	</apex:repeat>	
</apex:page>

 

20.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO
15:31:42.014 (14629000)|EXECUTION_STARTED
15:31:42.014 (14672000)|CODE_UNIT_STARTED|[EXTERNAL]|06690000001qGv5|VF: /apex/sendEmailPage
15:31:42.014 (14890000)|VF_DESERIALIZE_VIEWSTATE_BEGIN|06690000001qGv5
15:31:42.029 (29723000)|VF_DESERIALIZE_VIEWSTATE_END
15:31:42.030 (30622000)|CODE_UNIT_STARTED|[EXTERNAL]|01p90000001ziVK|outboundMessage get(cases)
15:31:42.030 (30640000)|SYSTEM_MODE_ENTER|true
15:31:42.030 (30660000)|CODE_UNIT_STARTED|[EXTERNAL]|01p90000001ziVK|cases
15:31:42.030 (30697000)|METHOD_ENTRY|[1]|01p90000001ziVK|outboundMessage.outboundMessage()
15:31:42.030 (30794000)|METHOD_EXIT|[1]|outboundMessage
15:31:42.030 (30808000)|CODE_UNIT_FINISHED|cases
15:31:42.030 (30819000)|CODE_UNIT_FINISHED|outboundMessage get(cases)
15:31:42.037 (37406000)|CODE_UNIT_STARTED|[EXTERNAL]|01p90000001ziVK|outboundMessage invoke(send)
15:31:42.037 (37501000)|SYSTEM_METHOD_ENTRY|[60]|ApexPages.currentPage()
15:31:42.037 (37589000)|SYSTEM_METHOD_EXIT|[60]|ApexPages.currentPage()
15:31:42.038 (38499000)|SYSTEM_CONSTRUCTOR_ENTRY|[66]|<init>()
15:31:42.038 (38530000)|SYSTEM_CONSTRUCTOR_EXIT|[66]|<init>()
15:31:42.038 (38564000)|METHOD_ENTRY|[68]|01p90000001ziVK|outboundMessage.__sfdc_attId()
15:31:42.038 (38595000)|METHOD_EXIT|[68]|01p90000001ziVK|outboundMessage.__sfdc_attId()
15:31:42.038 (38890000)|SOQL_EXECUTE_BEGIN|[68]|Aggregations:0|select Attachment.Id, Attachment.Name, Attachment.Body from Attachment 
15:31:42.044 (44173000)|SOQL_EXECUTE_END|[68]|Rows:0
15:31:42.044 (44229000)|SYSTEM_METHOD_ENTRY|[68]|Database.QueryLocator.iterator()
15:31:42.044 (44327000)|SYSTEM_METHOD_ENTRY|[7]|QueryLocatorIterator.QueryLocatorIterator()
15:31:42.044 (44341000)|SYSTEM_METHOD_EXIT|[7]|QueryLocatorIterator
15:31:42.044 (44401000)|SYSTEM_METHOD_EXIT|[68]|Database.QueryLocator.iterator()
15:31:42.044 (44417000)|SYSTEM_METHOD_ENTRY|[68]|Database.QueryLocatorIterator.hasNext()
15:31:42.044 (44436000)|SYSTEM_METHOD_EXIT|[68]|Database.QueryLocatorIterator.hasNext()
15:31:42.044 (44453000)|METHOD_ENTRY|[80]|01p90000001ziVK|outboundMessage.__sfdc_addresses()
15:31:42.044 (44478000)|METHOD_EXIT|[80]|01p90000001ziVK|outboundMessage.__sfdc_addresses()
15:31:42.044 (44514000)|EXCEPTION_THROWN|[80]|System.NullPointerException: Attempt to de-reference a null object
15:31:42.046 (46629000)|FATAL_ERROR|System.NullPointerException: Attempt to de-reference a null object

Class.outboundMessage.send: line 80, column 1
15:31:42.046 (46641000)|CODE_UNIT_FINISHED|outboundMessage invoke(send)

 

Thank for any help ! ! !

 
 
 
 
 

Hi All,

 

I want to set the different color for the image when a button click. I tried using style/styleclass ,but the img color is not changing.

 

<apex:image id="ImgId" url="/servlet/servlet.FileDownload?file=01590000000xTAS" style="Color:black;background-color:black;" width="250" height="150"/>

 

pls help me out..

 

  • January 03, 2013
  • Like
  • 0