• force shahid
  • NEWBIE
  • 180 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 79
    Questions
  • 93
    Replies
Hi,
I am trying to download csv file from vf page. But it doesn't download properly.
1st row & 1st column are empty and date format is also chnaged. If field doesn't have value then next field value populate there. How can i  solve this ?

My VF apge:
<apex:page controller="OrderReport_Class" contentType="application/octet-stream#{!fileName}.csv"  cache="true" >
     Distributorcode,OrderNumber,EffectiveDate,Location,Profit
    <apex:repeat value="{!orditem}" var="item" >
        {!item.SBCF_Distributor_Code__c},{!item.order.OrderNumber},{!item.order.EffectiveDate},{!item.SBCF_Location__c},{!item.order.SBCF_ProfitCenter__c}
    </apex:repeat>
</apex:page>

My APex Class :
public class OrderReport_Class
{
    public list<Order> ord{set;get;}
    public list<Orderitem> orditem{set;get;}
    public date startdate{set;get;}
    public date startdate1{set;get;}
    public date enddate{set;get;}
    public date enddate1{set;get;}
    public string filename{set;get;}
    public string selectedorder{set;get;}
       
    public OrderReport_Class()
    {
        startdate = system.today();
        enddate = system.today();
        enddate1 = enddate+1;
        filename = 'OrderReport';
        oilist = new List<SelectOption>();
        CSVTab = 'OSO';
        system.debug('startdate:'+startdate);
        system.debug('enddate:'+enddate);
        system.debug('enddate1:'+enddate1);
        orditem = [select SBCF_Distributor_Code__c,SBCF_Location__c,SBCF_Fixture_Family__c,SBCF_FixtureCode__c,SBQQ__OrderedQuantity__c from orderitem where order.status = 'Activated' and order.ActivatedDate >: startdate and order.ActivatedDate <:enddate1];
           system.debug('orderitem'+orditem);
        
        
    }

Thanks in advance.
Hi,
I am trying to download csv file from vf page. But it doesn't download properly.
1st row & 1st column are empty and date format is also chnaged. If field doesn't have value then next field value populate there. How can i  solve this ?

Thanks in advance

My VF apge:
<apex:page controller="OrderReport_Class" contentType="application/octet-stream#{!fileName}.csv"  cache="true" >
     Distributorcode,OrderNumber,EffectiveDate,Location,Profit
    <apex:repeat value="{!orditem}" var="item" >
        {!item.SBCF_Distributor_Code__c},{!item.order.OrderNumber},{!item.order.EffectiveDate},{!item.SBCF_Location__c},{!item.order.SBCF_ProfitCenter__c}
    </apex:repeat>
</apex:page>

Apex class :
public class OrderReport_Class
{
    public list<Order> ord{set;get;}
    public list<Orderitem> orditem{set;get;}
    public date startdate{set;get;}
    public date enddate{set;get;}
    public date enddate1{set;get;}
    public string filename{set;get;}
    public string CSVTab{set;get;}
    public string selectedorder{set;get;}
    public list<string> selectedorderitem{set;get;}
    public  List<SelectOption> oilist {set;get;}
    
    public OrderReport_Class()
    {
        startdate = system.today();
        enddate = system.today();
        enddate1 = system.today()+1;
        filename = 'OrderReport';
        oilist = new List<SelectOption>();
        CSVTab = 'OSO';
        system.debug('startdate:'+startdate);
        system.debug('enddate:'+enddate);
        orditem = [select SBCF_Distributor_Code__c,SBCF_Location__c,SBCF_Fixture_Family__c,SBCF_FixtureCode__c,SBQQ__OrderedQuantity__c,UnitPrice,SBCF_Factory__c,order.EffectiveDate,order.SBCF_DiscountperlineItem__c,order.OrderNumber,order.SBCF_Tax_Code__c,order.SBCF_SpecAgencyCode__c ,order.SBCF_Terms_Code__c,order.SBCF_ShipVia__c,order.SBCF_FOB__c,order.SBCF_Freight__c,order.SBCF_PO_Number__c,order.SBCF_Estimated_Ship_Date__c,order.SBCF_JobNo__c,order.SBCF_Shipping_Instructions__c,order.AccountId,order.SBCF_BillToAttention__c,order.Billingcity,
                        order.BillingStateCode,order.BillingCountryCode,order.BillingPostalCode,order.ShipTo__c,order.SBCF_ShippingAttention__c,order.Shippingcity,order.ShippingStateCode,order.ShippingCountryCode,order.ShippingPostalCode,order.SBCF_Contact__c,order.SBCF_Account_No__c,order.SBCF_Phone__c,order.SBCF_Fax__c,order.SBCF_Email__c,order.OpportunityId,order.SBCF_SalesAgencyCode__c,order.SBCF_Comm_Split__c,order.SBCF_SpecComm__c
                        ,order.SBCF_SpecOvg8020__c,order.TotalAmount,order.SBCF_TotalOverage__c,order.SBCF_Unused1__c,order.SBCF_Ship_Date__c,order.SBQQ__Quote__c,order.SBCF_FreightAllow__c,order.SBCF_SpecOvg100__c,order.SBCF_SalesOvg100__c,order.SBCF_Unused2__c,order.SBCF_Unused3__c,order.SBCF_CSalesRepCode__c
                        ,order.SBCF_Unused4__c,order.SBCF_SalesRepComm__c,order.SBCF_Parts_Svc__c,order.SBCF_SalesOvg8020__c,order.SBCF_Use_Alt_Code__c,order.SBCF_Use_UPC_Code__c,order.SBCF_OrderedBy__c,order.SBCF_ProfitCenter__c from orderitem where order.status = 'Activated' and order.ActivatedDate>=:startdate and order.ActivatedDate <:enddate1];
           getactivatedorders();
        
    }
     public List<SelectOption> getactivatedorders () {
        List<SelectOption> options = new List<SelectOption>();
         list<order> ord =[select id,OrderNumber from Order where ActivatedDate>=:startdate and ActivatedDate <:enddate1 and status ='Activated'];
         options.add(new selectoption('None','None'));  
         for(order dc : ord)
        {
               options.add(new selectoption(dc.OrderNumber,dc.OrderNumber));
        }
       system.debug('options:'+options);
        return options;
    }
    Public pagereference orderitemlist() // Custom Picklist values for User Field based on Designation starts here
    {
        system.debug('In method');
        oilist.clear();
        oilist.add(new selectoption('All','All'));
           list<orderitem> oitemlist = [select order.OrderNumber,id,OrderItemNumber from orderitem where order.status = 'Activated' and order.ActivatedDate>=:startdate and order.ActivatedDate <:enddate1 and order.OrderNumber =:selectedorder];
        system.debug('OrderNumber:'+selectedorder);
        system.debug('oitemlist:'+oitemlist);
        for(orderitem o :oitemlist)
        {
                oilist.add(new selectoption(o.OrderItemNumber,o.OrderItemNumber));
        }
        system.debug('Order Items list:'+oilist);
        oidata();
        return null;
    }
    
