• Bhanu Mahesh
  • SMARTIE
  • 1767 Points
  • Member since 2015

  • Chatter
    Feed
  • 57
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 1
    Questions
  • 224
    Replies
HI All,

 I am executing below code. 

global class CustomIterable implements Iterator<Object>{ 
   List<Account> accs {get; set;} 
   List<Object> listOfAccounts {get; set;}
   Integer i {get; set;} 
   global CustomIterable(){ 
       string s = '{"d":[{"Sede":"Crai","Cedi":"A.R.Ce.V","CodECR":"0010001","IDPV":1,"IDNielsen":"","CodAgente":"","RagSoc":"Punto vend. 1","PartitaIVA":""},{"Sede":"Crai","Cedi":"A.R.Ce.V","CodECR":"0010001","IDPV":1,"IDNielsen":"","CodAgente":"","RagSoc":"Punto vend. 1","PartitaIVA":""}]}';
       Map<String, Object> m = (Map<String, Object>) JSON.deserializeUntyped(s);
       List<Object> listOfAccounts = (List<Object>) m.get('d');
       System.debug('Size Of Account oBjects:' + listOfAccounts.size());
       accs = [SELECT id, name, numberofEmployees FROM Account LIMIT 10]; 
       //System.debug('size of Total Account List:' + accs.size());
       i = 0; 
   }   
   global boolean hasNext(){ 
       System.debug('Size of ListOfAccounts:' + listOfAccounts.size());
       if(i >= listOfAccounts.size()) 
           return false; 
       else 
           return true; 
   }    
   global Object next(){ 
       i=i+1; 
       return listOfAccounts[i-1]; 
   } 
}

I am getting the below error on line System.debug('Size of ListOfAccounts:' + listOfAccounts.size());
FATAL_ERROR System.NullPointerException: Attempt to de-reference a null object

I cab get the size of list listOfAccounts in cinstructor. However, I am getting the error on mentioned line.

Please help me resolve this query.

Thanks,
Nikhil Khandare
Hi all,

When I am closing the case, I want to create case comment for that particular case, when I am editing the same closed case I don’t want to create another case comment.

So, can you help me out to write trigger for this.
 
Hello,

I want to implement a functionality
Where on a button click Phone number field will eliminate non-numeric values
There are phone numbers like 030 / 3906 345-61 ,07272 / 7704 1245 O etc,I want to eliminate all non-numeric values in these numbers.
Any sample code snippet on this.

Thanks,
Tejas
I have a requirement. Contact related to activity, I need to pull his functional role ( custom field) on Activity page layout. So whenever I create an activity and relate with ant contact so his/her functional role should populate automatic.

Please help! How can I achieve it? I tried formula field but unable to get. I tried through trigger but it is not updating the field.
 
trigger updatefunctionalrole on Event (before insert, before update) {
// Create a map between the contact ID and its functional role value
Map<ID,String> confunrole = new Map<ID,String>();
List<Event> conEvents = new List<Event>();

// Loop through the triggered Events and add all of the contact IDs (for those associated with conortunities)
for (Event e : trigger.new) {
    // Only Events associated with contact
    if (e.whoID!= null && ((String)e.whoID).startsWith('003 ')) {
        // And only newly inserted events or those being reparented to an contact
        if (trigger.isInsert || (trigger.isUpdate && e.WhoID != trigger.oldMap.get(e.id).WhoID)) {
            confunrole.put(e.whoID,'');
            conEvents.add(e);
        }
    }
}
// Query the contact and add their functional role to the map
for (contact con : [SELECT Functional_Role__c FROM contact WHERE ID IN :confunrole.keySet()]) {
    confunrole.put(con.id,con.Functional_Role__c);
}
// Update the contact functional role field on the Event with the relevant value
for (Event e : conEvents) {
    e.contact_functional role__c = confunrole.get(e.whoID);
}
}

 
  Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger myruchika.contact caused an unexpected exception, contact your administrator: myruchika.contact: execution of AfterUpdate caused by: System.NullPointerException: Attempt to de-reference a null object: Class.myruchika.contact1.Managefeeonupdate: line 48, column 1



