• Yogesh Kulkarni
  • NEWBIE
  • 74 Points
  • Member since 2014

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 25
    Replies
Dear all, below is my code which auto follows accounts when a new custom object KTT is created or updated. Code works fine on single record but I`m having trouble in bulkfying this code. I get "System.LimitException: Too many DML rows: 10001" error when I try to insert records in bulk via data loader. Is there something wrong with my code? I`m new to Apex world so it would really help if someone can point me to right direction.

Also, if I try to remove last few lines of DML statement, I get "System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: <unknown> duplicates value on record with id: <unknown>: []" error.
 
trigger RTTAutoFollow2 on RTT__C (after insert,after update) {


            List <EntitySubscription > NewFollowers = new List <EntitySubscription > ();   

                            List<Id> whatIds = new List<Id>();
               
   for(RTT__C sampletracker : trigger.new)

                         {
                whatIds.add(sampletracker.Account__c);
                             }
    
Map<Id, Account> Accounts = new Map<Id, Account>([SELECT Id, Name from Account WHERE Id in :whatIds]);
             

for(RTT__C sampletracker : trigger.new){  

              
                  if(sampletracker.Account__c != NULL){ 

 
           String Accid = sampletracker.Account__c;           
            String AccIds = accounts.get(Accid).ID;                  

    if (sampletracker.No_longer_Key__c == False)
{
  
               EntitySubscription ES = new EntitySubscription();    
               ES.SubscriberId = sampletracker.Assigned_Sales_Team__c;  
               ES.ParentId = sampletracker.Account__c;  
    
           }  
  
           try{  
                insert NewFollowers;                 
           }  
           catch (System.DmlException e){  
           }  
}
}}

 
Hi,
Currently we have Product, Currency and pricebook as selection criteria for price selection with the help of PricebookEntry. How can I add one more addiional dimension for price selection in SalesForce.

Thanks,
Yogesh
Hi,
I am running the test class and getting the debug lines printed in the code also, but somehow the code coverage remains 0%. Any guesses why this is happening.

Thanks,
Yogesh

Hi,

I am opeing a page from opportunity which has link back to opportunity, I did it with the help of PageReference. Now I want to port this on mobile as well and trying to get users back to SF1 page rather than browser page on mobile as well, used following link but the code is always going into if from browser and mobile app. Please help to check if my page is running in mobile app or browser.

https://developer.salesforce.com/docs/atlas.en-us.salesforce1.meta/salesforce1/vf_dev_best_practices_pages_multipurpose.htm


Thanks,
Yogesh

Hi,

Can I change the current user for execution of some lines of code while using javascript behind detail button? I normally do this using System.RunAs in apex.

Thanks,
Yogesh
Formula field in the roll up summary filter. I am trying to rollup the current quarter opportunity amount rollup at account level and created formula to check if the opportunity is falling in current quarter. Now I am not able to see the field in the filter criteria on the roll up summary. Interestingly there is one more field formula (number) which is appearing on filter, seeing that I created a number filter with 1 or 0 value to identify the current auarter opportunity filter, but my new field is also not appearing in the filter. 

Roll up summary problem

Thanks,
Yogesh
Hi ,

I am getting below error while triggering outbound message SFDC to outbound listener hosted over internet. The integration was working fine till 24 June 2016. Facing this issue after that . Pleae help in closing this issue

javax.net.ssl.SSLPeerUnverifiedException: Server chose TLSv1, but that protocol version is not enabled or not supported by the c

 
Hi All,
Please help in resolving the field not writable issue being thrown in below code . The object and filed level sharing is being set appropriately

trigger AccountAddressTrigger on Account (before insert , before update) {
    System.debug('Welcome to the Triggers World');
    List<Account> lstAccount=new List<Account>();
    For (Account actNew :Trigger.New)
    {
    if(actNew.BillingAddress !=NULL && actNew.Match_Billing_Address__c==true)
    {
        actNew.ShippingAddress=actNew.BillingAddress;
    }
        lstAccount.add(actNew);
    }
    
    insert lstAccount;
    
}
Hi,
I am running the test class and getting the debug lines printed in the code also, but somehow the code coverage remains 0%. Any guesses why this is happening.

Thanks,
Yogesh
I would appreciate some best practice advice here -

I have an insert trigger to populate a field in the record being inserted into a custom object with the value of a field in the parent object.

From other posts I learned that trigger.new cannot see any related fields.

Taking the value from a formula field on my custom object would normally be a choice but maximum number of object references has been reached due to high number of formula fields so I can't create another.

