• Inanskar007
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 15
    Questions
  • 4
    Replies
Hello Guys,

We are opening few reports through custom buttons by URL hack and we are looking on options to reduce response time for loading the report. As it is taking more time at certain networks to open the report

Thanks In Advance
Hi All,

I am working on a requirement to compute the count of the completed Events for the past one year and palced the count on a contact. whenever a Event got deleted or added for a contact the count should be updated on a custom field of corresponding contact record

For this, I have written a trigger on Event objest as below

Trriger

trigger Event_updateActivityScore_trigger on Event (after insert, after update, after delete) {

Set<Id> e = new Set<Id>();

for(Event e1 : Trigger.new){

e.add(e1.id);

}

List<EventRelation> er = [select relationid from EventRelation where Eventid = :e and Relation.Type = 'Contact'];

Set<Id> i = new Set<Id>();

for(EventRelation er1 : er){

i.add(er1.id);

}


CountVisitsByContactpast365Controller.updateActivityScore(i);

}


and the follwoing class

Apex Class

public  with sharing  class CountVisitsByContactpast365Controller {
@future
public static void updateActivityScore(Set<Id> erid)
{
    System.debug(LoggingLevel.ERROR, ' event ids are' + erid);
    Set<Id> erid1 = new Set<Id>(erid);
     System.debug(LoggingLevel.ERROR, ' event relation ids are' + erid1);
    List<EventRelation> eventidset=  [select eventid from EventRelation where RelationId in:erid1];
   System.debug(LoggingLevel.ERROR, ' event ids are' + eventidset);
   Map<Id, EventRelation> er = new Map<Id, EventRelation>(eventidset);

   List <Event> finaleventidset= [select id from Event where EndDateTime>=LAST_N_DAYS:365 and Visit_Status__c='Completed' and isDeleted=false and ID in: er.keyset()];
   Map<Id, Event> e = New Map<Id, Event>(finaleventidset);
   
     List<EventRelation> er1 = [select relationid from EventRelation where eventid in:e.keyset()];
      Map<Id, EventRelation> er2 = new Map<Id, EventRelation>(er1);
      List<contact> c = [select id,Activity_Score__c from Contact where id in:er2.keyset()];
      
     
     List<AggregateResult> agr = [select count(id) T1, relationid from EventRelation where relationid in : er2.keyset() group by relationid];
     
         List<contact> ctct1 = new List<contact>();
   
 for(contact ct : c){
       for(AggregateResult ar : agr){
           if (ct.id == (Id)ar.get('expr1')){
            if(ct.Activity_Score__c!= (Integer)ar.get('T1')){
             ct.Activity_Score__c = (Integer)ar.get('T1');
             ctct1.add(ct);
   }}}}
            update ctct1; 
  }
}


We have used the following query in trigger to get the list of relationid's of type  contact
select relationid from eventrelation where eventid in : e and Relation.Type = 'Contact'

But When the trigger is passing the list of relation id's it is coming to the class as set of id's starts with '0RE'
Usually the contact id's will start with '003'

Could you please advise us the correct way to sent the list of contactid's from EventRelation from trigger to class

Thanks In Advance





 
Hi Team,
I want to delete single record alone in Recycle bin.. .. I am able to delete all records.. But I want to one delete record out of 10 records in recycle bin. Is  there any way to do it ?

Thanks In Advance
Hi

I have an apex trigger on contact which will trigger an email when an email field has been changed and picklist values is either No or Null

The following is the Apex trigger code 

Trigger:
trigger Contact_OnBusinessEmailChange_Trigger on Contact (after update) {
      
        List<String> mailList = new List<String>();
  List<String> mailAddresses = new List<String>(); 
  Group g = [SELECT (select userOrGroupId from groupMembers) FROM group WHERE name = 'TCSTestGroup'];
  for (GroupMember gm : g.groupMembers) 
  {
   mailList.add(gm.userOrGroupId);
  }
  User[] usr = [SELECT email FROM user WHERE id IN :mailList];
  for(User u : usr) 
  {
  mailAddresses.add(u.email);
  } 
        string messagebody;
        List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();
        for (Contact c : trigger.new) { 
            Contact old = trigger.oldMap.get(c.Id); 
            if ((old.Email != c.Email) && ((c.Opt_in_to_Tracking__c== 'No') ||(c.Opt_in_to_Tracking__c== null))) {  
                Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
                email.setToAddresses(mailAddresses);
                email.setReplyTo('noreply@salesforce.com');
                email.setSenderDisplayName('IT Salesforce Support');
                email.setSubject('Notification: Email Address Change');
                messagebody='<html><body>The Business Email for the contact "' +c.FirstName + ' ' + c.LastName + '" has been updated from ' + old.Email + ' to ' + c.Email +' by '+c.Updated_By__c + '.<br/><br/>The Contact\'s further details below:<br/><br/>Contact\'s First Name:'+c.FirstName+'<br/>Contact\'s Last Name:'+c.LastName+'<br/>Contact\'s ID:'+c.Id+'';
                email.setHtmlBody(messagebody);
                emails.add(email);
            }
        }
        Messaging.sendEmail(emails);
    }