public void onafterupdate(list<contact>Triggernew,list<contact>Triggerold,map<ID,contact>Triggernewmap,map<ID,contact>Triggeroldmap)
{
  Managefeeonupdate(TriggerNew,Triggeroldmap);
}
void Managefeeonupdate(list<contact>Triggernew,Map<ID,contact>Triggeroldmap)
{
    set<ID> setAccID= New set<ID>();
    list<Account> lstAcc=New list<Account>();
    for(contact objC: TriggerNew)
    {
        if (objC.AccountId!=null && objC.myruchika__fee__c!=TriggeroldMap.get(objC.AccountID).myruchika__fee__c)
           {
           setAccID.Add(objC.AccountId);
           }
    }         
     if(setAccID.size()>0)
           {
               for(Account objA:[select ID,myruchika__totalfees__c,(select ID,myruchika__fee__c From contacts Where myruchika__fee__c!=null) From Account Where ID in :setAccID])
               {
                   
               
           Decimal amt=0;
           for(contact objC:objA.contacts)
           {
               amt += objC.myruchika__fee__c;
           }
         objA.myruchika__totalfees__c=amt;
               
           lstAcc.add(objA);
           }
           If(lstAcc.size()>0)
           {
               update lstAcc;
               
           }
}
Hi 
I am trying to display Opportunity records based on their picklist value either "Closed Won" or "Closed Lost".
Upon selecting the radio button A all "Closed won" opportunities should be displayed,similarly
Upon selecting the radio button B all "Closed Lost " opportunities should be displayed.
so, in order to achieve this ,do i need to create radio buttons on my object or is is possible without creating radio buttons on the object.
i am unable to add radio buttons to my vf page when it has a pageblock table,

below is my VF Page Code for the reference,
please help me with the controller if required.

VF page:

<apex:page standardcontroller="Opportunity" tabstyle="Opportunity">
  <Apex:form >
  <Apex:pageblock Title="Records">
  <Apex:PageBlockTable value="{!Opportunity}" var="O">
   <Apex:Column value="{!O.Name}"/>
   <Apex:Column value="{!O.StageName}"/>
   <Apex:Column value="{!O.Amount}"/> 
   </Apex:PageBlockTable>
  </Apex:pageblock>
  </Apex:form>
</apex:page> 

Thanks in advance
I am fairly new to writing triggers, so I took a shot at this one because I thought it would be pretty simple. I have looked a tons of example and can't seem to figure out what I am doing wrong. I would like to update base address information from a field called Metro Area when address is null. However I keep getting the error "Expression cannot be a statement at line 4 column 14".
Code is listed below:

trigger UpdateMailingAddressMetro on Contact (Before Insert, Before Update) {
    for(contact c: trigger.new){
        If(c.Metro_Area__c.contains('Houston') && (c.mailingcity == NULL) && (c.mailingstate == NULL) && (c.mailingpostalcode == NULL)){
            (c.mailingcity == 'Houston');
            (c.mailingstate == 'TX');
            (c.mailingpostalcode == '77001');
            (c.mailingcountry == 'United States');
                }else {
                    c.mailingstate == NULL;
                    }
        }
}
Hi,

I would like to know how I can retrieve a Case Object based on the Attachment Parent ID (Trigger). Been trying to do so but not making any progress. Would appreciate some advice on how I can go about doing so~!

Cheers
HI Experts,

i need to write a forumla like this, could you guys me shape for this please

IF Date Assessed/ Rejected = NULL AND If (Related) tRIIO_Application.Days Left for Approval <= 0 Then
Forecast D+12 = Today() 
IF Date Assessed/ Rejected = NULL AND If (Related) tRIIO_Application.Days Left for Approval > 0 THEN
( TODAY() + Application_Ref__r.Days_Left_for_Approval__c ))
ELSE
Forecast D+12 = Date Assessed/ Rejected,

 existing forumala: IF( Application_Ref__r.Days_Left_for_Approval__c >=0, TODAY() ,( TODAY() + Application_Ref__r.Days_Left_for_Approval__c ))