So I need to look up the value with SOQL and store it in a map with the Id of the record being inserted.

Which means that my before insert trigger must now be an after insert in order to know the Id.

If I query into a map and then update the field on the record being inserted I then need to issue an update DML statement, so in order to populate my field I need an insert and an update.

Seems inefficient - is that the only way?

Thanks,
Mike.
Hello,
I am a newbe in SF platform. I have an E-mail campaign app like mailchimp developed in .NET Technologies. Where user can import contacts form popular web services Like Dropbox, FresBook, Highrise,Googleapps, Hotmail etc. Now i need to intigrate Salesforce so that my user can import his/her contacts from SF account. Can anyone point me in the right direction? Is it possible to access any SF organization through webservice? If yes then which a Authentication Service i will use? Thanks in advance.
How to Convert single button as Save & ExportHI Thanks in advance,
How to Convert single button as Save & Export as Excel sheet in local machine , I want Convert Save button as multi actions.

User-added image
This above page allows the user enter text data when user clicks on save button it will save data & export data in Excel sheet. Please help me over this code. i want controller clas for this . please share workable Apex code for this.
 
<apex:page sidebar="false" StandardController="Account" standardstylesheets="false" rendered="true" docType="html-5.0">
  <apex:form > 
            <apex:pageBlock >
                <apex:pageBlockButtons >
                    <apex:commandButton action="{!save}" value="Save"/>
                </apex:pageBlockButtons>
      <table id="newspaper-b" border="" width="100%">    
          <thead>  
                
             <tr>
                <td>Value1</td>
                <td>Value2</td>      
                <td>Adding Value</td>
            </tr>                    
          </thead>
         <tr>
           <td><apex:inputText style="width:60px;height:20px"/></td>                
            <td><apex:inputText style="width:60px;height:20px"/></td>
            <td><apex:inputText style="width:60px;height:20px"/></td>                 
          </tr>
          
         <tr>
            <td><apex:inputText style="width:60px;height:20px"/></td>      
            <td><apex:inputText style="width:60px;height:20px"/></td>
            <td><apex:inputText style="width:60px;height:20px"/></td>                   
          </tr>
          
         <tr>
            <td><apex:inputText style="width:60px;height:20px"/></td>      
            <td><apex:inputText style="width:60px;height:20px"/></td>
            <td><apex:inputText style="width:60px;height:20px"/></td>
         </tr>
        </table>
       </apex:pageBlock>
</apex:form>
</apex:page>

I have used both Controller class & Vf page unable to Export the data. Please share the code if you have.

Thanks
 
Hello,
I'm trying to get a SOAP API to retrieve the details of a certain account/accounts using the IDs I got from getUpdated call. 
My code was working fine until now - here is where I get an error: 

Account retrievedAccount = (Account)arrayIDs[0];

Here is the full (almost) code I have:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SFAPITest.salesforce;
using System.Web.Services.Protocols;
using SFAPITest;


namespace SFAPITest
{
    class Program
    {
        static void Main(string[] args)
        {

            SforceService binding = new SforceService();
            var result = binding.login("username", "pass");
          
            binding.Url = result.serverUrl;

            binding.SessionHeaderValue = new SessionHeader();
            binding.SessionHeaderValue.sessionId = result.sessionId; 

            Console.WriteLine("Server URL: " + result.serverUrl);
            Console.WriteLine("Session ID: " + result.sessionId);

            GetUpdatedResult updatedObj = binding.getUpdated("Account", DateTime.Today, DateTime.Today.AddDays(1)); 

            sObject[] arrayIDs = binding.retrieve("Type", "Account", updatedObj.ids);
            Account retrievedAccount = (Account)arrayIDs[0];

            Console.ReadKey(); 
        }
    }
}


The error is "The type or namespace name 'Account' could not be found (are you missing a using directive or an assembly reference?)"

Please help - have a missed a part of the documentation? I'm using Visual studio 2008 (I know, a little old - will a newer version help?). Just to confirm - I have NOT renamed the project - I see that has been kind of an issue for other users.

Thank you!
How to write the schedule class and  how to run the schedule job. please give me one example of above scenario. please give some ideas.
Hi,

I am getting attached error while saving an old class from Developer console. It saves from Develop > Apex Classes with out any error.

User-added image
The error is for Financial Force Object. When communicated with FF they replied as
Hi Rahul,

Our development team was able to edit the AutoInvoiceHelper class, but not on developer console, instead from Setup -> Develop -> Apex Classes, and it worked without errors. If developer console is failing, it might be a Salesforce issue. It does appear you have access to the Apex class, CODAAPIInvoiceTypes_9_0.

