• Surender
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 75
    Questions
  • 24
    Replies
Urgently needed test class for the below class.

Apex:

public class ContactRelatedListController {
    Account account;
    ApexPages.StandardSetController controller;
    Public Integer size{get;set;}
    Public Integer noOfRecords{get; set;}
    Public Integer overallListSize = 0;
    Public String isAllowedToCreateContact{get;set;}
    public string accountId {get;set;}
    //public string selectedContactId {get;set;}
    public String selectedContactId;
    private User userAndCompanyInfo{get;set;}
    public string userId {get;set;}
    
    
    public ContactRelatedListController(ApexPages.StandardController controller) {
        userAndCompanyInfo = SupportCommunityUtility.getCompanyInfo();
        accountId = userAndCompanyInfo.AccountId;
        // account = (Account)controller.getRecord();
        string currentProfileId = userinfo.getProfileId();
        System.debug('$$$ current user profile : '+currentProfileId);
        if(currentProfileId.startsWith('00e70000001K2HI') || currentProfileId.startsWith('00e70000001JsCp') || currentProfileId.startsWith('00e70000000ox3X'))
        {
            isAllowedToCreateContact = 'block';
        }
        else
        {
            isAllowedToCreateContact = 'none';
        }
           
    }
    
    /*public pageReference ShowAll() {
        controller.setPageSize(controller.getResultSize());
        return null; 
    } */

    public List<CustomerContactListUtility> getActiveContactsList()
    {
        List<CustomerContactListUtility> contactsList = new List<CustomerContactListUtility>();
        Integer atRatePosition;
        string nickName;
        string alias;
        string enableUrl;
        Map<Id,User> contactUserMap = new Map<Id,User>();
        Set<id> contactIds = new Set<id>();
        for(Contact contact : (list<Contact>)setCon.getRecords()){
            contactIds.add(contact.Id);
        }
        for(User user : [select id,ContactId from user where ContactId =: contactIds]){
            contactUserMap.put(user.ContactId,user);
        }
        for(Contact contact : (List<Contact>)setCon.getRecords()) {   
            
            CustomerContactListUtility contactList = new CustomerContactListUtility();               
            contactList.EditContactUrl = '/'+contact.Id;
            contactList.Id = contact.Id;
            contactlist.UserProfile = contact.User_Profile__c;
            contactList.Region = contact.Region__c;
            contactList.Email = contact.Email;
            if(contactUserMap.get(contact.Id) != null){
                contactList.ContactUser = 'Change Access';
               // User currentUser = contactUserMap.get(contact.Id);
               // contactList.ChangeAccessUrl = '/_ui/core/portal/PortalUserManagePage/e?id='+currentUser.Id+'&retURL=%2F'+accountId;
                User currentUser = contactUserMap.get(contact.Id);
                  contactList.ChangeAccessUrl = '/_ui/core/portal/PortalUserManagePage/e?id='+currentUser.Id+'&retURL=/apex/ShowContactsPage?id='+accountId+'-'+currentUser.Id;
                string userProfile = ApexPages.currentPage().getParameters().get('id');
                system.debug('userProfile: '+userProfile);
                if(userProfile.contains('-')){
                    string[] userId = userProfile.split('-');
                    if(userId.size() > 1){
                        User existingUser = contactUserMap.get(contact.Id);
                        system.debug('existingUser.Id '+existingUser.Id);
                        system.debug('userId[1] '+userId[1]);
                        if(userId[1] == existingUser.Id){
                            User user = [select id,profile.name from user where id =: userId[1]];
                            Contact cont = [select Name,Email,Phone,Region__c from contact where Id =: contact.Id];
                            contactList.UserProfile = user.Profile.Name;
                            contactList.Phone = cont.Phone;
                            contactList.Region = cont.Region__c;
                            contactList.Email = cont.Email;
                            contactList.Name = cont.Name;
                            system.debug('fetched user: '+cont.name+' '+cont.Phone+' '+cont.Region__c+' '+cont.Email);
                        }
                       else{
                           contactList.UserProfile = contact.User_Profile__c;
                       }
                    }
                   else{
                       contactList.UserProfile = contact.User_Profile__c;
                   }
                    system.debug('url id: '+userId);
                }
               
                if(contact.Phone != null){
                    EnableUrl += '&Phone='+contact.Phone;
                    contactList.Phone = string.valueOf(contact.Phone);
                }                
                string sessionId = UserInfo.getSessionId();
                contactList.RemoveUrl = '/_ui/core/portal/DisableCSPUserPage/e?save=1&id='+currentUser.Id+'&id='+contact.Id+'&cntc='+contact.Id+'&_CONFIRMATIONTOKEN='+sessionId;
               // contactList.ChangeAccessUrl = 'openChangeAccess();';
            }
            else{
                contactList.ContactUser = 'Enable';
                if(contact.Email != null){
                    atRatePosition = contact.Email.indexOf('@');
                    nickName = contact.Email != null ? string.valueOf(contact.Email).substring(0,atRatePosition) : null;
                }
               else nickName = null;
                EnableUrl = '/_ui/core/portal/PortalUserManagePage/e?ut=c&retURL=%2F'+accountId+'&retURL=%2F'+contact.Id+'&cntc='+contact.Id; 
                
                
            if(contact.FirstName != null){
                alias =  string.valueOf(contact.FirstName).substring(0,1) + string.valueOf(contact.Lastname).substring(0,3);    
            }
           else{
               alias = string.valueOf(contact.LastName).subString(0,4);
           }
           EnableUrl += '&Alias='+Alias+'&CommunityNickname='+nickName;
            //alias = contact.FirstName != '' ? string.valueOf(contact.FirstName).substring(0,1) + string.valueOf(contact.Lastname).substring(0,3) : contact.LastName;            
                if(contact.Email != null){
                    EnableUrl += '&Email='+contact.Email+'&Username='+contact.Email;
                    contactList.Email = string.valueOf(contact.Email); 
                }
                if(contact.Title != null){
                    EnableUrl += '&Title='+contact.Title;
                    contactList.Title = string.valueOf(contact.Title);
                }
                if(contact.Phone != null){
                    EnableUrl += '&Phone='+contact.Phone;
                    contactList.Phone = string.valueOf(contact.Phone);
                }
                if(contact.Fax != null){
                    EnableUrl += '&Fax='+contact.Fax;
                    contactList.Fax = string.valueOf(contact.Fax);
                }
                if(contact.MobilePhone != null){
                    EnableUrl += '&MobilePhone='+contact.MobilePhone;
                    contactList.MobilePhone = contact.MobilePhone;
                }
                if(contact.LastName != null){
                    EnableUrl += '&name_lastName='+contact.LastName;
                    contactList.MobilePhone = contact.LastName;
                }
                if(contact.MailingStreet != null){
                    EnableUrl += '&Addressstreet='+contact.MailingStreet;
                    contactList.MailingStreet = contact.MailingStreet;
                }
                if(contact.MailingCity != null){
                    EnableUrl += '&Addresscity='+contact.MailingCity;
                    contactList.MailingCity = contact.MailingCity;
                }
                if(contact.MailingState != null){
                    EnableUrl += '&Addressstate='+contact.MailingState;
                    contactList.MailingState = contact.MailingState;
                }
                if(contact.MailingPostalCode != null){
                    EnableUrl += '&Addresszip='+contact.MailingPostalCode;
                    contactList.MailingPostalCode = contact.MailingPostalCode;
                }
                if(contact.MailingCountry != null){
                    EnableUrl += '&Addresscountry='+contact.MailingCountry;
                    contactList.MailingCountry = contact.MailingCountry;
                } 
                }    
                contactList.Name = contact.Name;          
                contactList.EditUrl = '/'+contact.Id+'/e?retURL=%2F'+accountId;
                contactList.EnableUrl = EnableUrl;
                
            contactsList.add(contactList);
           }
           system.debug('contactsList: '+contactsList);
           overallListSize = contactsList.size();
        return contactsList;
    }    
    public ApexPages.StandardSetController setCon {
        get{
            if(setCon == null){
                size = 5;
                System.debug('@@@ accountId = '+accountId);
                if(accountId == null)
                {
                    return null;
                }
                string queryString = 'select Id,FirstName,LastName,Name,User_Profile__c,Support_Role__c,Region__c,Phone,Email,Preferred_Language__c, Fax, HomePhone, MailingAddress, MailingCity, MailingCountry, MailingPostalCode,MailingState, MailingStreet, MobilePhone, Title from Contact where accountId = :accountId and Inactive__c = false order by Name';
                setCon = new ApexPages.StandardSetController(Database.getQueryLocator(queryString));
                setCon.setPageSize(size);
                noOfRecords = setCon.getResultSize();
            }
            return setCon;
        }set;
    }
    public pageReference refresh() {
        setCon = null;
        getActiveContactsList();
        setCon.setPageNumber(1);
        return null;
    }
    public void setNextPageSize()
    {
        Integer currentPageSize = setCon.getPageSize();
        setCon.setPageSize(currentPageSize + currentPageSize);
    }
   