could any one tell me how to write for this , thanks in advance
I have created permission set for a user and assigned it.
The user does not have view all/,odify all for the object
When I see results on visualforce page , it brings back ll the records,
Cn you suggest a solution ?
Hi,

I have tried to create the tasks via Workflow in ( managed package object) this particular custom object  only not visible in action drop down. other objects having the task in workflow action drop down. Is any customization need to get this or any think else have to do. Guide me to solve this issue as earely as possible. 
 Thanks 
Maheshwar
Screen Shot: 
User-added image
I have a field on the product that I would like visible as quote line items are entered. Can someone please tell me what is wrong with my code below?
trigger UpdateFormulaFields on QuoteLineItem (before insert,before update) {

 set<id> PIds = new set<id>();
   for(QuoteLineItem qli : Trigger.new){
       PIds.add(qli.Product2Id);
   }
     list<Product2> pList = [select id, name , Cost_Price__c, Quantity_On_Hand__c, In_Stock_Pricing__c  from Product2 where Id IN : PIds];  
     for(Product2 p : pList){
      
         for(QuoteLineItem ql : Trigger.new){
             if(p.id == ql.product2Id){
                
                 if(Trigger.isInsert){
                     
                 	ql.Cost_Price__c = p.Cost_Price__c;
                    ql.Quantity_On_Hand__c = p.Quantity_On_Hand__c;
                    ql.In_Stock_Price2__c = p.In_Stock_Pricing__c;
             	
                 }
                 if(Trigger.isUpdate){
                                     
                    ql.Cost_Price__c = p.Cost_Price__c;
                    ql.Quantity_On_Hand__c = p.Quantity_On_Hand__c;
                    ql.In_Stock_Price2__c = p.In_Stock_Pricing__c;
                     
                 }
             }
             
       }
    }
    update pList;
  
}
Hi all i want a trigger if i change owner of a particular record then we need to notify all the record owners of that object records if any one helps i am very thankfull you
I'm open to using either a trigger or Flow. I've been trying to do it as a Flow, but I'm getting stuck on getting it to loop through everything and can only get it to create a Demographic for the first Qualification in the list. I'm sure it's something in how to set the Loop and Assign. But I'm more familiar with Apex triggers, so I'm happy to go back to that.

This scenario uses 3 objects: Opportunity, Qualification, and Demographic. 
  • Qualifications have a picklist field called Default_Country__c
  • On Opportunities, the user selects their country from a picklist field Country__c
  • Demographics have a lookup to both Qualification and Opportunity.
I want when an Opportunity is created, for any Qualifications where Default_Country__c matches the Opportunity__c, a Demographic is created. My brain is a bit fried on this so I could use a bit of guidance. 

Thanks!
Hi,

I am getting the above error after cllicking on the (C2F) button. The debug logs are showing "successful" callout to webservice.


Apex Class from WSDL
 
//Generated by wsdl2apex

