• Gunnam Ram
  • NEWBIE
  • 15 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 4
    Likes Given
  • 5
    Questions
  • 8
    Replies
Hi, I am trying to connect to sandbox from Eclipse. My org settings wont allow me to connect to sandbox using test.salesforce.com. I have to put hostname to create a project. As we know we have different host names for classic and Lightning. My problem is when I am trying to create project using Lightning HostName, I am getting below exception. I am able to create project with Classic view HostName. 

Can you please explain why this is happening.??

User-added image
I have 5 test classes which are creating a case record. When creating a case record in test classes the case object trigger logic is executing and creating a casearticle for each case. The problem is when I am running these 5 test classes synchronously, I am seeing "UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record" for few test classes. When I am running test classes asynchronously I am not seeing an issue and all tests passing. 
Please suggest a way where I can make all test classes pass in synchrounous mode.
I am working on a class which creates an case if we post something in a chatter group. My code is working as expected nut I cannot cover the code inside two IF blocks in my test class. Can any one please suggest.

My class:
Id parentID = Feeditem.ParentId;
String groupName;
         string smartBarLabel = Label.SmartBar_Custom_Label;
        string IPToolLabel = Label.IP_Tool_Support_custom_label;
Map<id,CollaborationGroup> CollaborationGroupName = new Map<id,CollaborationGroup>([select id, Name from CollaborationGroup where                                                                                                CollaborationType='Public' and ID in :FeedId]);
Case css = new Case();
                if(CollaborationGroupName.size() > 0) {
                    groupName = CollaborationGroupName.get(parentID).Name;
                }
                if(groupname!=null && groupName.equalsIgnoreCase(smartBarLabel)) {
                    css.RecordTypeId = ind.id;
                    if(SmartBarID!=null)
                        css.OwnerId=smartBarID;
                }
                else if(groupname!=null && groupname.equalsIgnoreCase(IPToolLabel)) {
                    css.Recordtypeid=IPind.id;
                    if(IPToolID!=null)
                        css.OwnerId=IPToolID;
                }    
                
                css.Chatter_Name__c=Feedpost.CreatedById;
                css.Description=FeedBody;
                css.Subject=Feedpost.Title;
                //css.Reason='Function';
                //css.OwnerId=Label.CaseQueueOwner;
                css.Type='Chatter';
                css.FeedItemId__c=feedpost.id;
                if(Feedpost.Title==null) css.Subject=FeedBody;
                system.debug('the feedpostparent********'+css.FeedItemId__c);
                csslist.add(css);  

Test Class :
       CollaborationGroup cg2 = new CollaborationGroup(Name='xxxx', CollaborationType='Public');
        cg2.OwnerId=u1.Id;
        insert cg2;
        FeedItem fitem2 = new FeedItem();
        fitem2.Body = 'yyyyy';
        fitem2.CreatedById = u1.Id;
        fitem2.ParentId = cg2.Id;
        insert fitem2;
       
        String groupnm = cg2.Name;
        Case aCase = new Case();
        system.assert(groupnm == 'xxxx');
        system.assert(groupnm!=NULL);
        aCase.OwnerId = testGroup.Id;
        aCase.Recordtypeid=ind.id;
        aCase.Description='FeedBody';
        aCase.FeedItemId__c=fitem2.Id;
        aCase.Subject='Feedpost.Title';
        aCase.Reason='Function';
        aCase.Type='Chatter';
        aCase.Chatter_Name__c = fitem2.CreatedById;
        insert aCase;
I have Contact object and Address Object. Address is related to Contact using LOOKUP. I can create many number of duplicate ADDRESS records under 1 contact. My requirement is to query the address object to get all duplicate records under 1 contact. please suggest.
Hi, Below is the code I have written to call Controller method from Javascript. But the issue I have identified is Onchange is not calling javascript . tried all possible ways. Please let me know where issue persists in below code.

<apex:page standardController="Address1__c" extensions="Address1controller">

    <script type="text/javascript">
    function setRequired(countryvar) {
       
    var country = document.getElementByID(countryvar);
   
    reRenderBlock(country);
 
    }
    </script>

      <apex:form id="theForm">

          <apex:actionFunction name="reRenderBlock" action="{!setzipcoderequired}">
              <apex:param id="country" name="country" value="" />
          </apex:actionFunction>

      <apex:pageBlock id="thePageBlock">
      <apex:pageBlockSection id="thePageBlockSection">
      <apex:inputField id="country" value="{!Address1__c.Billing_Country__c}"  onchange="setRequired({!$Component.country});"/>
      <apex:inputField id="zipcode" value="{!Address1__c.Billing_Zip__c}" required="{!check}"/>
      <apex:commandButton action="{!Save}" value="Save"/>

      </apex:pageBlockSection>

      </apex:pageBlock>
      </apex:form>
    </apex:page>