Please try the steps provided above, but if it still doesn't work on the developer console you may consider contacting Salesforce support.  Unfortunately, this is as far as we can support since this is a custom Apex class.
Please let me know if you're ok to close this case.

Thank you,

FinancialForce.com
Would like to get solution before posting it with Salesforce.

Could I kindly request further help please?

Best Regards,

Rahul
 
Hi,

Can I change the current user for execution of some lines of code while using javascript behind detail button? I normally do this using System.RunAs in apex.

Thanks,
Yogesh
HI all,

This is my code
Date d = Date.Today();
 List<Account> AllAccounts= new List<Account>([select id,Name,Relationship_Start_Date__c,ARR__c,(Select Name from Opportunities) from Account ]);
 Map<String,Set<String>> MapAccwithOpps =new Map<String,Set<String>>();
 for(Account a:AllAccounts)
 {
 Set<String> Oppnames = new Set<String>();
    //string Oppnames='';
    for(Opportunity opp:a.Opportunities)
        {
            Oppnames.add(opp.Name);
        }
    MapAccwithOpps.put(a.Name,Oppnames);
    }
    system.debug('MapAccwithOpps==='+MapAccwithOpps);
 for(Account a:AllAccounts)
 {
    Integer numberDaysDue= a.Relationship_Start_Date__c.daysBetween(d);
 if(numberDaysDue<=60)
 {
    Opportunity O= new Opportunity();
    o.Name=a.Name;
    o.StageName='Legal';
    o.Amount=a.ARR__c;
    o.AccountId=a.ID;
    o.CloseDate=Date.today();
    o.NextStep='Won';
    if(!(MapAccwithOpps.get(a.Name).contains(o.Name)))
        insert o;
    }
 system.debug('Diff==='+numberDaysDue);
 
 }


How to create a scheduled job for this. I want to run this code every day Automatically.
Hi ,

Can anybody help me in writing a test class for the below tigger - 

trigger ProjectOnUpdate on Project__c(before update, after update) 
{
  
  if(Trigger.isBefore && Trigger.isUpdate){
  for(Project__c o: trigger.new) 
     {
          Project__c oldOpp = trigger.oldMap.get(o.Id);
          if(o.End_Date__c <> oldOpp.End_Date__c )
          {
                o.Field_Change_Indicator__c = true;
                o.End_Date_Prior_Value__c = oldOpp.End_Date__c;
                //genRequest(o);
          }
     }
     }
  else If(Trigger.isAfter && Trigger.isUpdate)
     {
         for(Project__c o1:trigger.new){
         If(o1.Field_Change_Indicator__c == true)
         {
             genRequest(o1);
         }
       }  
     }

  public void genRequest(Project__c  o2){

       Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
       req1.setComments('Submitting request for approval.');
       req1.setObjectId(o2.id);
       req1.setNextApproverIds(new Id[] {o2.Project_Sponsor__c});
       Approval.ProcessResult result = Approval.process(req1); 
       System.assert(result.isSuccess());        
}
}

Regards
Hi Guyz,
I am creating an opportunity whose name is same as that of the Account based on the criteria.
Now After creating an opportunity,Again when we run the script it should not create another opportunity if the opportunity name whose name which is same as that of the account name is found.

How to Proceed further to achieve this.
Here is My code.

Date  d = Date.Today();
List<Account> AllAccounts= new List<Account>([select id,Name,ARR__c,Relationship_Start_Date__c,
                                              (Select Id,Account.Id from Opportunities) from Account]);
                                              

for(Account a:AllAccounts)
{
    
    Integer numberDaysDue= a.Relationship_Start_Date__c.daysBetween(d);
    if(numberDaysDue<=60){
       
        Opportunity O= new Opportunity();
        o.Name=a.Name;
        o.StageName='Legal';
        o.Amount=a.ARR__c;
        o.AccountId=a.ID;
        o.CloseDate=Date.today();
        o.NextStep='Won';
        system.debug('Account Id'+o.AccountId);
        insert o;
      
    }
}
hi,
data loader default batch size is 200. one batch is considered as one transaction. so while iam updating 200 records 200th record id is not specified. iam getting 199 successes and one error that is as id is not specified. 199 records are being updated. now my question is batch size is 200 then we dont have problem with 199 records, only we have problem with 200th record then total transaction should be failed.  even 199 records should not be processed. process should be rolledback. incase of me why 199 records are being updated. please can any one explain this.
Hi ,

I need help in writng a test class class for the below controller - 