public class TmpCnv {
    public class FahrenheitToCelsiusResponse_element {
        public String FahrenheitToCelsiusResult;
        private String[] FahrenheitToCelsiusResult_type_info = new String[]{'FahrenheitToCelsiusResult','http://www.w3schools.com/webservices/',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://www.w3schools.com/webservices/','true','false'};
        private String[] field_order_type_info = new String[]{'FahrenheitToCelsiusResult'};
    }
    public class CelsiusToFahrenheitResponse_element {
        public String CelsiusToFahrenheitResult;
        private String[] CelsiusToFahrenheitResult_type_info = new String[]{'CelsiusToFahrenheitResult','http://www.w3schools.com/webservices/',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://www.w3schools.com/webservices/','true','false'};
        private String[] field_order_type_info = new String[]{'CelsiusToFahrenheitResult'};
    }
    public class FahrenheitToCelsius_element {
        public String Fahrenheit;
        private String[] Fahrenheit_type_info = new String[]{'Fahrenheit','http://www.w3schools.com/webservices/',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://www.w3schools.com/webservices/','true','false'};
        private String[] field_order_type_info = new String[]{'Fahrenheit'};
    }
    public class CelsiusToFahrenheit_element {
        public String Celsius;
        private String[] Celsius_type_info = new String[]{'Celsius','http://www.w3schools.com/webservices/',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://www.w3schools.com/webservices/','true','false'};
        private String[] field_order_type_info = new String[]{'Celsius'};
    }
    public class TempConvertSoap {
        public String endpoint_x = 'http://www.w3schools.com/webservices/tempconvert.asmx';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x;
        private String[] ns_map_type_info = new String[]{'http://www.w3schools.com/webservices/', 'TmpCnv'};
        public String FahrenheitToCelsius(String Fahrenheit) {
            TmpCnv.FahrenheitToCelsius_element request_x = new TmpCnv.FahrenheitToCelsius_element();
            request_x.Fahrenheit = Fahrenheit;
            TmpCnv.FahrenheitToCelsiusResponse_element response_x;
            Map<String, TmpCnv.FahrenheitToCelsiusResponse_element> response_map_x = new Map<String, TmpCnv.FahrenheitToCelsiusResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://www.w3schools.com/webservices/FahrenheitToCelsius',
              'http://www.w3schools.com/webservices/',
              'FahrenheitToCelsius',
              'http://www.w3schools.com/webservices/',
              'FahrenheitToCelsiusResponse',
              'TmpCnv.FahrenheitToCelsiusResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.FahrenheitToCelsiusResult;
        }
        public String CelsiusToFahrenheit(String Celsius) {
            TmpCnv.CelsiusToFahrenheit_element request_x = new TmpCnv.CelsiusToFahrenheit_element();
            request_x.Celsius = Celsius;
            TmpCnv.CelsiusToFahrenheitResponse_element response_x;
            Map<String, TmpCnv.CelsiusToFahrenheitResponse_element> response_map_x = new Map<String, TmpCnv.CelsiusToFahrenheitResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://www.w3schools.com/webservices/CelsiusToFahrenheit',
              'http://www.w3schools.com/webservices/',
              'CelsiusToFahrenheit',
              'http://www.w3schools.com/webservices/',
              'CelsiusToFahrenheitResponse',
              'TmpCnv.CelsiusToFahrenheitResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.CelsiusToFahrenheitResult;
        }
    }
}

VisualForce Controller
public class TmpCntrl {

    Public String Celsius{get;set;}
    Public String Fahrenheit{get;set;}
    Public String FResult{get;set;}
    Public String CResult{get;set;}
    
    PageReference pageRef = ApexPages.currentPage();
    TmpCnv.TempConvertSoap TC = new TmpCnv.TempConvertSoap();
      
    public string FCalculate() {
        FResult = TC.CelsiusToFahrenheit(Celsius);
        return null;
    }
    
    public String CCalculate() {
        CResult = TC.FahrenheitToCelsius(Fahrenheit);
        return null;
    }
}

VisualForce Page
<apex:page controller="TmpCntrl">
    <apex:form >
        <apex:inputText value="{!Celsius}"/>
          <p>{!FResult}</p> 
        <apex:commandButton value="C2F" action="{!FCalculate}" rerender="all" >
            <apex:param name="Celsius" value="{!Celsius}" assignTo="{!FResult}"/>
        </apex:commandButton>
    </apex:form>
</apex:page>
Please give me some light.

Thanks.
Hi.

I would like to create a new field in the task that contain an information already present in the case.
For example: I would lile to add in the task view the case record type.

I can creat a customized field in the task but I am not able to relate this field with the Case record type.

I think is not so hard but I am a principiant :(

Thanks!!
Hi Team,

We are facing an issue with a date field in Salesforce. The complete object is populated by a batch job by reading a csv file.  The object has few date fields. One of the date fields is populating incorrectly. That is always populating as one day less than the actual date supplied, where as remainign all the fields are getting populating correctly. 

I've verified the success file that generated after the upsert operation by job and observed that the success file also contains the date supplied in source csv file. Not sure where the problem is? Could someone help in resolving this issue.  There is no trigger associated with that field as as well.

Please let us know for any more details. 

Thanks, 
Kishore
RWE Npower