   public void disableContactUser(){
        setCon = null;
        getActiveContactsList();
        setCon.setPageNumber(1);            
    }
   
   public String getselectedContactId(){
        return selectedContactId;
    }
   
    public void setselectedContactId(String selectedContactId){
        System.debug('ppsr'+selectedContactId);
        this.selectedContactId = selectedContactId;
    }   
}


Test Class:

public class ContactRelatedListControllerTest{

  static testMethod void tesCongtactsDisplay() {
       Account TestAccount = new Account(Name = 'Initech', Type = Utility.SITE_ACCOUNT_TYPE, BillingCountry = 'USA');
       insert TestAccount;
       
       // Create two contacts with same account
       Contact contact1 = new Contact(FirstName = 'TestFirstName1', LastName = 'TestLastName2', email = 'test1@jda.com.test', accountId = TestAccount.Id, MailingCountry = 'USA');
       Contact contact2 = new Contact(FirstName = 'TestFirstName1', LastName = 'TestLastName2', email = 'test2@jda.com.test', accountId = TestAccount.Id, MailingCountry = 'USA');
       List<Contact> contactList = new List<Contact>{contact1, contact2};
       insert contactList;        
       
       //ApexPages.StandardSetController ob=new ApexPages.StandardSetController();
       //ob.SetCon(TestAccount);
       
       ApexPages.StandardSetController con = new ApexPages.StandardSetController(Database.getQueryLocator([select Id,Name from Account WHERE Id =: TestAccount.Id]));
       
       ApexPages.StandardController ContactsList= new ApexPages.standardController(TestAccount);
       ContactRelatedListController obj= new ContactRelatedListController(ContactsList);   
       obj.getActiveContactsList();
       
         
  }
}


I wrote the above test class but it is failing with NullPointerException for SetCon property.


Can someone help me in writing test class in achieving 100% code coverage.

Feedback is appreciated.

 
Hi,

We are in the process of enabling critical updates in our production environment. Before activating critical updates we want to ensure what impact it might cause. I have found review description for the 'Enable clickjack protection for non-setup Salesforce pages'. But can you eloborate me that how this critical update impacts environment. Also it would be great that what components/sections that we need to check to avoid impact of this critical update.

Regards
G.Surender
Hi,

We are in the process of enabling critical updates in our production environment. Before activating critical updates we want to ensure what impact it might cause. I have found review description for the 'Enable CSRF protection on GET and POST requests'. But can you eloborate me that how this critical update impacts environment. Also it would be great that what components/sections that we need to check to avoid impact of this critical update.

Regards
G.Surender
Hi,