public with sharing class Project_Report {

public string model{get;set;}
public List<String> SelectedDept{get;set;}
public List<String> SelectedName{get;set;}
public List<SelectOption> AllDept{get;set;}
public List<SelectOption> AllName{get;set;}
public set<String> sSelectedDept;
public set<String> sSelectedProj;
public List<Project__c> results{get;set;}



public Project_Report()
{
 AllDept= new List<SelectOption>();
 AllDept= getDept();
 AllName= new List<SelectOption>();
 AllName= getName();

}

 public List<SelectOption> getDept()
    {
        List<SelectOption> options = new List<SelectOption>();
        Schema.DescribeFieldResult departfield =  Project__c.Department_Name__c.getDescribe();
        List<Schema.PicklistEntry> picklist = departfield.getPicklistValues();
        for( Schema.PicklistEntry f : picklist){      
        options.add(new SelectOption(f.getLabel(), f.getValue()));
        }    
        return options;
        
     }

       public List<SelectOption> getName()
    {
        List<SelectOption> options = new List<SelectOption>();
        Set<String> sProj = new Set<String>();
        
        if(SelectedDept != null && SelectedDept.size()>0)
            {
            system.debug('@@@@'+SelectedDept);
               for(String oSelectOption : SelectedDept)
               {
                    sProj.add(oSelectOption);
               }
               for(Project__c Proj  :[SELECT ID,Name FROM Project__c Where Department_Name__c IN : sProj] )
               {
                    options.add(new SelectOption(Proj.ID,Proj.Name));
               }
                
            }
            else
            {
                
                for(Project__c Proj  :[SELECT ID,Name FROM Project__c ] )
                {
                   options.add(new SelectOption(Proj.ID,Proj.Name));
                }
                
            }
      
        return options;
        
     }

    public void FindAllName()
    {
        system.debug('@@@Inside find all name');
        AllName= new List<SelectOption>();
        results = new List<Project__c>();        
        AllName= getName();
        
    }
    public void doSearch(){
    results = new List<Project__c>();   
    sSelectedDept = new set<String>();
    sSelectedProj = new set<String>(); 
    
    if(SelectedDept != null && SelectedDept.size()>0){
     for(String option: SelectedDept)
            {
              sSelectedDept.add(option);
            }
         }
          else
            {
                for(SelectOption oSelectOption : AllDept)
                {
                   sSelectedDept.add(oSelectOption.getValue());
                }
            }
            
    if(SelectedName !=null && SelectedName.size()>0){
    for(String options:SelectedName)
            {
              sSelectedProj.add(options);
            }
        }
        else
            {
                for(SelectOption oSelectOptions : AllName)
                {
                
                sSelectedProj.add(oSelectOptions.getValue());
                
                }
            }
            system.debug('$$$$$$' + sSelectedProj);
            String strProjqry  = 'select Id, Name,Project_Manager__c,Start_Date__c,End_Date__c,Status__c,Department_Name__c from Project__c ';
            
            if(sSelectedDept !=null && sSelectedDept.size()>0)
                {
                    strProjqry  += ' Where Department_Name__c IN :sSelectedDept';
                }
                

            if(sSelectedProj !=null && sSelectedProj.size()>0)
                {
                    strProjqry  += ' and ID IN: sSelectedProj' ;
                }

            System.debug('@@@Query:'+strProjqry);
            try
           {
                  results= database.query(strProjqry)  ;
                  system.debug('@@@@'+results.size());
                  
            }
            catch(Exception ex)
            {
                System.debug('This is the bug :'+ex);
            }
    }

}
Regards

 
I have a chatter group where user can put a question and if any user answer the question , requestor can choose the answer as a "BestAnswer". Below class is reponsible for this functionality. Now the issue is bestanswer flag is not coming in the detail page. we have found out the resolution. could someone help me to get it as i am new into SFDC?