And the below is the Apex Test Class

@isTest
private class ContactOnBusinessEmailChangeTestClass{
private static testMethod void mailchangecheckvalid(){
//for new contact valid test
   Account grpAccnt = new Account(name='UpdateAccSSTest_grp1_11Dec_2015',account_type__c='Group',Source_System_ID__c='test5923');
        insert grpAccnt;
        
        Account accnt1 = new Account(name='UpdateAccSSTest_accnt1_11Dec_2015',account_type__c='Account',Source_System_ID__c='test594',
                parentId=grpAccnt.Id);
        insert accnt1;
        Account acc1 = new Account(Name='UpdateAccSSTest_accLoc1_11Dec_2015',Account_Type__c ='Account Location',
                Active__c = true,Source_System_ID__c='test',parentId=accnt1.Id);
        insert acc1;
        Contact con1 = new Contact(FirstName='UpdateAccSSTest_con1_11Dec_2015',LastName='Test contact1',accountid=acc1.id,
                Business_Unit__c='GCF',Email='mytestmail@genre.com');
        insert con1;
  
con1.Email='mytestmail2@genre.com';
try{update con1; }catch(DmlException e){System.Debug('Failure happened');}


System.assertEquals('mytestmail2@genre.com',con1.Email);
}

private static testMethod void mailchangecheckinvalid(){
//for new contact invalid test
   Account grpAccnt = new Account(name='UpdateAccSSTest_grp2_11Dec_2015',account_type__c='Group',Source_System_ID__c='test5927');
        insert grpAccnt;
        
        Account accnt1 = new Account(name='UpdateAccSSTest_accnt2_11Dec_2015',account_type__c='Account',Source_System_ID__c='test5947',
                parentId=grpAccnt.Id);
        insert accnt1;
        Account acc1 = new Account(Name='UpdateAccSSTest_accLoc2_11Dec_2015',Account_Type__c ='Account Location',
                Active__c = true,Source_System_ID__c='test',parentId=accnt1.Id);
        insert acc1;
        Contact con1 = new Contact(FirstName='UpdateAccSSTest_con1_17Mar_2011',LastName='Test contact2',accountid=acc1.id,
                Business_Unit__c='GCF',Email='mytestmail3@genre.com');
        insert con1;

       
con1.Email='mytestmail4@genre.com';

try{update con1; }catch(DmlException e){System.Debug('Failure happened');}

System.assertnotEquals('mytestmail3@genre.com',con1.Email);
}

}