We are in the process of enabling critical updates in our production environment. Before activating critical updates we want to ensure what impact it might cause. I have found review description for the 'Require secure connections (HTTPS)'. But can you eloborate me that how this critical update impacts environment. Also it would be great that what components/sections that we need to check to avoid impact of this critical update.

Regards
G.Surender


Hi,

 

If we modify related list like dependent opportunities on a opportunity used to update LastModifiedDate on a opportunity and on parent opportunity as well.

 

But today when i modify/delete dependent opportunies on a opportunity then it is not updating the LastModifiedDate on parent opportunities.

 

I have checked this bahaviour in Sandbox environment.

 

Can anyone know the reason for why it is not happening so?

 

Your feedback is appreciated.

 

Regards

Surender

 

Hi,

 

We need test class code for the below controller class satisfying all the criterias urgently.

 

public class TestController {

public PageReference save() {

Integer CountofWs;
Integer CountofAs;
Map<ID,Integer> W = new Map<ID,Integer>();
Map<ID,Integer> A = new Map<ID,Integer>();
List<Opportunity> FinOpp = new List<Opportunity>();
List<Opportunity> FlagOpp = new List<Opportunity>();
List<Opportunity> UnFlagOpp = new List<Opportunity>();
List<OpportunityLineItem> AllOps = new List<OpportunityLineItem>();

Datetime endd = Datetime.now();
Datetime start = Datetime.now().addHours(-1);

//Get all the Opportunities which are modified an hour ago
List<Opportunity> opptys = [SELECT o.Id,o.Name, o.Type, o.AccountId,o.StageName, o.Cloud_Attached__c, o.Parent_Opportunity__c FROM Opportunity o WHERE o.LastModifiedDate>= : start and o.LastModifiedDate<= : endd];
if(!opptys.isEmpty()) {
System.debug('Opportunity List'+opptys);
for(Opportunity oppty :opptys){
//get all the Parent Opportunities first
if(oppty.Parent_Opportunity__c!=null){
if(!w.containsKey(oppty.parent_Opportunity__c)){
W.put(oppty.parent_Opportunity__c, 0);
A.put(oppty.parent_Opportunity__c, 0);
}
}
if(!w.containsKey(oppty.Id)){
W.put(oppty.Id, 0);
A.put(oppty.Id, 0);
}

}//for

System.debug(' A Keyset - :'+ A.keyset()+' W Keyset - :' + W.keyset()+' :W Keyset is Empty ?'+W.isEmpty()+' W Size : '+ W.size());

if(W.size()>0){
//Get all Children of All Unique Parent Id's collected
AllOps = [Select Opportunity.id, Opportunity.StageName, Opportunity.Type,Opportunity.Cloud_Attached__c, Opportunity.parent_Opportunity__c,OpportunityLineItem.PricebookEntry.Product2.Supplier__c from Opportunitylineitem where Opportunity.parent_Opportunity__c in :W.keyset()];

System.debug('Step 1.3 AllOps - :'+AllOps);
// Calculate how many W's and A's each parent has
for(Integer i=0; i<AllOps.size(); i++){
CountofWs = 0;
CountofAs = 0;
if (AllOps.size()>0){
if (AllOps.get(i).Opportunity.parent_Opportunity__c!=NULL){
if (AllOps[i].PricebookEntry.Product2.Supplier__c==NULL || AllOps[i].PricebookEntry.Product2.Supplier__c=='Cloud - Long Term'){
if (AllOps[i].Opportunity.Type.contains('Cloud') && AllOps[i].Opportunity.StageName=='Won'){
system.debug('Step 1.4 AllOps - :'+AllOps[i]);
CountofWs = W.get(AllOps[i].Opportunity.parent_Opportunity__c);
CountofWs = CountofWs+1;
//system.debug('Step 1.5 - ' + CountofWs);
W.put(AllOps[i].Opportunity.parent_Opportunity__c, CountofWs);
}
system.debug('Step 1.7 - Ws'+W.values());
if (AllOps[i].Opportunity.Type.contains('Cloud') && AllOps[i].Opportunity.StageName<>'Won'){
System.debug('Step 1.4 AllOps - :'+AllOps[i]);
CountofAs = A.get(AllOps[i].Opportunity.parent_Opportunity__c);
CountofAs = CountofAs+1;
//system.debug('Step 2 - '+CountofAs);
A.put(AllOps[i].Opportunity.parent_Opportunity__c, CountofAs);
//W.put (AllOps[i].parent_Opportunity__c, 0);
//CountofAs = 0;
}
system.debug('Step 2.1 - As'+A.values());
}//if
}//if
}//if
}//for

Set<ID> Oppidset = W.keyset();
System.debug('Step 3 - Keyset' + Oppidset);
List<ID> Oppidlist = new List<ID>();
Oppidlist.addAll(Oppidset);
System.debug('Step 4 - Keylist' + Oppidlist);
for(Integer i=0; i<Oppidlist.size(); i++){
Opportunity Opp = new Opportunity(id=Oppidlist.get(i), Cloud_Attach_TriggerRun__c=True);
FlagOpp.add(Opp);
}

for(Integer i=0; i<Oppidlist.size(); i++){
System.debug('Step 4.5 - Oppidlist : ' + Oppidlist.get(i));
System.debug('Step 4.5 - W-Value : ' + W.get(Oppidlist.get(i)));
System.debug('Step 4.5 - A-Value : ' + A.get(Oppidlist.get(i)));

if (W.get(Oppidlist.get(i))>=A.get(Oppidlist.get(i)) && W.get(Oppidlist.get(i))>0){
Opportunity Opp = new Opportunity(id=Oppidlist.get(i), Cloud_Attached__c='W');
FinOpp.add(Opp);
System.debug('Step 5 - FinOppWs' + FinOpp);
}
if (A.get(Oppidlist.get(i))>W.get(Oppidlist.get(i))){
Opportunity Opp = new Opportunity(id=Oppidlist.get(i), Cloud_Attached__c='A');
FinOpp.add(Opp);
System.debug('Step 6 - FinOppAs' + FinOpp);
}
if (A.get(Oppidlist.get(i))==0 && W.get(Oppidlist.get(i))==0){
Opportunity Opp = new Opportunity(id=Oppidlist.get(i), Cloud_Attached__c='');
FinOpp.add(Opp);
System.debug('Step 7 - FinOppWithNulls' + FinOpp);
}
}//for

for(Integer i=0; i<Oppidlist.size(); i++){
Opportunity Opp = new Opportunity(id=Oppidlist.get(i), Cloud_Attach_TriggerRun__c=False);
UnFlagOpp.add(Opp);
}

System.debug('Step 7 - FinOpp' + FinOpp);
Update FlagOpp;
Update FinOpp;
Update UnFlagOpp;
}//if (w.size()>0)

}//if

return null;
}//save
}//class

 