for(sobject s : scope){
              jj_sss_Question_And_Answer__c question = (jj_sss_Question_And_Answer__c)s;
           
            try {                               (4)
                ConnectApi.FeedItem fi = jj_sss_Chatter_Functions.GetFeedItem(question.jj_sss_Feed_Item_Id__c);          (1)
               
                ConnectApi.QuestionAttachment qa = (ConnectApi.QuestionAttachment)fi.attachment;         (2)
                if (qa.bestAnswer != null) {
                    List<jj_sss_Question_And_Answer__c> answersToQuestion =
                        [select id, jj_sss_Status__c, jj_sss_isMailSent__c,jj_sss_Is_Best_Answer__c, jj_sss_Answer_Posted_By__c,jj_sss_Answer_Posted_By__r.Id,jj_sss_Question_Posted_By__r.Id, jj_sss_Feed_Comment_Id__c
                         from jj_sss_Question_And_Answer__c
                         where jj_sss_Feed_Item_Id__c = :question.jj_sss_Feed_Item_Id__c
                         and jj_sss_Feed_Comment_Id__c != null];
                   
                    jj_sss_Question_And_Answer__c bestAnswer = null;
              …
            } catch(Exception ex) {
                // An Exception occured
                System.debug(logginglevel.ERROR, 'An Exception occured while running the Best Answer job');     (3)
            }
                   
(1)If the feed item is deleted, this will return ‘Null’ and cause an nullpointer exception in (2)
(2)Calling the property .attachment can also return ‘Null’ which is not checked
(3)When logging the error message, the original exception is not mentioned. As such debugging is hard.
(4)The try catch is only around questions, issues with answers will be caught, but stop the processing of other answsers.


seeing 1,2,3,4 can you write the code for me ?
Good evening, 

need help getting the proper test coverage on trigger, and one issue i'm having with the test class is the field that i'm actually trying to test.  the trigger is to populate an Event record custom field ('Fortune_1000_Ranking__c') from a field pulled from the related Contact ('Fortune_1000_2013_Ranking__c'), which is actually a forrmula field pulled from the same field on the Account record (master-detail).  The trigger works fine:

trigger UpdateEventFortune1000 on Event (before insert, before update) {
Set<Id>CIds = new Set<Id>();for (Event E:trigger.new)
{String wId = e.WhoId; If(wID!=null && wId.startsWith('003')&& !cIds.contains(e.WhoId))
{cIds.add(e.WhoId);}}
    
    List<Contact> EventC = [Select Id, Fortune_1000_2013_Ranking__c from Contact where
                            Id in :cIds];
    
    Map<Id, Contact> CMap = new Map<Id, Contact>(); for (Contact c: EventC)
        
    {CMap.put(c.Id,c);}
    
    for (Event e:trigger.new)
    {String wId = e.WhoId; if (wId!=null && wId.startswith('003'))
    {Contact thisC = cMap.get(e.WhoId);
    if(thisC!=null)
    {e.Fortune_1000_Ranking__c = thisC.Fortune_1000_2013_Ranking__c;}}}
 
}

---------------------------------------------------------
The test class is throwing an error on the Fortune_1000_2013_Ranking__c line below due to the field is unwritable (value is pulled from the Account record)...any help would be appreciated!!

@isTest
private class UpdateEventFortune1000testclass {
    
static testMethod void UpdateEventFortune1000 () {
List<Contact>Contact = new List<Contact> {new Contact (
    firstname = 'test',
    lastname = 'testtest',
    Fortune_1000_2013_Ranking__c = 1,
    phone = '(555) 555-5555') }; 
    insert Contact;
    
List<Event> e = new List<Event> {new Event(
    WhoID = Contact[0].id, 
    subject = 'test trigger',
    Type = 'Meeting')};
    
    insert e;
    
List<Event> Eventstoupdate = New List<event>{[select id from event where id in :e]};
    for (event eok:eventstoupdate)
    eok.Fortune_1000_Ranking__c=null;
    
    update eventstoupdate;
    
Contact[] c = [select id,Fortune_1000_2013_Ranking__c from Contact where id in :Contact];
    System.assertEquals(1,Contact[0].Fortune_1000_2013_Ranking__c);
    
}
}
We are getting following error while creating a task in Salesforce.
Error msg: Too many retries of batch save in the presence of Apex triggers with failures: when triggers are present partial save requires that some subset of rows save without any errors in order to avoid inconsistent side effects from those triggers. Number of retries: 2 
We are getting this error on calling SforceService.create() function.

Please let me know the solution for this.
Anyone Seen this on the validation rule trailhead? - Challenge not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Contact Must Be in Account Zip Code: []
We have two fields criteria and gap which needs to be calculated in Account. both the fields are formula fields.

Criteria checks two things. First it checks for the account Type and than on the basis of the Type of account it checks the Region.

I have constructed the formula for one type of the Account(NON-SAVE) but i am not able to make one for the other type(SAVE) since formulas can be only of 5000 as a limit.both the types need to be calculated in the same formula.Is there any alternative way to do so.

CASE(
Typel__c , 'NON-SAVE',

CASE( Region__c,
'NSW/ACT', 85000,
'VIC/TAS',85000,
'QLD',85000,
'WA',75000,
'SA/NT', 60000,0
),

0) 

Once done with criteria field the Gap will be calculated after subtracting it.


Thanks in Advance