I have a web form that passes through a multi picklist field to a case object. Problem is that they come through as comma seperated but i need them to be semi-colon seperated. i will work with the web developers to see if they can pass them through as semi-colon seperated but in the event that they can't; what would my options be to create a field update to replace the comma with semi-colon. I tried doing a field update but apparently thats not available with a multi picklist field.
Hi, Below is the code I have written to call Controller method from Javascript. But the issue I have identified is Onchange is not calling javascript . tried all possible ways. Please let me know where issue persists in below code.

<apex:page standardController="Address1__c" extensions="Address1controller">

    <script type="text/javascript">
    function setRequired(countryvar) {
       
    var country = document.getElementByID(countryvar);
   
    reRenderBlock(country);
 
    }
    </script>

      <apex:form id="theForm">

          <apex:actionFunction name="reRenderBlock" action="{!setzipcoderequired}">
              <apex:param id="country" name="country" value="" />
          </apex:actionFunction>

      <apex:pageBlock id="thePageBlock">
      <apex:pageBlockSection id="thePageBlockSection">
      <apex:inputField id="country" value="{!Address1__c.Billing_Country__c}"  onchange="setRequired({!$Component.country});"/>
      <apex:inputField id="zipcode" value="{!Address1__c.Billing_Zip__c}" required="{!check}"/>
      <apex:commandButton action="{!Save}" value="Save"/>

      </apex:pageBlockSection>

      </apex:pageBlock>
      </apex:form>
    </apex:page>
Hi,

I'm trying to use apex:repeat to loop through the list of contacts attached to a opportunity (through the account), but I'm getting an error.  I assume my dot notation is messed up.

What I have is
 
<apex:repeat value="{!Opportunity.account.contacts}" var="con">

Thanks,
How to hide "Save & New Task" button from task page layout.
User-added image
I recently inherited a Salesforce org with almost no code coverage. I am trying to write some test classes for the triggers already in production. The test keeps failing with the below error and I think it is related to the trigger. Can someone shed some light on the below error? My developer skils are very basic.

Test Class:
@isTest
public class Test_OppWonChatter {
    static testMethod void insertNewOpportunity(){

        Opportunity o = new Opportunity();
        o.name = 'Test';
        o.AccountId = '0015500000GE3OS';
        o.StageName = 'Closed Won';
        o.CloseDate = date.today();
        o.Type = 'New Customers';
        
        insert o;
    }
}



Error:
Time Started8/22/2016 2:57 PM
ClassTest_OppWonChatter
Method NameinsertNewOpportunity
Pass/FailFail
Error MessageSystem.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, OppWonChatter: execution of AfterInsert

caused by: System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []

Trigger.OppWonChatter: line 31, column 1: []
Stack TraceClass.Test_OppWonChatter.insertNewOpportunity: line 12, column 1

Trigger:
trigger OppWonChatter on Opportunity (after insert, after update) {

String status;
String OppAccName;
String OppOwnerName;
String OppName;   
FeedItem post = new FeedItem();
    
    for(Opportunity o : Trigger.new) {
        if(o.OwnerId == '00560000001NLvS') { //It will not post record for for this user to group. Accountsys
            return;
        }
        else { 
            if(Trigger.isInsert ) { 
                if( o.IsWon == true ) { //This will be executed on new record insertion 
                    for (Opportunity oppty : [SELECT Account.Name, Owner.Name, Name FROM Opportunity WHERE Id =:o.Id] ) {
                        OppAccName = oppty.Account.Name;
                     OppName = oppty.Name;
                    
                        
                        OppOwnerName = oppty.Owner.Name;
                    }   
                    
                    status = OppOwnerName + ' just won ' + OppName + '!';

                                                             
                    post.ParentId = '0F960000000Xbrr';
                    post.Title = o.Name;   
                    post.Body = status;
                    
                    insert post;
                }
            }    
            else {
                if ( Trigger.isUpdate ) {
                    if( o.IsWon == true ) { //This will be executed on update to existing record
                        for (Opportunity oppty : [SELECT Account.Name, Owner.Name, Name FROM Opportunity WHERE Id =:o.Id] ) {
                            OppName = oppty.Name;
                            OppAccName = oppty.Account.Name;  
                            OppOwnerName = oppty.Owner.Name; 
                        }        
                        status = OppOwnerName + ' just won ' + OppName + '!';
                                            
                        post.ParentId = '0F960000000Xbrr';
                        post.Title = o.Name;
                        post.Body = status;
                        
                        insert post;      
                    }
                }
            }
        }
    }    
}

 
Hi All,


Q). you have two salesforce account and insertion of contact in one account u need to insert in other account and vice versa for update how we can achieve ?

Can anyone reply for this post.

Thanks in advance..
Hi,

I have a trigger on Contact that will trigger an update on Account as below:
 