Any help is appreciated.

 

Regards

Surender

Hi,

 

I have a requirement like i want to display value in inputText fields based on selection of checkboxes in the same line.

 

Below is vf page code which has checkboxes incorporated.

<apex:PageBlock >
     <apex:pageBlockSection columns="1"  >
         <apex:outputPanel id="modulesPanel">
             <apex:outputLabel value="Select the Modules :">
                 <apex:selectCheckboxes value="{!selectedField}" layout="pageDirection">
                     <apex:SelectOptions value="{!items}"/>
                 </apex:selectCheckboxes>
            </apex:outputLabel>
         </apex:outputPanel>
     </apex:pageBlockSection>
 </apex:PageBlock>
 

How can i show inputText fields in the sameline of checkboxes based on selection.

Also the number of the checkboxes is not fixed and it can vary based on other fields.

 

Please help me in achieving the above.

Hi,

 

Can someone share code snippet to send private message in chatter using ChatterMessage object.

We need code snippet for doing this in Apex only.

 

Thanks in advance. 

Hi,

 

I want to add subscriberId's into a list of Id's.

 

below is the code for the same.

 

List<Id> usr=new List<Id>();
AggregateResult[] sub= [select subscriberId from EntitySubscription group by SubscriberId having count(ParentId)>= 500];
for (AggregateResult ar : sub)
usr.add(ar.get(subscriberId));

 

but i'm getting error like Variable does not exist: subscriberId.

 

Can someone correct the above.

 

Thanks in advance.

Hi,

 

 

I have the below code which will send feed post to some particular user. 

 

 

string msg = 'You have automatically swarmed an Opportunity.'+  '\n' +
                       'Opportunity Name : ' + thisOppty.Name+ '\n' + 
                       'Account : ' + thisOppty.Account.Name + '\n' +
                       'Type : ' + thisOppty.Type + '\n' +
                       'Close Date : ' + dateStr + '\n' +
                       'Owner : ' + thisOppty.Owner.Name;
                                
FeedItem swarmNotification = new FeedItem();
swarmNotification.Type = 'LinkPost';
swarmNotification.ParentId = rule.User__c;
swarmNotification.Title = 'Link to Opportunity Record '+thisOppty.Name+' Swarmed';
swarmNotification.Body = msg;
swarmNotification.LinkUrl = URL.getSalesforceBaseUrl().toExternalForm() + '/' + thisOppty.Id;
feedNotifications.add(swarmNotification);

 

But we have problem with the above like the feed post is sent to particular user and the users who are following that user.

 

Can we send private feed post only to that particular user.

 

Share some code snippets for better understanding.

 


Hi,

Can someone help me in writing webservices in Java.

I am interested in updating fields of certain objects through web services and how to publish web services in salesforce.

Share sample code snippets for better understanding.

 

 

 

 

 

 

Hi,

 

I have 6 checkboxes in VF page like below..

 

<apex:selectCheckboxes id="step1Options" value="{!step1}" onclick="hideAllTest()" layout="pageDirection" >
<apex:selectOption itemValue="AA1" itemLabel="AA1" />
<apex:selectOption itemValue="AA2" itemLabel="AA2" />
<apex:selectOption itemValue="AA3" itemLabel="AA3" />

 

<apex:selectOption itemValue="BB1" itemLabel="BB1" />
<apex:selectOption itemValue="BB2" itemLabel="BB2" />
<apex:selectOption itemValue="BB3" itemLabel="BB3" />
</apex:selectCheckboxes>

 

I have a requirement like i want 2 radio buttons and each radio button can include 3 checkboxes of the above( one radio button have AA group checkboxs and other is to have BB group checkboxes).

 

I want to display those 3 chexkboxes only on the selection of the radio button.

 

Can someone reply on how can we accomplish the above with some code snippets.

 

Thanks in advance.

 

 

 

 

Hi,

 


I have SOQL which retrieves 20 User records. I have a requirement to store User names in an String array with iterating these 20 records.


Can someone reply on how to accomplish this.

 

Thanks in advance.

 

 

Hi,

 

We want to implement some functionality only for Chatter Free users.


when we create new user, User License has Chatter free and Salesforce picklist values.


But we didn't find User License field in the User object.


We need soql to get only Chatter free users in the Apex, can someone post it.

 

Thanks in Advance.. 

Hi,

 

We want to implement some emails for Chatter Free users who have not taken training/acknowledged the policy.

 

o After 7 days, an email is generated from Salesforce to the user reminding them to take training/sign off policy.

 

o After 14 days, we would like to generate another email to the user, and one to the user’s manager. We understand the application cannot send to the manager, but we would like to see what can be done outside the application, keying off the email address and referencing Active Directory.

 

o After 30 days, we want to deactivate the user from Chatter Free if they still have not taken training/acknowledged the policy.

Can some one send us soql for the above three categories to proceed further.

Thanks in advance..

Hi,

 