Could you please tell me how to increase the code coverage to deploy this trigger
Hii All. I have a report where it will display the event records for certain users. The filter condition is assigned to x,y,z, etc.,
Now I have added this report to a dashbord to display the record count of assigner users in a horizontal bar chart.  Eventhough report is displaying the records for all assingned users. But the horizontal bar chart dashboard is displaying only first assigned user record count. Any suggestions to display all the assigned users record count in horizontal bar chart.
Hi ..An Account is having 5 child objects. I would like to create a SF report to fetchs Accounts having atleast one record in all it's child objects. I am able to create a report type upto 3 child objects (as Salesforce allows only 3 child objects) for an account. I have tried joined report.. But it's showing Accounts which are not having records in any of it's child objects. Is there any way to create a report type or SF report to fetch Accounts having atleast one record on all of it's child objects. Any Suggestions. Thanks in Advance.
Hi.. Whenever an event created for a contact, salesforce will add the respective contact as an invitee by default.. But I have open an existing old event where I am not able to see the contact under the invitee section (Hasn't responded yet, Accepted Decline).. Any guess how can we replicate this...
Hi SD,

I am not able access a desktop icon Salesforce files. Intially I am able to access the Salesforce files at first time and able to enter credentials sucessfully. Now I want to chage the credentials and logon with the different credentials, but it is not opening to sign with different credentials

When I double click on that icon, it is coming in system tray (show hidden icons) and then become invisible immediately in the system tray.
 
Hii ,

I have five events exists for a contact. Out of five events, I am not able to delete two events. Remaining three I am to delete it.

When I try to delete these events, I am getting the following error message

Data Not Available
The data you were trying to access could not be found. It may be due to another user deleting the data or a system error. If you know the data is not deleted but cannot access it, please look at our support page. 


Please look over it and suggest me if there is any way two delete these events.


 
Hi I have 1000 reports and I want to get the all the filter conditions used in these reports. Is there any way to get all the filter conditions used in my reports at a single point of time.

Also, is there any way that i can save all the filter conditions for the 1000 reports in a spreadsheet.

Thanks in Advance.
Hi
i have custom link executed as a javascript for on click to hide a standard button and i have added the custom link as a home page component
now i wanted to hide the home page component but the custom link should be invoked eventhough if it is not visible. Is it possible to do that
Hi 

Is it Possible to disable/hide Save and Send button through Visual Workflow.

If so, Please let me know how to do it. Thanks in Advance
Hi
I want to hide save and send update button in Event edit page. In Salesforce , these save and hide button will be visible only when u add invitees more than 1 user.

I have tried to create a custom visualforce page similar to Event edit page but i'm not not able to add the related list Attachments and Invite Other details
The following is my code

VF page:

<apex:page standardController="Event" extensions="CustomVisitController" showHeader="true">
  <apex:form >
  <apex:pageBlock title="Calendar">
  <apex:pageBlockButtons >
  <apex:commandButton action="{!Save}" value="Save"/>
  <apex:commandButton action="{!saveAndNewTodo}" value="Save & New To do"/>
  <apex:commandButton action="{!saveAndNewVisit}" value="Save & New Visit"/>
  <apex:commandButton action="{!cancel}" value="Cancel"/>
  </apex:pageBlockButtons>
  <apex:pageBlockSection title="Visit Details (Only create visits from a Contact)" columns="4">
   <apex:inputField value="{!Event.Ownerid}">
  <apex:actionSupport event="onchange" rerender="Event_view" action="{!rerender}">
  <apex:param name="ownerId_VF" value="{!Event.Ownerid}" assignTo="{!ownerId_VF}" />                    
  </apex:actionSupport>
  </apex:inputField>
  <apex:inputField value="{!Event.Type}" />
  <apex:pageBlockSectionItem ></apex:pageBlockSectionItem>
  <apex:pageBlockSectionItem ></apex:pageBlockSectionItem>
  <apex:inputField value="{!Event.Subject}"/>
  <apex:inputField value="{!Event.StartDateTime}">
  <apex:actionSupport event="onchange" rerender="Event_view" action="{!rerender}">
  <apex:param name="startDate_VF" value="{!Event.StartDateTime}" assignTo="{!startDate_VF}"/>
  </apex:actionSupport>
  </apex:inputField>
  <apex:pageBlockSectionItem ></apex:pageBlockSectionItem>
  <apex:pageBlockSectionItem ></apex:pageBlockSectionItem>
  <apex:inputField value="{!Event.Whoid}"/> <!--<apex:commandLink value="[Add to Invitees]"/> -->
  <apex:inputField value="{!Event.EndDateTime}"/>
  <apex:pageBlockSectionItem ></apex:pageBlockSectionItem>
  <apex:pageBlockSectionItem ></apex:pageBlockSectionItem>
  <apex:inputField value="{!Event.Whatid}"/>
  <apex:inputField value="{!Event.IsAllDayEvent}"/>
  <apex:pageBlockSectionItem ></apex:pageBlockSectionItem>
  <apex:pageBlockSectionItem ></apex:pageBlockSectionItem>
  <apex:inputField value="{!Event.Location}"/>
  </apex:pageBlockSection>
  <apex:pageBlockSection title="Visit Notes - Use Description field for visit, and follow-up notes">
  <apex:inputField value="{!Event.Description}"/>
  <apex:pageBlockSectionItem ></apex:pageBlockSectionItem>
  </apex:pageBlockSection>
  <apex:pageBlockSection title="Recurrence">
  <apex:inputField value="{!Event.IsRecurrence}"/>
  </apex:pageBlockSection>
   <apex:pageBlockSection title="Reminder">
  <apex:inputField value="{!Event.IsReminderSet}"/>
  </apex:pageBlockSection>
  <apex:pageBlockSection >
 
 
  </apex:pageBlockSection>
 
 
  </apex:pageBlock>
 
   <apex:pageBlock title="Attachments">
  <apex:commandButton value="Attach File" action="{!attachfile}"/>
  </apex:pageBlock>
  </apex:form>

 
</apex:page>

Controller

public with sharing class CustomVisitController {

    public CustomVisitController(ApexPages.StandardController controller) {
       
    }
    
    Public PageReference rerender() {
    
    return null;
    }
    
    Public PageReference saveAndNewTodo() {
     try{
            Event eve = new Event();
             upsert eve;
        }        
        catch(Exception e){
            ApexPages.addmessage(new ApexPages.message(ApexPages.Severity.ERROR,'Error creating/updating record'));
        }
        PageReference pageRef = new PageReference('https://cs11.salesforce.com/00T/e?retURL=%2Fhome%2Fhome.jsp');
        pageRef.setRedirect(true);

        return pageRef;   
    
    }

     Public PageReference saveAndNewVisit() {
     try{
            Event eve = new Event();
             upsert eve;
        }        
        catch(Exception e){
            ApexPages.addmessage(new ApexPages.message(ApexPages.Severity.ERROR,'Error creating/updating record'));
        }
        PageReference pageRef = new PageReference('https://c.cs11.visual.force.com/apex/CustomVisitPage');
        pageRef.setRedirect(true);

        return pageRef;   
    
    }
Public PageReference attachfile(){

Attachment a = new Attachment();
upsert a;
return null;

}


}

Please guide let us know how to go further. Thanks
Hi 
My requirement is to create a report using the report type as TODos and visits (which refers to acitivies)
with fields in the report as  Assigned to (refers to user ) subject, Opportunies, Visit status, etc., based on the filter condition One P&C (custom picklist field) equals as Asia Pac

This custome picklist field is present in User object having the picklist values as Asia Pac, Europe, North America and South America.) 