trigger calAccountLifeCycleStatus on Contact (after insert, after update) {
    List<id> acc_ids = new List<id>();
    List<Account> acc_toUpdate = new List<Account>();
    
    if(trigger.isInsert){
        for(Contact ctc : Trigger.new){
            acc_ids.add(ctc.AccountId);
        }
        
    }

    if(acc_ids.size() > 0){
        
        for(Account acc: [Select id, CalculateALC__c from Account where id in: acc_ids]){
            acc.CalculateALC__c = true;
            acc_toUpdate.add(acc);
        }
    }
    
    if(acc_toUpdate.size() > 0){
        update acc_toUpdate;
    }

}
then in my account i have this triggger -> class

my account trigger
trigger AccountLifeCycleUpdate on Account (before update) {
    AccountLifeCycleCal.calculate(trigger.New ,Trigger.NewMap, Trigger.OldMap);
}
my apex class
public without sharing class AccountLifeCycleCal{
     
    public static void calculate( List<Account> newAcc, Map<ID, Account> newAccMap, Map<ID, Account> oldAccMap){
		Map<Id, String> AccountStatusMap = new Map<Id, String>();
	
		for(Account acc_trigger: newAcc){
		
			if(acc_trigger.CalculateALC__c == true){
					acc_ids.add(acc_trigger.id);
			}
		}
				
		for(Account acc: [select id, name, Status__c,(select id, contact_type__c from Contacts) from Account where Id IN :acc_ids])
        {
			String AccountStatus = '';
			
			for(Contact c : acc.contacts){
				if(c.contact_type__c = 'A'){
					AccountStatus = 'customer';
					break;
				}			
			}			
			AccountStatusMap.put(acc.id, AccountStatus);
		}
		
		for(Account upd_acc: newAcc){
            if(acc_ids.size() > 0){
				upd_acc.Status__c = AccountStatusMap.get(upd_acc.id);
			}
		}
	}
}

when i do a batch import of 50k contacts, i kept getting this error 'unable to obtain exclusive access to this record' but when i import this error file again and it go through but still not all imported, still left a portion of contacts with that error, then i keep repeat import the error file.

is it due to the the trigger above?

Thanks.



 
I have an VisualForce page set up like this:
<apex:actionPoller interval="5" reRender="panel" action="{!getPanelRecords}"/>

<apex:outputPanel id="panel">
    <button onClick = "btnClick(this,'blue');" value="Change me blue"/>
    <button onClick = "btnClick(this,'red');" value="Change me red"/>
</apex:outputPanel>

<script>
    function btnClick(element, color) {
        this.attr('color', color);
    }
</script>

When I click the button, it will change color, But due to the panel getting rerendered, it will not persist between refreshes.

I was thinking of using the actionPoller onComplete event to get a list of id's and set the colors accordingly, but I'm not sure if there's an easier/better way to achieve this.

Can anybody recommend how to store the changed CSS on multiple elements between refreshes?
Hello all!
I am attempting to switch the default opportunity list view in Lightning from "recent" to "my open opportunities".  I have created a VF page, and adjusted the tab to show the VF page instead of the default.  I think I'm almost there, but 2 issues.
1.  The page displayed is classic with a lightning header.  I would like it to be displayed as a lightning page.
2.  The displayed list is not "my open opportunities".
my VF page code is as follows:
<apex:page showHeader="true" tabstyle="Opportunity">
<apex:ListViews type="Opportunity" />
</apex:page>

any assistance on this is appreciated.
I created a new sandbox and tried to log into it.  I used my production password but it did not work.  When I try to have salesforce email me my new password setup routine I don’t receive the email.  My thought is that the email the new sandbox has is not my correct email.  It appends the name of my sandbox to the end of it.  I saw this before.  Our other admin could get into the last sandbox and fix my email for me, however he cannot get in this time.  Any ideas how to get around this salesforce bug?
 
Hello,

We regularly export ou Contacts to send them. We use the data loader in command line to query the contacts that were not updated by the tech user, with the following SOQL query

select Id, [some other fields]
FROM Contact
WHERE LastModifiedDate = LAST_N_DAYS:3
AND LastModifiedById != '[Id of the tech user]'


Because there are more than 10 millions records in the database (but only a few of the in the expected result), the query takes some time (14s) and even times out. We tried to optimize the query by checking the developer guide ( https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_SOQL_VLSQ.htm) with a couple of solutions of our own.

For instance we tried to use a "LastModifiedBy.ProfileId IN (...)" filter. We also created a checkbox to turn the negation form into a postive form : "LastModified.TechnicalUser__c == true". But in both cases, the result was slower (18s) than our first query and still had some timeout.

I was thinking about asking the support for a custom index on the User.TechnicalUser__c field but this can only be requested by their developer's team. Is there any way to improve the performance our query?