We want to implement some emails for Chatter Free users who have not taken training/acknowledged the policy.

 

o After 7 days, an email is generated from Salesforce to the user reminding them to take training/sign off policy.

 

o After 14 days, we would like to generate another email to the user, and one to the user’s manager. We understand the application cannot send to the manager, but we would like to see what can be done outside the application, keying off the email address and referencing Active Directory.

 

o After 30 days, we want to deactivate the user from Chatter Free if they still have not taken training/acknowledged the policy.

 

Can some one send us soql for the above three categories to proceed further.

 

Thanks in advance..

Hi,

 

I'm getting System.LimitException: Too many script statements for the below Apex Code:

 

Apex Code:
public class OpportunitySalesTeamSwarmHelper {

public static void evaluateOpptySalesTeamRules() {

// Get list of Opptys with opp, acc, owner details
List<Opportunity> opptys = [SELECT o.Id, o.Name, o.Type, o.AccountId, Account.Name,Account.OwnerId, Account.JDA_Industry__c,
Account.Named_Account__c,Account.Target_Rating__c, o.StageName, o.Amount,o.CurrencyIsoCode, o.Local_Region_Override__c,o.CloseDate, o.Business_Unit__c,
o.OwnerId, o.Owner.Name, o.Owner.Reports_To__c FROM Opportunity o WHERE o.StageName like 'open'];

// Get list of all rules
List<Opportunity_Swarm_Rule__c> rules = [select Name,type__c, Opportunity_amount__c, Opportunity_stage__c,
Opportunity_type__c, Opportunity_Local__c,Opportunity_Business_Unit__c,JDA_Industry__c, user__c,
ownerId, Notify_on_Swarm__c from Opportunity_Swarm_Rule__c WHERE user__r.IsActive = true];

// Get all subscriptions and put in string concatenating subscriber + object ID
List<EntitySubscription> existingOpptySubs = [select SubscriberId, ParentId from EntitySubscription where ParentId in :opptys];

Set<String> existingOpptySubsIds = new Set<String>();
for (EntitySubscription es:existingOpptySubs) {
existingOpptySubsIds.add((String)es.SubscriberId + es.ParentId);
}//for

List<OpportunityTeamMember> opptySalesTeams = [SELECT UserId from OpportunityTeamMember where OpportunityId in :opptys];

// Create a list of subscripions and chatter feeds and insert them later outside the loop
List<EntitySubscription> subs = new List<EntitySubscription>();
List<FeedItem> feedNotifications = new List<FeedItem>();

// For each oppty check all rules.
// If criteria is satisfied, make the user of rule to follow the opportunity
Integer count = 0;
for (Opportunity thisOppty : opptys) {
count++;
System.debug('The value of Count is'+count);
for (Opportunity_Swarm_Rule__c rule : rules) {

if(rule.Type__c.contains('Opptys where I am an Account Team Member')) {

boolean salesTeamFlag = false;
boolean condition = false;
for (OpportunityTeamMember opptySalesTeam : opptySalesTeams) {
if(rule.User__c == opptySalesTeam.UserId ){
salesTeamFlag=true;
}
if(salesTeamFlag)
break;
}

condition= salesTeamFlag;
System.debug('The value of Condition - Opptys where I am Sales Team Member is : '+condition);

if(condition) {
if (existingOpptySubsIds.contains((string)rule.User__c + thisOppty.Id) == FALSE) {
subs.add(new EntitySubscription(parentId = thisOppty.id, SubscriberId = rule.User__c));
existingOpptySubsIds.add((String)rule.User__c + thisOppty.id);

// Add swarming notification to user's feed
if (rule.Notify_on_Swarm__c == true) {
//displaying close datetime as only date string
Datetime dateTimetemp = thisOppty.CloseDate;
Date dateTemp = Date.newInstance(dateTimetemp.year(),dateTimetemp.month(),dateTimetemp.day());
String dateStr = dateTemp.format();

string msg = 'You have automatically swarmed an Opportunity.'+ '\n' +
'Opportunity Name : ' + thisOppty.Name+ '\n' +
'Account : ' + thisOppty.Account.Name + '\n' +
'Type : ' + thisOppty.Type + '\n' +
'Close Date : ' + dateStr + '\n' +
'Owner : ' + thisOppty.Owner.Name;

FeedItem swarmNotification = new FeedItem();
swarmNotification.Type = 'LinkPost';
swarmNotification.ParentId = rule.User__c;
swarmNotification.Title = 'Link to Opportunity Record '+thisOppty.Name+' Swarmed';
swarmNotification.Body = msg;
swarmNotification.LinkUrl = URL.getSalesforceBaseUrl().toExternalForm() + '/' + thisOppty.Id;
feedNotifications.add(swarmNotification);
}// if 3
}//if 2
}//if 1
}

}//for 2

}//for 1 oppty's
try {
System.Debug('Subscription count : ' + subs.size());
insert subs;
insert feedNotifications;
} catch (DMLException e) {
system.debug('Oppty Swarm subscriptions were not all inserted successfully. Error: '+e);
}//catch
}//evaluateOpptyRules

}//class

 

Below is debug log info:
01:42:46.811|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 4 out of 100
Number of query rows: 6698 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of DML rows: 0 out of 10000
Number of script statements: 200002 out of 200000 ******* CLOSE TO LIMIT
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

 

Can someone look at the code and please share your thoughts to overcome the above exception..

 

Thanks in advance..


Hi,

 

I'm getting System.LimitException: Too many script statements for the below Apex Code:

 

Apex Code:

public class OpportunitySalesTeamSwarmHelper {

public static void evaluateOpptySalesTeamRules() {

// Get list of Opptys with opp, acc, owner details
List<Opportunity> opptys = [SELECT o.Id, o.Name, o.Type, o.AccountId, Account.Name,Account.OwnerId, Account.JDA_Industry__c,
Account.Named_Account__c,Account.Target_Rating__c, o.StageName, o.Amount,o.CurrencyIsoCode, o.Local_Region_Override__c,o.CloseDate, o.Business_Unit__c,
o.OwnerId, o.Owner.Name, o.Owner.Reports_To__c FROM Opportunity o WHERE o.StageName like 'open'];

// Get list of all rules
List<Opportunity_Swarm_Rule__c> rules = [select Name,type__c, Opportunity_amount__c, Opportunity_stage__c,
Opportunity_type__c, Opportunity_Local__c,Opportunity_Business_Unit__c,JDA_Industry__c, user__c,
ownerId, Notify_on_Swarm__c from Opportunity_Swarm_Rule__c WHERE user__r.IsActive = true];

// Get all subscriptions and put in string concatenating subscriber + object ID
List<EntitySubscription> existingOpptySubs = [select SubscriberId, ParentId from EntitySubscription where ParentId in :opptys];

Set<String> existingOpptySubsIds = new Set<String>();
for (EntitySubscription es:existingOpptySubs) {
existingOpptySubsIds.add((String)es.SubscriberId + es.ParentId);
}//for

List<OpportunityTeamMember> opptySalesTeams = [SELECT UserId from OpportunityTeamMember where OpportunityId in :opptys];

// Create a list of subscripions and chatter feeds and insert them later outside the loop
List<EntitySubscription> subs = new List<EntitySubscription>();
List<FeedItem> feedNotifications = new List<FeedItem>();

// For each oppty check all rules.
// If criteria is satisfied, make the user of rule to follow the opportunity
Integer count = 0;
for (Opportunity thisOppty : opptys) {
count++;
System.debug('The value of Count is'+count);
for (Opportunity_Swarm_Rule__c rule : rules) {

if(rule.Type__c.contains('Opptys where I am an Account Team Member')) {

boolean salesTeamFlag = false;
boolean condition = false;
for (OpportunityTeamMember opptySalesTeam : opptySalesTeams) {
if(rule.User__c == opptySalesTeam.UserId ){
salesTeamFlag=true;
}
if(salesTeamFlag)
break;
}

condition= salesTeamFlag;
System.debug('The value of Condition - Opptys where I am Sales Team Member is : '+condition);

if(condition) {
if (existingOpptySubsIds.contains((string)rule.User__c + thisOppty.Id) == FALSE) {
subs.add(new EntitySubscription(parentId = thisOppty.id, SubscriberId = rule.User__c));
existingOpptySubsIds.add((String)rule.User__c + thisOppty.id);

// Add swarming notification to user's feed
if (rule.Notify_on_Swarm__c == true) {
//displaying close datetime as only date string
Datetime dateTimetemp = thisOppty.CloseDate;
Date dateTemp = Date.newInstance(dateTimetemp.year(),dateTimetemp.month(),dateTimetemp.day());
String dateStr = dateTemp.format();

string msg = 'You have automatically swarmed an Opportunity.'+ '\n' +
'Opportunity Name : ' + thisOppty.Name+ '\n' +
'Account : ' + thisOppty.Account.Name + '\n' +
'Type : ' + thisOppty.Type + '\n' +
'Close Date : ' + dateStr + '\n' +
'Owner : ' + thisOppty.Owner.Name;

FeedItem swarmNotification = new FeedItem();
swarmNotification.Type = 'LinkPost';
swarmNotification.ParentId = rule.User__c;
swarmNotification.Title = 'Link to Opportunity Record '+thisOppty.Name+' Swarmed';
swarmNotification.Body = msg;
swarmNotification.LinkUrl = URL.getSalesforceBaseUrl().toExternalForm() + '/' + thisOppty.Id;
feedNotifications.add(swarmNotification);
}// if 3
}//if 2
}//if 1
}

}//for 2

}//for 1 oppty's

try {
System.Debug('Subscription count : ' + subs.size());
insert subs;
insert feedNotifications;
} catch (DMLException e) {
system.debug('Oppty Swarm subscriptions were not all inserted successfully. Error: '+e);
}//catch
}//evaluateOpptyRules

}//class

 

Below is debug log info:

01:42:46.811|LIMIT_USAGE_FOR_NS|(default)|

Number of SOQL queries: 4 out of 100
Number of query rows: 6698 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of DML rows: 0 out of 10000
Number of script statements: 200002 out of 200000 ******* CLOSE TO LIMIT
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

 

Can someone look at the code and please share your thoughts to overcome the above exception..

 

Thanks in advance..

 

Hi,

 

Is it possible to write a trigger on OpportunityTeamMember object?

 

I want to invoke some code when we add/update SalesTeamMembers in an Opportunity..

 

Let us know other poosibilities to acheive the above..

 

 

Thanks in advance..

Hi,

 

We are calling sample code(which has logic to auto-follow the records) when an Opportunity is getting created or updated. We are able to achieve this by having trigger in Opportunity.

 

We need same sample code to be executed when we add/update Sales Team members to an opportunity. We are not able to achieve this as we can't write triggers in OpportunityTeammember.

 

Can someone share your thoughts on how to achive this.

 

Thanks in advance..

Hi,

We are in the process of enabling critical updates in our production environment. Before activating critical updates we want to ensure what impact it might cause. I have found review description for the 'Enable CSRF protection on GET and POST requests'. But can you eloborate me that how this critical update impacts environment. Also it would be great that what components/sections that we need to check to avoid impact of this critical update.

Regards
G.Surender
Hi,

We are in the process of enabling critical updates in our production environment. Before activating critical updates we want to ensure what impact it might cause. I have found review description for the 'Require secure connections (HTTPS)'. But can you eloborate me that how this critical update impacts environment. Also it would be great that what components/sections that we need to check to avoid impact of this critical update.

Regards
G.Surender


Hi,