I have 20 users with One P&C field as Asia Pac. In order to get those user details with One P&C field as Asia Pac, I have created a custom field in Actiivites object with field type as formula which use merge field formula to get the One P&C value of user object.

Eventhough i created that formual field, One P&C is not getting any values.

Please look over it and suggest a way to filter the Activities records in report based on the custom picklist field (One P&C in user object).

 
Hello,

I have standard report type Todo and Visits, Based on that i have fliter condition, Assigned To : username (xyz).and I will create a new reports for Todo and visits.

Now I have created a custom picklist field on user object. This custom field does not have a relation ship with any object. But I want to include this custom field as a filter conditon in my report (report type as todo and visits).

Could you please let me know possible way to do this?
 
Hello Guys,

We are opening few reports through custom buttons by URL hack and we are looking on options to reduce response time for loading the report. As it is taking more time at certain networks to open the report

Thanks In Advance
Hi all,

Our project demands to hide fields in some layout by using Home Page component.so I initially used Javascript in Home Page Component for achieve our requirement.But after upgradation of salesforce, components that contain JavaScript, CSS, iframes are restricted and stop working properly.I am attaching my code which i done before salesforce up-gradation.

Could anyone give solution for this? It would be great.



Code which work fine before SF upgradation:-

//Below If condition to hide the Service details in maintenance sheet  Edit Layout for system type: Disabled/Nursecall Alarm
if (document.location.href.toString().indexOf("/a0F") != -1 && document.location.href.toString().indexOf("/a0F/o") == -1 && document.location.href.toString().indexOf

("/e?") != -1 ) { 
//checking the system name
var e  = document.getElementById("00ND0000005Ec8j");
var strUser = e.options[e.selectedIndex].value;
//alert('Systm name '+strUser);

if(strUser != "Disabled/Nursecall")
{

for(var i=1;i<document.getElementsByTagName('Label').length;i++)
{
if(document.getElementsByTagName('Label')[i].innerHTML== "SLA Power Calibration Qty")
{
var a =document.getElementsByTagName('LABEL')[i].htmlFor;
document.getElementsByTagName('LABEL')[i].innerHTML ="";
document.getElementById(a).style.display='none';
}
}
}
}




 
Hi.. Whenever an event created for a contact, salesforce will add the respective contact as an invitee by default.. But I have open an existing old event where I am not able to see the contact under the invitee section (Hasn't responded yet, Accepted Decline).. Any guess how can we replicate this...
Hi 

Is it Possible to disable/hide Save and Send button through Visual Workflow.

If so, Please let me know how to do it. Thanks in Advance