    public void showdata()
    {
       // orditem = [select OrderItemNumber,SBCF_Distributor_Code__c,SBCF_Location__c,SBCF_Fixture_Family__c,SBCF_FixtureCode__c,SBQQ__OrderedQuantity__c,UnitPrice,SBQQ__TaxCode__c,SBCF_Factory__c,SBCF_TotalOverage__c,
        //           order.OrderNumber,order.EffectiveDate,order.SBCF_DiscountperlineItem__c from orderitem where order.status = 'Activated' and order.ActivatedDate>=:startdate and order.ActivatedDate <:enddate1 ];
            orditem = [select SBCF_Distributor_Code__c,SBCF_Location__c,SBCF_Fixture_Family__c,SBCF_FixtureCode__c,SBQQ__OrderedQuantity__c,UnitPrice,SBCF_Factory__c,order.EffectiveDate,order.SBCF_DiscountperlineItem__c,order.OrderNumber,order.SBCF_Tax_Code__c,order.SBCF_SpecAgencyCode__c ,order.SBCF_Terms_Code__c,order.SBCF_ShipVia__c,order.SBCF_FOB__c,order.SBCF_Freight__c,order.SBCF_PO_Number__c,order.SBCF_Estimated_Ship_Date__c,order.SBCF_JobNo__c,order.SBCF_Shipping_Instructions__c,order.AccountId,order.SBCF_BillToAttention__c,order.Billingcity,
                        order.BillingStateCode,order.BillingCountryCode,order.BillingPostalCode,order.ShipTo__c,order.SBCF_ShippingAttention__c,order.Shippingcity,order.ShippingStateCode,order.ShippingCountryCode,order.ShippingPostalCode,order.SBCF_Contact__c,order.SBCF_Account_No__c,order.SBCF_Phone__c,order.SBCF_Fax__c,order.SBCF_Email__c,order.OpportunityId,order.SBCF_SalesAgencyCode__c,order.SBCF_Comm_Split__c,order.SBCF_SpecComm__c
                        ,order.SBCF_SpecOvg8020__c,order.TotalAmount,order.SBCF_TotalOverage__c,order.SBCF_Unused1__c,order.SBCF_Ship_Date__c,order.SBQQ__Quote__c,order.SBCF_FreightAllow__c,order.SBCF_SpecOvg100__c,order.SBCF_SalesOvg100__c,order.SBCF_Unused2__c,order.SBCF_Unused3__c,order.SBCF_CSalesRepCode__c
                        ,order.SBCF_Unused4__c,order.SBCF_SalesRepComm__c,order.SBCF_Parts_Svc__c,order.SBCF_SalesOvg8020__c,order.SBCF_Use_Alt_Code__c,order.SBCF_Use_UPC_Code__c,order.SBCF_OrderedBy__c,order.SBCF_ProfitCenter__c from orderitem where order.status = 'Activated' and order.ActivatedDate>=:startdate and order.ActivatedDate <:enddate1 ];
        system.debug('Orditems:'+orditem.size());
        
    }
    public void oidata()
    {
        if(selectedorderitem.contains('All')==True)
        {
            system.debug('selectedorderitem:'+selectedorderitem);
            //orditem = [select OrderItemNumber,SBCF_Distributor_Code__c,SBCF_Location__c,SBCF_Fixture_Family__c,SBCF_FixtureCode__c,SBQQ__OrderedQuantity__c,UnitPrice,SBQQ__TaxCode__c,SBCF_Factory__c,SBCF_TotalOverage__c,
                      // order.OrderNumber,order.EffectiveDate,order.SBCF_DiscountperlineItem__c from orderitem where order.status = 'Activated' and order.ActivatedDate>=:startdate and order.ActivatedDate <:enddate1 and order.OrderNumber=:selectedorder];
            orditem = [select SBCF_Distributor_Code__c,SBCF_Location__c,SBCF_Fixture_Family__c,SBCF_FixtureCode__c,SBQQ__OrderedQuantity__c,UnitPrice,SBCF_Factory__c,order.EffectiveDate,order.SBCF_DiscountperlineItem__c,order.OrderNumber,order.SBCF_Tax_Code__c,order.SBCF_SpecAgencyCode__c ,order.SBCF_Terms_Code__c,order.SBCF_ShipVia__c,order.SBCF_FOB__c,order.SBCF_Freight__c,order.SBCF_PO_Number__c,order.SBCF_Estimated_Ship_Date__c,order.SBCF_JobNo__c,order.SBCF_Shipping_Instructions__c,order.AccountId,order.SBCF_BillToAttention__c,order.Billingcity,
                        order.BillingStateCode,order.BillingCountryCode,order.BillingPostalCode,order.ShipTo__c,order.SBCF_ShippingAttention__c,order.Shippingcity,order.ShippingStateCode,order.ShippingCountryCode,order.ShippingPostalCode,order.SBCF_Contact__c,order.SBCF_Account_No__c,order.SBCF_Phone__c,order.SBCF_Fax__c,order.SBCF_Email__c,order.OpportunityId,order.SBCF_SalesAgencyCode__c,order.SBCF_Comm_Split__c,order.SBCF_SpecComm__c
                        ,order.SBCF_SpecOvg8020__c,order.TotalAmount,order.SBCF_TotalOverage__c,order.SBCF_Unused1__c,order.SBCF_Ship_Date__c,order.SBQQ__Quote__c,order.SBCF_FreightAllow__c,order.SBCF_SpecOvg100__c,order.SBCF_SalesOvg100__c,order.SBCF_Unused2__c,order.SBCF_Unused3__c,order.SBCF_CSalesRepCode__c
                        ,order.SBCF_Unused4__c,order.SBCF_SalesRepComm__c,order.SBCF_Parts_Svc__c,order.SBCF_SalesOvg8020__c,order.SBCF_Use_Alt_Code__c,order.SBCF_Use_UPC_Code__c,order.SBCF_OrderedBy__c,order.SBCF_ProfitCenter__c from orderitem where order.status = 'Activated' and order.ActivatedDate>=:startdate and order.ActivatedDate <:enddate1 and order.OrderNumber=:selectedorder];
            system.debug('Orditems:'+orditem.size());            
        }else
        {
            //orditem = [select OrderItemNumber,SBCF_Distributor_Code__c,SBCF_Location__c,SBCF_Fixture_Family__c,SBCF_FixtureCode__c,SBQQ__OrderedQuantity__c,UnitPrice,SBQQ__TaxCode__c,SBCF_Factory__c,SBCF_TotalOverage__c,
                      // order.OrderNumber,order.EffectiveDate,order.SBCF_DiscountperlineItem__c from orderitem where order.status = 'Activated' and order.ActivatedDate>=:startdate and order.ActivatedDate <:enddate1 and OrderItemNumber IN:selectedorderitem];
            orditem = [select SBCF_Distributor_Code__c,SBCF_Location__c,SBCF_Fixture_Family__c,SBCF_FixtureCode__c,SBQQ__OrderedQuantity__c,UnitPrice,SBCF_Factory__c,order.EffectiveDate,order.SBCF_DiscountperlineItem__c,order.OrderNumber,order.SBCF_Tax_Code__c,order.SBCF_SpecAgencyCode__c ,order.SBCF_Terms_Code__c,order.SBCF_ShipVia__c,order.SBCF_FOB__c,order.SBCF_Freight__c,order.SBCF_PO_Number__c,order.SBCF_Estimated_Ship_Date__c,order.SBCF_JobNo__c,order.SBCF_Shipping_Instructions__c,order.AccountId,order.SBCF_BillToAttention__c,order.Billingcity,
                        order.BillingStateCode,order.BillingCountryCode,order.BillingPostalCode,order.ShipTo__c,order.SBCF_ShippingAttention__c,order.Shippingcity,order.ShippingStateCode,order.ShippingCountryCode,order.ShippingPostalCode,order.SBCF_Contact__c,order.SBCF_Account_No__c,order.SBCF_Phone__c,order.SBCF_Fax__c,order.SBCF_Email__c,order.OpportunityId,order.SBCF_SalesAgencyCode__c,order.SBCF_Comm_Split__c,order.SBCF_SpecComm__c
                        ,order.SBCF_SpecOvg8020__c,order.TotalAmount,order.SBCF_TotalOverage__c,order.SBCF_Unused1__c,order.SBCF_Ship_Date__c,order.SBQQ__Quote__c,order.SBCF_FreightAllow__c,order.SBCF_SpecOvg100__c,order.SBCF_SalesOvg100__c,order.SBCF_Unused2__c,order.SBCF_Unused3__c,order.SBCF_CSalesRepCode__c
                        ,order.SBCF_Unused4__c,order.SBCF_SalesRepComm__c,order.SBCF_Parts_Svc__c,order.SBCF_SalesOvg8020__c,order.SBCF_Use_Alt_Code__c,order.SBCF_Use_UPC_Code__c,order.SBCF_OrderedBy__c,order.SBCF_ProfitCenter__c from orderitem where order.status = 'Activated' and order.ActivatedDate>=:startdate and order.ActivatedDate <:enddate1 and OrderItemNumber IN:selectedorderitem];
            system.debug('Orditems:'+orditem.size());
        }
       
    }
    
}
I created process builder on order object. When order is activated then the related opportunity of order stage becomes closed won.

And I created  validation rule , when opportunity stage is closed won , then no one can edit this opportunity.

When I am trying to activate the order , validation rule will fire and display validation error message .
How to fix this issue ? Any idea ?
Thanks in advance,
Shahid.
Hi Friends,

I need one query  for list of opportunities without open activities . Is there any possibility for getting result without writing any code ? I need only one single query . 

Thanks in advance.
Shahid.


 
Hi Friends,
I need to add some more fields in search layout section in Add invities fucntion on New Event.How can i do this ?
Screenshot :
User-added image
Thanks,
Shahid.
 
Hi friends,

I have custom object named as EMployee. Iin this object i stored my employee details. 
My requirement is assign more than one employee into one single event . How it is possible ? Without VF , Apex can i solve this.


 
Hi friends,

I want to create a Validation rule in opportunity object. When year is changed in Close Date field in Opportunity object  , i need to display error msg to fill the reason into another field. 
How to write VR for this one.

VR for only year changed in Close Date field
 Hi friends,
When a page is loaded, I need multi-select picklist field should be prefilled with some value. Is it possible? 
Thanks in advance.

Thanks ,
Shahid.
Hi Friends,
I want to know how to add script to particular field / fields in edit / detail  page.I don't want to override the entire page , because of one field.
Is there any way to add script on standard field without creating VF page.

Thanks in advance,
Shahid.
Hi Friends,

I need to find out the way to send the Debug log file to System admin. When I directly importing CSV file into contacts / accounts , then i know how many records are inserted /updated . But I import into custom object , and these records are insert and update in Contact & lead objects. I got the information from debug logs how many records are inserted,7 Updated. 
But my requirement is i want to send these logs file / report to system admin.
How it is possible ?
Thanks in advance,
Shahid.
Hi Friends,
I Created a custom lookup field on Opportunity object to Contact object. I need to fetch the account details when i create new opportunity under contact object.

While creating new opportunity under contact object , ihave only contact details, but i need to fetch this particular contact account details also. 

Code:
 Set<Id> cId=new Set<Id>();
        for(Opportunity opp : newList){
        cId.add(opp.Primary_Broker__c);
        }
              List<Contact> Updcon = new List<Contact>();
              List<Contact> con = [select id,AccountId,Open_Opportunities__c from Contact where Id in:cId ]; 
              List<Opportunity > opportunity= [select id,Primary_Broker__c,StageName from Opportunity where  Primary_Broker__c in:cId AND ( StageName NOT IN ('Closed Won','Closed Lost')) ];
           for(Contact c :con )
           {
             c.Open_Opportunities__c=opportunity.size();
             Updcon.add(c);
           }update Updcon;

Thanks in advance,
Shahid.
Hi Friends ,

I want to create chat window in my salesforce org . I don't know javascript. Anybody help me ?

Screenshot of chat window :
User-added image

I need to create like above screenshot . with images also.
Thanks in advance.

Thanks,
Shahid.
 
Hi Friends,

I written one apex class with different methods. now i call this apex class in one trigger. But It gives some error.

Apex class :

public with sharing class Account_Handler {
 public static void afterInsert (List<Opportunity> newList){
        List<Account> Updacc = new List<Account>();
      for(Opportunity opp : newList){
              List<Account> acc = [select id,Total_Open_Opportunities__c from Account where Id =: opp.AccountId]; 
              List<Opportunity > opportunity= [select id,AccountId,StageName from Opportunity where AccountId =:opp.AccountId AND ( StageName NOT IN ('Closed Won','Closed Lost')) ];
           for(Account a :acc )
           {
             a.Total_Open_Opportunities__c=opportunity.size();
             Updacc.add(a);
          }
      }update Updacc; 
   }
    
    public static void afterUpdate (List<Opportunity> newList){
          List<Account> Updacc = new List<Account>();
        for(Opportunity opp : newList){
              List<Account> acc = [select id,Total_Open_Opportunities__c from Account where Id =: opp.AccountId]; 
              List<Opportunity > opportunity= [select id,AccountId,StageName from Opportunity where AccountId =:opp.AccountId AND ( StageName NOT IN ('Closed Won','Closed Lost'))];
           for(Account a :acc )
           {
             a.Total_Open_Opportunities__c=opportunity.size();
             Updacc.add(a);
           }
       }update Updacc; 
    } 
    
    public static void afterDelete (List<Opportunity> oldList){
          List<Account> Updacc = new List<Account>();
        for(Opportunity opp : oldList){
              List<Account> acc = [select id,Total_Open_Opportunities__c from Account where Id =: opp.AccountId]; 
              List<Opportunity > opportunity= [select id,AccountId,StageName from Opportunity where AccountId =:opp.AccountId AND ( StageName NOT IN ('Closed Won','Closed Lost'))];
           for(Account a :acc )
           {
             a.Total_Open_Opportunities__c=opportunity.size();
             Updacc.add(a);
           }
       }update Updacc; 
    }   
}

This is Sample code. Its not a complete code. I have another methods also.

Trigger :

trigger AccountTrigger on Account (before insert, after insert, after update,after delete) {
  if (Trigger.isBefore) {
    if (Trigger.isInsert) {
      Account_Handler.beforeInsert(Trigger.new);
    }
  }

  if (Trigger.isAfter) {
    if (Trigger.isInsert) {
      Account_Handler.afterInsert(Trigger.new);
      Account_Handler.afterInsert(Trigger.new);
    }
    if (Trigger.isUpdate) {
        Account_Handler.afterUpdate(Trigger.new);
      Account_Handler.afterUpdate(Trigger.newMap, Trigger.oldMap);
      
    }
    if (Trigger.isDelete) {
      Account_Handler.afterDelete(Trigger.old);
    }
  }
}

Error :

Method does not exist or incorrect signature: Account_Handler.afterUpdate(List<Account>)

This error comes for afterUpdate & afterdelete methods.

Thanks in advance,
Shahid.
Hi Friends,

I have a problem on updation [rpcess. I am updating contact records through custom object. And I write a method for updation. If the custom object field is empty then no need to update contact field. 
But this scenario is different in  MQL_Date field. If MQL_Date field is having a value in contact object then no need to update this field with custom object MQL_date field.
But its not working. 
The MQL_Date field of contact object is updated with custom object MQL_Date field field.

My Code is :

c1.Became_an_MQL_Lead_Date__c = isValidInputDate( c1.Became_an_MQL_Lead_Date__c)? c1.Became_an_MQL_Lead_Date__c : customObjRecord.MQL_Date__c;

Method is : 

 public static boolean isValidInputDate(Datetime D) {
        if(D != null ) {
            return true;
        }
        return false;
        
    }

Thanks in Advance,
Shahid.

 
Hi Friends,

If any body have any idea about how to integrate OneNote with Salesforce ? Is it possible or not ? If it is possible, how can we achieve this ? Without Third party can we make this ? What are circumstances ?
Please provide any dcoumentation.
Thanks in Advance
Hi friends ,

I wrote a trigger on Territory2 object . And i create custom setting and field . In this custom setting the custom check field is checked for any particular user he only have the permission to delete option.

How to write test class for this trigger

Trigger :

trigger Triggerdelete on Territory2 (before delete) {
    id ids=userinfo.getProfileId();
    Delete_Permission__c del=Delete_Permission__c.getinstance(ids);
    if(del.Permission__c==false){
        Trigger.old[0].adderror('User Can\'t delete this Territory');
    }

}

 
HI Friends,

I written a trigger for importing the CSV file into custom object . While importing into custom object these records are also insert / update in Contact & Lead object also.
I have to give the report to sales team as how many records inserted in Contact & how many updated .Same thing Leads also.

When i import CSV file directly into Contact / Lead then i got info how many iserted & updated. 
But here i am importing records into custom object then how can i find.

I wrriten some code , with this code i got the info of result of importing file in debug only log file. I need to give this file to admin.

Also i need to fetch the data from geterrors.  

Code :

 if (upcon.size() > 0){
        System.debug('Update Contact Size:-'+upcon.size());
        Database.saveResult[] rslt=Database.update(upcon, false);
        for(Database.saveResult r: rslt){
            if(r.isSuccess()){
                System.debug(r.getId());
            }
            else{
                  for(Database.Error err : r.getErrors()){
                    System.debug('The following error has occurred.');                    
                    System.debug(err.getStatusCode() + ': ' + err.getMessage());
                    System.debug('Contact fields that affected this error: ' + err.getFields());
                }
            }
        }
    }
Hi Friends ,

I have one trigger. In my trigger i wrote some condition insert records into conatct / lead object while importing CSV file into Custom object. . I am importing CSV file into Custom object . In my custom object state field type is Text . Contact object state field type is Picklist. In picklist i have multble state. But in CSV file state names are replaced with their state codes . Like  California = CA ,
 
For this reason when i import csv file into custom objects rescords are inserted in custom object only. They didn't insert / update in contacts object
. CLient is not rady to change the field data type  & not ready to insert CA into picklist field .How to write a code ?How to overcome this issue ?

I am giving my inserting code below. Here i am written code for one state . I think this is not proper issue.

Code :

contact c4 = new contact();
                        c4.AccountId = a.Id;
                        c4.LastName = customObjRecord.Name;
                        c4.FirstName = customobjrecord.First_Name__c;
                        c4.OtherPhone = customObjRecord.Other_Phone__c;
                        c4.Email = customObjRecord.Email_Address__c;
                        c4.Phone = customObjRecord.Phone__c;
                        c4.Title=customObjRecord.Title__c;
                        c4.Contact_Status__c = customObjRecord.Contact_Status__c;
                        c4.LeadSource = customObjRecord.Lead_Source__c;
                        c4.Lead_Subsource__c = customObjRecord.Lead_Subsource__c;
                        c4.Lead_Channel__c = customObjRecord.Lead_Channel__c;  
                        c4.MailingStreet=customObjRecord.Mailing_Address__c;
                        c4.MailingCity=customObjRecord.Mailing_Address_City__c;
                       // c4.MailingState=customObjRecord.Mailing_Address_State__c;
                        c4.MailingPostalCode=customObjRecord.Mailing_Postal_Code__c;
                        c4.External_Con_Id__c='Ext'+count;  
                        
                        if(customObjRecord.Primary_Address_Country__c.equalsIgnoreCase('US') 
                              ||  customObjRecord.Primary_Address_Country__c.equalsIgnoreCase('usa') ){
                                c4.MailingCountry='United States';
                        } else 
                        {
                               c4.MailingCountry=customObjRecord.Primary_Address_Country__c;
                        }
                        
                        if(customObjRecord.Mailing_Address_State__c.equalsIgnoreCase('CA')  ){
                                c4.MailingState='California';
                        } else 
                        {
                               c4.MailingState=customObjRecord.Mailing_Address_State__c;
                        }
Hi friends , 

I write a trigger for importing records in custom object. while importing records in custom object , i written some condition for importing these record into contacts and Leads objects at the same time. 
How do you know the how many records inserted in contacts , how many updated in contacts object. Same issue for lead object also . In my org i  have already records. and I import more than 1000 records . That's y i need to find out this one .
Is it possible ?
Hi Friends,

I created app for restaurent . I created custom objects name as Bill , Order , Raw material . Now i want to write a trigger /something for deduct the rawmaterial after order is billing. howit is possible ?

Thanks in advance
 
Hi Friends,

I need one query  for list of opportunities without open activities . Is there any possibility for getting result without writing any code ? I need only one single query . 

Thanks in advance.
Shahid.


 
Hi Friends,
I need to add some more fields in search layout section in Add invities fucntion on New Event.How can i do this ?
Screenshot :
User-added image
Thanks,
Shahid.
 
Hi friends,

I want to create a Validation rule in opportunity object. When year is changed in Close Date field in Opportunity object  , i need to display error msg to fill the reason into another field. 
How to write VR for this one.

VR for only year changed in Close Date field
Hi Friends,

I need to find out the way to send the Debug log file to System admin. When I directly importing CSV file into contacts / accounts , then i know how many records are inserted /updated . But I import into custom object , and these records are insert and update in Contact & lead objects. I got the information from debug logs how many records are inserted,7 Updated. 
But my requirement is i want to send these logs file / report to system admin.
How it is possible ?
Thanks in advance,
Shahid.
Hi Friends,
I Created a custom lookup field on Opportunity object to Contact object. I need to fetch the account details when i create new opportunity under contact object.

While creating new opportunity under contact object , ihave only contact details, but i need to fetch this particular contact account details also. 

Code:
 Set<Id> cId=new Set<Id>();
        for(Opportunity opp : newList){
        cId.add(opp.Primary_Broker__c);
        }
              List<Contact> Updcon = new List<Contact>();
              List<Contact> con = [select id,AccountId,Open_Opportunities__c from Contact where Id in:cId ]; 
              List<Opportunity > opportunity= [select id,Primary_Broker__c,StageName from Opportunity where  Primary_Broker__c in:cId AND ( StageName NOT IN ('Closed Won','Closed Lost')) ];
           for(Contact c :con )
           {
             c.Open_Opportunities__c=opportunity.size();
             Updcon.add(c);
           }update Updcon;

Thanks in advance,
Shahid.
Hi Friends ,

I want to create chat window in my salesforce org . I don't know javascript. Anybody help me ?

Screenshot of chat window :
User-added image

I need to create like above screenshot . with images also.
Thanks in advance.

Thanks,
Shahid.
 
Hi Friends,

I written one apex class with different methods. now i call this apex class in one trigger. But It gives some error.

Apex class :

public with sharing class Account_Handler {
 public static void afterInsert (List<Opportunity> newList){
        List<Account> Updacc = new List<Account>();
      for(Opportunity opp : newList){
              List<Account> acc = [select id,Total_Open_Opportunities__c from Account where Id =: opp.AccountId]; 
              List<Opportunity > opportunity= [select id,AccountId,StageName from Opportunity where AccountId =:opp.AccountId AND ( StageName NOT IN ('Closed Won','Closed Lost')) ];
           for(Account a :acc )
           {
             a.Total_Open_Opportunities__c=opportunity.size();
             Updacc.add(a);
          }
      }update Updacc; 
   }
    
    public static void afterUpdate (List<Opportunity> newList){
          List<Account> Updacc = new List<Account>();
        for(Opportunity opp : newList){
              List<Account> acc = [select id,Total_Open_Opportunities__c from Account where Id =: opp.AccountId]; 
              List<Opportunity > opportunity= [select id,AccountId,StageName from Opportunity where AccountId =:opp.AccountId AND ( StageName NOT IN ('Closed Won','Closed Lost'))];
           for(Account a :acc )
           {
             a.Total_Open_Opportunities__c=opportunity.size();
             Updacc.add(a);
           }
       }update Updacc; 
    } 
    
    public static void afterDelete (List<Opportunity> oldList){
          List<Account> Updacc = new List<Account>();
        for(Opportunity opp : oldList){
              List<Account> acc = [select id,Total_Open_Opportunities__c from Account where Id =: opp.AccountId]; 
              List<Opportunity > opportunity= [select id,AccountId,StageName from Opportunity where AccountId =:opp.AccountId AND ( StageName NOT IN ('Closed Won','Closed Lost'))];
           for(Account a :acc )
           {
             a.Total_Open_Opportunities__c=opportunity.size();
             Updacc.add(a);
           }
       }update Updacc; 
    }   
}

This is Sample code. Its not a complete code. I have another methods also.

Trigger :

trigger AccountTrigger on Account (before insert, after insert, after update,after delete) {
  if (Trigger.isBefore) {
    if (Trigger.isInsert) {
      Account_Handler.beforeInsert(Trigger.new);
    }
  }

  if (Trigger.isAfter) {
    if (Trigger.isInsert) {
      Account_Handler.afterInsert(Trigger.new);
      Account_Handler.afterInsert(Trigger.new);
    }
    if (Trigger.isUpdate) {
        Account_Handler.afterUpdate(Trigger.new);
      Account_Handler.afterUpdate(Trigger.newMap, Trigger.oldMap);
      
    }
    if (Trigger.isDelete) {
      Account_Handler.afterDelete(Trigger.old);
    }
  }
}

Error :

Method does not exist or incorrect signature: Account_Handler.afterUpdate(List<Account>)

This error comes for afterUpdate & afterdelete methods.

Thanks in advance,
Shahid.
Hi Friends,

If any body have any idea about how to integrate OneNote with Salesforce ? Is it possible or not ? If it is possible, how can we achieve this ? Without Third party can we make this ? What are circumstances ?
Please provide any dcoumentation.
Thanks in Advance
Hi friends ,

I wrote a trigger on Territory2 object . And i create custom setting and field . In this custom setting the custom check field is checked for any particular user he only have the permission to delete option.

How to write test class for this trigger

Trigger :

trigger Triggerdelete on Territory2 (before delete) {
    id ids=userinfo.getProfileId();
    Delete_Permission__c del=Delete_Permission__c.getinstance(ids);
    if(del.Permission__c==false){
        Trigger.old[0].adderror('User Can\'t delete this Territory');
    }

}

 
Hi friends , 

I write a trigger for importing records in custom object. while importing records in custom object , i written some condition for importing these record into contacts and Leads objects at the same time. 
How do you know the how many records inserted in contacts , how many updated in contacts object. Same issue for lead object also . In my org i  have already records. and I import more than 1000 records . That's y i need to find out this one .
Is it possible ?
Hi Friends,

I created app for restaurent . I created custom objects name as Bill , Order , Raw material . Now i want to write a trigger /something for deduct the rawmaterial after order is billing. howit is possible ?

Thanks in advance
 
Hi Friends,

I am creating a application for restaurent purpose. 
I want to genearte single bill for multiple orders of a single customer . Is it possible ? And how it is Possible.

Thanks in Advance.
Hi Friends ,

I am importing a csv file using data import wizard. After Completion of import i got the below error.
System.ListException: Duplicate id in list

It shows System.ListException: Duplicate id in list: 00Qn0000006FfywEAC.

When I check the id in my objects. i found a record . I check the CSV file with this record. I found phone number field is name in some other records. That'y It shows error Duplicate Id.
Only Phone number is Same , remaining fields are different. How to over come thsi.

My code is :

public class DataImport_Class {
    public static void beforeInsert (List<Campaign_Entry__c> newrecord){
Integer count1;
    String custObjEmailDomain;
    List <Lead> inlead = new List <Lead> ();
    List <Lead> uplead = new List <Lead> ();
    List <Lead> uplead1 = new List <Lead> ();
    List <Lead> uplead2 = new List <Lead> ();
    List <Campaign> campCrt = new List <Campaign> ();
    List <Campaign> camprecds = [select name, (select Name, Status, ContactId,LeadId,Phone, MobilePhone, 
                                     CompanyOrAccount from CampaignMembers ) from Campaign];
    List <CampaignMember> campMemUpd = new List <CampaignMember>();
    List <CampaignMember> campMemcre1 = new List <CampaignMember>();
    List <CampaignMember> campMemcre2 = new List <CampaignMember>();
    List <CampaignMember> campMemcre = new List <CampaignMember>();
    List <Account> accs = [select Email_Domain__c, (select LastName,Email, otherphone, phone, Contact_Status__c,Title,
                                  MailingStreet,MailingCity,MailingState,MailingPostalCode
                                                    from Contacts) from Account];
    List <Lead> leads = [select lastname, MobilePhone, Email, Company,phone, Title ,Street,City,State,PostalCode,Status from Lead];
    List <CampaignMember> campMem = [select Name, Status, ContactId,LeadId,Phone, MobilePhone, 
                                     CompanyOrAccount from CampaignMember];
       for (Campaign_Entry__c customObjRecord: newrecord) { // Iterate over the custom object records
           if(customObjRecord.Email_Address__c!=null && customObjRecord.Email_Address__c !=''){   
                custObjEmailDomain = ((customObjRecord.Email_Address__c).split('@')[1]).split( '\\.')[0];
           }
        System.debug(customObjRecord);
        Boolean accCrtFlag = true;
if (accCrtFlag) {
            Boolean leadCrtFlag = true;
            for (Lead l: leads) {
                if (leadCrtFlag && (customObjRecord.Email_Address__c == l.email && customObjRecord.Email_Address__c !=
                        '' && customObjRecord.Email_Address__c != null) && customObjRecord.Office_Phone__c != l.phone ) // If Email ids are same
                {
                    leadCrtFlag = false;
                    Lead l1 = l;
                    
                    if (customObjRecord.Name != null && customObjRecord.Name != '')
                        l1.LastName = customObjRecord.Name;
                    if (customObjRecord.First_Name__c != null && customObjRecord.First_Name__c != '')
                         l1.FirstName = customObjRecord.First_Name__c;
                    if (customObjRecord.Business_Card_Company__c != null && customObjRecord.Business_Card_Company__c !='')
                        l1.Company = customObjRecord.Business_Card_Company__c;
                    if (customObjRecord.Office_Phone__c != '' && customObjRecord.Office_Phone__c != null)
                        l1.MobilePhone = customObjRecord.Office_Phone__c; // Update new phone Field value into other phone Field
                    if (customObjRecord.Business_Card_Title__c != null && customObjRecord.Business_Card_Title__c !='')
                        l1.Title=customObjRecord.Business_Card_Title__c;
                    if (customObjRecord.Primary_Address_Street__c != null && customObjRecord.Primary_Address_Street__c !='')
                        l1.Street=customObjRecord.Primary_Address_Street__c;
                    if (customObjRecord.Primary_Address_City__c != null && customObjRecord.Primary_Address_City__c !='')
                        l1.City=customObjRecord.Primary_Address_City__c;
                    if (customObjRecord.Primary_Address_State__c != null && customObjRecord.Primary_Address_State__c !='')
                        l1.State=customObjRecord.Primary_Address_State__c;
                    if (customObjRecord.Primary_Address_Country__c != null && customObjRecord.Primary_Address_Country__c !='')
                        l1.Country=customObjRecord.Primary_Address_Country__c;
                    if (customObjRecord.Primary_Address_Postal_Code__c != null && customObjRecord.Primary_Address_Postal_Code__c !='')
                        l1.PostalCode=customObjRecord.Primary_Address_Postal_Code__c;
                      Boolean campCrtFlag = true;
                        for (Campaign camp: camprecds){
                            if(camp.Name==customObjRecord.Campaign__c){
                                for(CampaignMember cm: camp.CampaignMembers){
                                    if(cm.LeadId==l1.Id){
                                        campCrtFlag=false;
                                    }
                                }
                                if(campCrtFlag){
                                    CampaignMember cm = new CampaignMember(CampaignId = camp.Id, LeadId = l1.Id,
                                                                           status = customObjRecord.Member_Status__c);
                                    campMemcre.add(cm);
                                }
                            }
                        }
                    uplead.add(l1); // Update the existing record in Leads
                } else if (customObjRecord.Email_Address__c != l.email  && (customObjRecord.Office_Phone__c == l.phone &&
                        customObjRecord.Office_Phone__c != '' && customObjRecord.Office_Phone__c != null)) // If phone numbers are same
                {
                    leadCrtFlag = false;
                    lead l2 = l;
                    if (customObjRecord.Name != null && customObjRecord.Name != '') // Update LastName field when new Name field value is not empty .
                        l2.LastName = customObjRecord.Name;
                    if (customObjRecord.First_Name__c != null && customObjRecord.First_Name__c != '')
                            l2.FirstName = customObjRecord.First_Name__c;
                    if (customObjRecord.Email_Address__c != null && customObjRecord.Email_Address__c != '')
                        l2.Email = customObjRecord.Email_Address__c;
                    if (customObjRecord.Business_Card_Company__c != null && customObjRecord.Business_Card_Company__c !='')
                        l2.Company = customObjRecord.Business_Card_Company__c;
                    if (customObjRecord.Business_Card_Title__c != null && customObjRecord.Business_Card_Title__c !='')
                        l2.Title=customObjRecord.Business_Card_Title__c;
                    if (customObjRecord.Primary_Address_Street__c != null && customObjRecord.Primary_Address_Street__c !='')
                        l2.Street=customObjRecord.Primary_Address_Street__c;
                    if (customObjRecord.Primary_Address_City__c != null && customObjRecord.Primary_Address_City__c !='')
                        l2.City=customObjRecord.Primary_Address_City__c;
                    if (customObjRecord.Primary_Address_State__c != null && customObjRecord.Primary_Address_State__c !='')
                        l2.State=customObjRecord.Primary_Address_State__c;
                    if (customObjRecord.Primary_Address_Country__c != null && customObjRecord.Primary_Address_Country__c !='')
                        l2.Country=customObjRecord.Primary_Address_Country__c;
                    if (customObjRecord.Primary_Address_Postal_Code__c != null && customObjRecord.Primary_Address_Postal_Code__c !='')
                        l2.PostalCode=customObjRecord.Primary_Address_Postal_Code__c;
                     Boolean campCrtFlag = true;
                        for (Campaign camp: camprecds){
                            if(camp.Name==customObjRecord.Campaign__c){
                                for(CampaignMember cm: camp.CampaignMembers){
                                    if(cm.LeadId==l2.Id){
                                        campCrtFlag=false;
                                }
                                }
                                if(campCrtFlag){
                                    CampaignMember cm = new CampaignMember(CampaignId = camp.Id, LeadId = l2.Id,
                                                                           status = customObjRecord.Member_Status__c);
                                    campMemcre.add(cm);
                                }
                            }
                        }
                    uplead.add(l2); // Update the existing record in Leads
                } else if ((customObjRecord.Email_Address__c == l.email && customObjRecord.Email_Address__c != '' &&
                        customObjRecord.Email_Address__c != null) && (customObjRecord.Office_Phone__c == l.phone &&
                        customObjRecord.Office_Phone__c != '' && customObjRecord.Office_Phone__c != null)) //  phone numbers & Email Ids are same
                {
                    leadCrtFlag = false;
                    lead l3 = l;
                    if (customObjRecord.Name != null && customObjRecord.Name != '') // Update LastName field when new Name field value is not empty .
                        l3.LastName = customObjRecord.Name;
                    if (customObjRecord.First_Name__c != null && customObjRecord.First_Name__c != '')
                         l3.FirstName = customObjRecord.First_Name__c;
                    if (customObjRecord.Business_Card_Company__c != null && customObjRecord.Business_Card_Company__c !='')
                        l3.Company = customObjRecord.Business_Card_Company__c;
                    if (customObjRecord.Business_Card_Title__c != null && customObjRecord.Business_Card_Title__c !='')
                        l3.Title=customObjRecord.Business_Card_Title__c;
                    if (customObjRecord.Primary_Address_Street__c != null && customObjRecord.Primary_Address_Street__c !='')
                        l3.Street=customObjRecord.Primary_Address_Street__c;
                    if (customObjRecord.Primary_Address_City__c != null && customObjRecord.Primary_Address_City__c !='')
                        l3.City=customObjRecord.Primary_Address_City__c;
                    if (customObjRecord.Primary_Address_State__c != null && customObjRecord.Primary_Address_State__c !='')
                        l3.State=customObjRecord.Primary_Address_State__c;
                    if (customObjRecord.Primary_Address_Country__c != null && customObjRecord.Primary_Address_Country__c !='')
                        l3.Country=customObjRecord.Primary_Address_Country__c;
                    if (customObjRecord.Primary_Address_Postal_Code__c != null && customObjRecord.Primary_Address_Postal_Code__c !='')
                        l3.PostalCode=customObjRecord.Primary_Address_Postal_Code__c;
                    
                    Boolean campCrtFlag = true;
                        for (Campaign camp: camprecds){
                            if(camp.Name==customObjRecord.Campaign__c){
                                for(CampaignMember cm: camp.CampaignMembers){
                                    if(cm.LeadId==l3.Id){
                                        campCrtFlag=false;
                                    }
                                }
                                if(campCrtFlag){
                                    CampaignMember cm = new CampaignMember(CampaignId = camp.Id, LeadId = l3.Id,
                                                                           status = customObjRecord.Member_Status__c);
                                    campMemcre.add(cm);
                                }
                            }
                        }
                    uplead.add(l3); // Update the existing record in Contacts
                }
            }
            
            if (leadCrtFlag) // Email & Phone both are different
                {
                    System.debug('lead: Both are Different');
                    count1=01;
                    lead l4 = new lead();
                    l4.LastName = customObjRecord.Name;
                    l4.FirstName = customobjrecord.First_Name__c;
                    l4.MobilePhone = customObjRecord.Other_Phone__c;
                    l4.Email = customObjRecord.Email_Address__c;
                    l4.Phone = customObjRecord.Office_Phone__c;
                    l4.Company = customObjRecord.Business_Card_Company__c;
                    l4.Title=customObjRecord.Business_Card_Title__c;
                    l4.Street=customObjRecord.Primary_Address_Street__c;
                    l4.City=customObjRecord.Primary_Address_City__c;
                    l4.State=customObjRecord.Primary_Address_State__c;
                    l4.Country=customObjRecord.Primary_Address_Country__c;
                    l4.PostalCode=customObjRecord.Primary_Address_Postal_Code__c;
                    l4.External_Lead_Id__c='Ext'+count1+customObjRecord.Office_Phone__c;
                    System.debug('Ext'+count1+customObjRecord.Office_Phone__c);
                    inlead.add(l4); // Create new Lead
                    for (Campaign camp: camprecds){
                            if(camp.Name==customObjRecord.Campaign__c){
                                    String extname='Ext'+count1+customObjRecord.Office_Phone__c;
                                    Lead lnew=new Lead(External_Lead_Id__c=extname);
                                    CampaignMember cm = new CampaignMember(CampaignId = camp.Id, Lead = lnew,
                                                                           Status=customobjrecord.Member_Status__c);
                                    campMemcre.add(cm);
                                
                            }
                        }
                    count1++;
                }
            
        }
    }

        System.debug('New Contacts'+incon);
    if (inlead.size() > 0){
        Database.saveResult[] rslt=Database.insert(inlead, false);
        for(Database.saveResult r: rslt){
            if(r.isSuccess()){
                System.debug(r.getId());
            }
            else{
                System.debug(r.getErrors());
            }
        }
    }
        
    if (uplead.size() > 0){
        Database.saveResult[] rslt=Database.update(uplead, false);
        for(Database.saveResult r: rslt){
            if(r.isSuccess()){
                System.debug(r.getId());
            }
            else{
                System.debug(r.getErrors());
            }
        }
    }
    if (campMemUpd.size() > 0){
        Database.saveResult[] rslt=Database.update(campMemUpd, false);
        for(Database.saveResult r: rslt){
            if(r.isSuccess()){
                System.debug(r.getId());
            }
            else{
                System.debug(r.getErrors());
            }
        }
    }
    
    }
}