We are in the process of enabling critical updates in our production environment. Before activating critical updates we want to ensure what impact it might cause. I have found review description for the 'Enable clickjack protection for non-setup Salesforce pages'. But can you eloborate me that how this critical update impacts environment. Also it would be great that what components/sections that we need to check to avoid impact of this critical update.

Regards
G.Surender

Hi,

 

If we modify related list like dependent opportunities on a opportunity used to update LastModifiedDate on a opportunity and on parent opportunity as well.

 

But today when i modify/delete dependent opportunies on a opportunity then it is not updating the LastModifiedDate on parent opportunities.

 

I have checked this bahaviour in Sandbox environment.

 

Can anyone know the reason for why it is not happening so?

 

Your feedback is appreciated.

 

Regards

Surender

 

Hi,

 

I want to add subscriberId's into a list of Id's.

 

below is the code for the same.

 

List<Id> usr=new List<Id>();
AggregateResult[] sub= [select subscriberId from EntitySubscription group by SubscriberId having count(ParentId)>= 500];
for (AggregateResult ar : sub)
usr.add(ar.get(subscriberId));

 

but i'm getting error like Variable does not exist: subscriberId.

 

Can someone correct the above.

 

Thanks in advance.

Hi,

 

 

I have the below code which will send feed post to some particular user. 

 

 

string msg = 'You have automatically swarmed an Opportunity.'+  '\n' +
                       'Opportunity Name : ' + thisOppty.Name+ '\n' + 
                       'Account : ' + thisOppty.Account.Name + '\n' +
                       'Type : ' + thisOppty.Type + '\n' +
                       'Close Date : ' + dateStr + '\n' +
                       'Owner : ' + thisOppty.Owner.Name;
                                
FeedItem swarmNotification = new FeedItem();
swarmNotification.Type = 'LinkPost';
swarmNotification.ParentId = rule.User__c;
swarmNotification.Title = 'Link to Opportunity Record '+thisOppty.Name+' Swarmed';
swarmNotification.Body = msg;
swarmNotification.LinkUrl = URL.getSalesforceBaseUrl().toExternalForm() + '/' + thisOppty.Id;
feedNotifications.add(swarmNotification);

 

But we have problem with the above like the feed post is sent to particular user and the users who are following that user.

 

Can we send private feed post only to that particular user.

 

Share some code snippets for better understanding.

 


Hi,

 

We want to implement some functionality only for Chatter Free users.


when we create new user, User License has Chatter free and Salesforce picklist values.


But we didn't find User License field in the User object.


We need soql to get only Chatter free users in the Apex, can someone post it.

 

Thanks in Advance.. 

Hi,

 

I'm getting System.LimitException: Too many script statements for the below Apex Code:

 

Apex Code:
public class OpportunitySalesTeamSwarmHelper {

public static void evaluateOpptySalesTeamRules() {

// Get list of Opptys with opp, acc, owner details
List<Opportunity> opptys = [SELECT o.Id, o.Name, o.Type, o.AccountId, Account.Name,Account.OwnerId, Account.JDA_Industry__c,
Account.Named_Account__c,Account.Target_Rating__c, o.StageName, o.Amount,o.CurrencyIsoCode, o.Local_Region_Override__c,o.CloseDate, o.Business_Unit__c,
o.OwnerId, o.Owner.Name, o.Owner.Reports_To__c FROM Opportunity o WHERE o.StageName like 'open'];

// Get list of all rules
List<Opportunity_Swarm_Rule__c> rules = [select Name,type__c, Opportunity_amount__c, Opportunity_stage__c,
Opportunity_type__c, Opportunity_Local__c,Opportunity_Business_Unit__c,JDA_Industry__c, user__c,
ownerId, Notify_on_Swarm__c from Opportunity_Swarm_Rule__c WHERE user__r.IsActive = true];

// Get all subscriptions and put in string concatenating subscriber + object ID
List<EntitySubscription> existingOpptySubs = [select SubscriberId, ParentId from EntitySubscription where ParentId in :opptys];

Set<String> existingOpptySubsIds = new Set<String>();
for (EntitySubscription es:existingOpptySubs) {
existingOpptySubsIds.add((String)es.SubscriberId + es.ParentId);
}//for

List<OpportunityTeamMember> opptySalesTeams = [SELECT UserId from OpportunityTeamMember where OpportunityId in :opptys];

// Create a list of subscripions and chatter feeds and insert them later outside the loop
List<EntitySubscription> subs = new List<EntitySubscription>();
List<FeedItem> feedNotifications = new List<FeedItem>();

// For each oppty check all rules.
// If criteria is satisfied, make the user of rule to follow the opportunity
Integer count = 0;
for (Opportunity thisOppty : opptys) {
count++;
System.debug('The value of Count is'+count);
for (Opportunity_Swarm_Rule__c rule : rules) {

if(rule.Type__c.contains('Opptys where I am an Account Team Member')) {

boolean salesTeamFlag = false;
boolean condition = false;
for (OpportunityTeamMember opptySalesTeam : opptySalesTeams) {
if(rule.User__c == opptySalesTeam.UserId ){
salesTeamFlag=true;
}
if(salesTeamFlag)
break;
}

condition= salesTeamFlag;
System.debug('The value of Condition - Opptys where I am Sales Team Member is : '+condition);

if(condition) {
if (existingOpptySubsIds.contains((string)rule.User__c + thisOppty.Id) == FALSE) {
subs.add(new EntitySubscription(parentId = thisOppty.id, SubscriberId = rule.User__c));
existingOpptySubsIds.add((String)rule.User__c + thisOppty.id);

// Add swarming notification to user's feed
if (rule.Notify_on_Swarm__c == true) {
//displaying close datetime as only date string
Datetime dateTimetemp = thisOppty.CloseDate;
Date dateTemp = Date.newInstance(dateTimetemp.year(),dateTimetemp.month(),dateTimetemp.day());
String dateStr = dateTemp.format();

string msg = 'You have automatically swarmed an Opportunity.'+ '\n' +
'Opportunity Name : ' + thisOppty.Name+ '\n' +
'Account : ' + thisOppty.Account.Name + '\n' +
'Type : ' + thisOppty.Type + '\n' +
'Close Date : ' + dateStr + '\n' +
'Owner : ' + thisOppty.Owner.Name;

FeedItem swarmNotification = new FeedItem();
swarmNotification.Type = 'LinkPost';
swarmNotification.ParentId = rule.User__c;
swarmNotification.Title = 'Link to Opportunity Record '+thisOppty.Name+' Swarmed';
swarmNotification.Body = msg;
swarmNotification.LinkUrl = URL.getSalesforceBaseUrl().toExternalForm() + '/' + thisOppty.Id;
feedNotifications.add(swarmNotification);
}// if 3
}//if 2
}//if 1
}

}//for 2

}//for 1 oppty's
try {
System.Debug('Subscription count : ' + subs.size());
insert subs;
insert feedNotifications;
} catch (DMLException e) {
system.debug('Oppty Swarm subscriptions were not all inserted successfully. Error: '+e);
}//catch
}//evaluateOpptyRules

}//class

 

Below is debug log info:
01:42:46.811|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 4 out of 100
Number of query rows: 6698 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of DML rows: 0 out of 10000
Number of script statements: 200002 out of 200000 ******* CLOSE TO LIMIT
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

 

Can someone look at the code and please share your thoughts to overcome the above exception..

 

Thanks in advance..


Hi,

 

I have below method which is called from a button click in a visualforce page.

 

 public PageReference saveUsePolicy() {

 

       User usr= [SELECT Use_Policy__c from User where Id=:UserInfo.getUserId() and IsActive=true];
        usr.Use_Policy__c = true;
        update usr;
       
        PageReference pageRef = Page.UsePolicySuccess;
        pageRef.setRedirect(false);
        return pageRef;      

}

 

It is updating user record upon button click. Also It is redirected to open new page(UsePolicySuccess).

 

I want that page to be opened in the same page not in a new page(new window).

 

Share your thoughts on this.

 

Thanks in advance..

 

Hi,

 

I want below kind of validation rule.

 

CONTAINS(lower(text(Type__c)), "certain type") && ISBLANK(text(Opportunity_Amount__c))

 

But Type__c is of multi-select pick list, so it is not accepting CONTAINS.

 

Can some one help me how to write same validation rule for multi-select picklist.

 

Your feedback is appreciated.

 

Regards

G. Surender

Hi,

 

How to write Test Case for the below Apex class..

 

public class ABC {

    public PageReference callfun() {
        Boolean flag= false;
        
        User usr= [SELECT Use_Policy__c from User where Id=:UserInfo.getUserId() and IsActive=true];
        
        if(usr.Use_Policy__c) {
            PageReference pageRef = Page.UsePolicySuccess;
            pageRef.setRedirect(true);
            return pageRef;
        } else{
        
           PageReference pageRef = Page.UsePolicyPage;
           pageRef.setRedirect(true);
           return pageRef;       
        }
    }

}

 

Your feedback is appreciated..

Hi,

 

I'm getting System.LimitException in the test case for the below query.

 

User sender = [SELECT Email from USER where Id =: thisOppty.OwnerID];

 

But the above query returns only one record.

 

Need your suggestions to resolve the above..

 

 

 

 

Hi,

 


While creating Home page Components i choose component of Type HTML Area to display it in wide region.

 

From this i want to call Visual Force page for that i wrote like below

 

<HTML>

<a href=URL.getSalesforceBaseUrl().toExternalForm()+'/apex/UsePolicyTest'>Click Here</a>

</HTML>


But it is showing as is in the Home Page and it is not calling VisualForce Page.


Can anyone please share ideas on how to call Visual Force Page from here..

Hi,

 

When the tab gets loaded, how can we call A VisualForce page (with out any actions from side bar).

 

I am able to achieve this by having custom link in the Home tab(in the Side bar) and when the user clicks on the link it is calling that VisualForce page.


But our requirement to achive this without a link click in the sidebar and that VisualForce page has to be called in the Wide Area.

 

Your feedback is appeciated.

Hi,
 
As we are new to salesforce development, can someone briefly explain how we can achive the below urgent requirement.
 
I want to display Use Policy(i.e., check box) as a pop-up as soon as they login to Salesforce for the first time. This should happen for existing users who are going to see Chatter for the first time or new SF users. User should not be able to proceed till the User policy has been accepted. 
Also we need to track the acceptance to the Use Policy(add attribute to User record, maybe date and time to track who has accepted to have read the policy).
 
Also share us with sample code/examples if any..
 
Thanks in advance..

Hi,

 

I want to display Use Policy(i.e., check box) as a pop-up as soon as they login to Salesforce for the first time. This should happen for existing users who are going to see Chatter for the first time or new SF users. User should not be able to proceed till the User policy has been accepted.


Also we need to track the acceptance to the Use Policy(add attribute to User record, maybe date and time to track who has accepted to have read the policy)

 

Please share your thoughts like how can we achive this.

 

Also share us with sample files if any..

 

Thanks in advance..

Hi,
I want to display Use Policy(i.e., check box) as a pop-up as soon as they login to Salesforce for the first time. This should happen for existing users who are going to see Chatter for the first time or new SF users. User should not be able to proceed till the User policy has been accepted. 
Also we need to track the acceptance to the Use Policy(add attribute to User record, maybe date and time to track who has accepted to have read the policy)
Please share your thoughts like how can we achive this. 
Also share us with sample files if any..
Thanks in advance..
 

Hi,

 

Can someone guide us like how can we remove the timestamp from the DateField Value.

 

Ex: Suppose i have Date value like 2011-11-15 00:00:00 then i want to print only 2011-11-15.

 

Please share your thoughts on this.

 

Regards

G. Surender