• Tommy Georgiou
  • NEWBIE
  • 160 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 25
    Questions
  • 94
    Replies
Hi all,


My business scenario that I am having problems to resolve is the following. I am sending quotes to our clients with various products(different product families). 
As soon as the client accepts the terms I create an order per each product family as I have suppliers per product family. As you understand this is a duplication of my work creating the opp and then the quote. 
Ideally with a hit of a button I could transfer lets say products a,b,c of product family A into the assigned order form layout for product family A. With another button the products d,e,f of product family B will go to the order form layout of pro fami. B.

I do not know if this can be done either by a custom button or a visualforce page. Anyhow I am seeking help from experts like you guys in the developer forum.

Thank you very much
Hi all,


Has anyone tried the 3CX integration for Salesforce. If yes can you please be kind and let me kow of advantages/disadvantages regarding this provider. If it's easy can you send some screenshots as well when you receive an incoming call how the interface looks.

Thank you in advance
Hello,


I am trying to insert new records into a custom object (production) via apex data loader. When I do so I get an error like
 
​ ReservationTrigger: execution of AfterInsert

caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing.
Even if a field is indexed a filter might still not be selective when:
1. The filter value includes null (for instance binding with a list that contains null)
2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times)

Trigger.ReservationTrigger: line 11, column 1

My trigger is 
trigger ReservationTrigger on Reservations__c (after insert,after update) {
    // Get the IDs of related contacts
    Set<Id> contactIds = new Set<Id>();
    for(Reservations__c oneReservation:trigger.new){
        if(oneReservation.ReservationStatus__c == 'Confirmed'){
            contactIds.add(oneReservation.Email__c);
        }
    }
    // Count the distinct Reservation_Number__c from the Reservation objects of all related contacts
    Map<Id, Integer> countDistinctReservationMap = new Map<Id, Integer>();
    for (AggregateResult aggRes : [SELECT COUNT_DISTINCT(ReservationCode__c) resNum, Email__c conId FROM Reservations__c WHERE Email__c IN: contactIds GROUP BY Email__c ]) {
         Id conId = (Id) aggRes.get('conId');
         Integer resNum  = (Integer) aggRes.get('resNum');
         countDistinctReservationMap.put(conId, resNum);
    }
    // Now fetch the Contacts in a list
    List<Contact> listContacts = [Select Id, customRollupField__c from Contact Where Id IN:contactIds];
    if(listContacts.size()>0) {
         for(Contact con : listContacts) {
              // fetch or get the distinct count or rollup from the map and copy it to the contact's field
              con.customRollupField__c = countDistinctReservationMap.get(con.Id);
         }
    }
    // Update the contacts
    update listContacts;
}

Any Ideas why?
I have moved my custom object(Reservations) with the custom fields(near to 50 fields) created in Sandbox into Production but when i try and create a new res I can use only the standard field of that custom object. All the other fields are not visible. When I go to the edit of the page layout I can see them but when I preview the layout they are missing. Did I forgot something during the transition from Sandbox to Production?
Hello,


I need a sort button in Orders for Order Products where I can sort the products into the order that I want. There is a sort button in the Opps for the products there. Has anyone found out how to create a custom button with the similar functionallity?
Hi all,


Due to my poor knowledge on apex I am seeking for help in this forum. I am really new to this so please spare me.
With help from another Dev a trigger was created for a custom object where using the Count_Dinstinct it was reading the unique ReservationCode__c and rolling up the custom field on Contacts if the trigger was firing due to its rules. 
Trigger is : 
 
trigger ReservationTrigger on Reservations__c (after insert,after update) {
    // Get the IDs of related contacts
    Set<Id> contactIds = new Set<Id>();
    for(Reservations__c oneReservation:trigger.new){
        if(oneReservation.ReservationStatus__c == 'Confirmed'){
            contactIds.add(oneReservation.Email__c);
        }
    }
    // Count the distinct Reservation_Number__c from the Reservation objects of all related contacts
    Map<Id, Integer> countDistinctReservationMap = new Map<Id, Integer>();
    for (AggregateResult aggRes : [SELECT COUNT_DISTINCT(ReservationCode__c) resNum, Email__c conId FROM Reservations__c WHERE Email__c IN: contactIds GROUP BY Email__c ]) {
         Id conId = (Id) aggRes.get('conId');
         Integer resNum  = (Integer) aggRes.get('resNum');
         countDistinctReservationMap.put(conId, resNum);
    }
    // Now fetch the Contacts in a list
    List<Contact> listContacts = [Select Id, customRollupField__c from Contact Where Id IN:contactIds];
    if(listContacts.size()>0) {
         for(Contact con : listContacts) {
              // fetch or get the distinct count or rollup from the map and copy it to the contact's field
              con.customRollupField__c = countDistinctReservationMap.get(con.Id);
         }
    }
    // Update the contacts
    update listContacts;
}

My problem is how to get the custom object onto the test class. 

Due to my poor knowledge I think that a test class should include  

Account a = new Account(Name = 'Test');
        insert a;     

     Contact c = new Contact(AccountId=a.Id, lastname='testing', firstname='apex', Email= 'xxxxx');
        insert c;

but here is where I stuck. How to get the custom object onto the test class with the count dinstinct??

Thank you in advance
 
Hi all,


I have a custom text field that I want to include into a workflow where my end result will be a field update(checkbox). What I want as a rule is when this custom text field is the same then the update won't take place. ie. when abc1234 = abc 1234 then nothing will happen. 

My question is how can I create this rule? (For a contact I have a custom object where it has records. In some cases two records have the same custom text field.)
Hi all,

I have created  triggers for Quote Line Items where it checks a checkbox as soon as the Product Family of the item equals the value that I've set for each trigger.
One of the triggers looks like : 
trigger UpdateQuoteCheckBoxCake on QuoteLineItem (after insert, after update)
{
    List<Quote> quoteList = new List<Quote>();
    
    for(QuoteLineItem currQli : Trigger.New)
    {
        if(currQli.Product_Family__c == 'Cakes')
        {
            quoteList.add(new Quote(Id = currQli.QuoteId, Cakes__c = true));
        }
    }
    
    if(!quoteList.isEmpty())
    {
      update quoteList;
    }
}

Now I am trying to update all the records in order to get teh boxes checked and I am getting an error like 
Apex trigger UpdateQuoteCheckBoxReception caused an unexpected exception, contact your administrator: UpdateQuoteCheckBoxReception: execution of AfterUpdate caused by: System.ListException: Duplicate id in list: 0Q0w0000000o68RCAQ: Trigger.UpdateQuoteCheckBoxReception: line 15, column 1

Any Ideas how can I resolve this?
Hi I am really new in apex and programming. 

I received help for the trigger 
trigger UpdateQuoteCheckBox on QuoteLineItem (after insert, after update)
{
    List<Quote> quoteList = new List<Quote>();
    
    for(QuoteLineItem currQli : Trigger.New)
    {
        if(currQli.Product2.Family == 'Your Product Family Name')
        {
            quoteList.add(new Quote(Id = currQli.QuoteId, Family__c = true));
        }
    }
    
    if(!quoteList.isEmpty())
    {
      update quoteList;
    }
}

but do not know how to write the test class for it. I have searched a bit on 
https://developer.salesforce.com/page/An_Introduction_to_Apex_Code_Test_Methods
 But still don't get. Any help would be appreciated. Thank you in advance
Hello all,


I have custom checkbox fields in Quotes based on the the values of Product Family field. What I am looking if it's possible is when I insert Quote Line Item and it's Product Family equals with X the checkbox X will become checked. 

Any Ideas?
I have created a custom button(like send an email function) to define the email template and the recipient email address. Behavior is set to execute Java, content source is OnClick Java. Code is 
 
location.replace('/email/author/emailauthor.jsp?retURL=/{!Order.Id}&p3_lkid={!Order.Id}&rtype=003&p3_lkid={!Order.OrderNumber}&p3_1kid={!$User.Email}&p24="xxxxx@spidernet.com&template_id=00Xw0000001U7YN');


My problem is that it defines the additional to field and not the To. See image below. Any ideas why?

User-added image

`
Hi,

I want to create a custom button where I can prepopulate the ''To'' on the send an email function through Orders and predefine the email tempate as well.

I was able to manage the first scale to prepopulate the ''To" button by the help of a fellow SF user.

My steps where: 
1) Created a contact record associated with Supplier's value under Order.
2) Created a custom text field under Account to capture contact id of supplier's contact (might be called as Supplier's Contact ID). Because I have multiple order records under that particular account, I created an apex trigger as well ( see below)
3)Created Custom Task button to do URL hacking in order to prepopulate the field : https://cs18.salesforce.com/_ui/core/email/author/EmailAuthor?p2_lkid={!Account.Supplier_s_Contact_ID__c}&p3_lkid={!Account.Id}&retURL=%2F{!Account.Id}

trigger : 
trigger PopulateSupplierContactUnderAccount on Order (after insert, after update) {
    if(Trigger.isAfter)
    {
        if(Trigger.isInsert || Trigger.isUpdate)
        {
            Set<Id> setAccountIds = new Set<Id>();
            Map<Id,Id> mapOrderId_AccountId = new Map<Id,Id>();
            if(Trigger.isInsert)
            {
                for(Order o : Trigger.new)
                {
                    if(o.Supplier_s_Contact__c != NULL) //Supplier_s_Contact__c is API name of Supplier's Contact lookup field in Order object.
                    {
                        setAccountIds.add(o.AccountId);
                        mapOrderId_AccountId.put(o.Id, o.AccountId);
                    }
                }
            }
            else if(Trigger.isUpdate)
            {
                for(Integer i = 0; i < Trigger.size; i++)
                {
                    if(Trigger.new[i].Supplier_s_Contact__c != NULL && Trigger.new[i].Supplier_s_Contact__c != Trigger.old[i].Supplier_s_Contact__c)
                    {
                        setAccountIds.add(Trigger.new[i].AccountId);
                        mapOrderId_AccountId.put(Trigger.new[i].Id, Trigger.new[i].AccountId);
                    }
                }
            }
            //Supplier_s_Contact_ID__c is API name of Supplier's Contact ID custom text field in Account object.
            //Supplier_s_Contact_Name__c is API name of Supplier's Contact Name custom text field in Account object.
            Map<Id,Account> mapAccId_Account = new Map<Id,Account>();
            for(Account acc : [SELECT Id, Supplier_s_Contact_ID__c, Supplier_s_Contact_Name__c FROM Account WHERE Id IN :setAccountIds])
            {
                mapAccId_Account.put(acc.Id, acc);
            }
            List<Account> listAccounts = new List<Account>();
            Set<Id> setUpdatedAccountIds = new Set<Id>();
            for(Order o : [SELECT Id, AccountId, Supplier_s_Contact__c, Supplier_s_Contact__r.Name FROM Order WHERE Id IN :mapOrderId_AccountId.keySet()])
            {
                setUpdatedAccountIds.add(mapOrderId_AccountId.get(o.Id));
                Account getAcc = mapAccId_Account.get(mapOrderId_AccountId.get(o.Id));
                getAcc.Supplier_s_Contact_ID__c = o.Supplier_s_Contact__c;
                getAcc.Supplier_s_Contact_Name__c = o.Supplier_s_Contact__r.Name;
                if(!setUpdatedAccountIds.contains(getAcc.Id) || setUpdatedAccountIds.size() == 1)
                {
                    listAccounts.add(getAcc);
                }
            }
            if(!listAccounts.isEmpty())
            {
                update listAccounts;
            }
        }
    }
}

So far so good. "To" is prepopulated. What I need is to predefine the email template as well. I have found an article from Werewolf where he suggests a custom detail button with java behavior:  ​location.replace('/email/author/emailauthor.jsp?retURL=/{!Case.Id}&p3_lkid={!Case.Id}&rtype=003&p2_lkid={!Case.ContactId}&template_id=<your template here>');

How can I mix these two into one button in order to prepopulate contact and predefine the template?
Hi All,

I've written a trigger for Orders where whenever I send an email through the Order the status in the order from 'draft' will become 'sent'. And it works like a charm. My trigger is :
 
trigger TaskTrigger on Task (after insert) {
    List<Order> ordersToUpdate = new List<Order>();

    for(Task t : Trigger.new) {
        if(t.WhatId.getSObjectType() == Order.sObjectType 
            && t.Subject.startsWith('Email:')) {
                ordersToUpdate.add(new Order(Id = t.WhatId, Status = 'Sent'));
        }
    }

    update ordersToUpdate;
}

My problem is with the test class. After modifying my calss alot of times I came to a result where System.AssertException: Assertion Failed: Expected: Sent, Actual: draft

My class is 
@isTest
   public class Test7{
    public static testmethod void TaskTrigger_Test1()
    {
             Account a = new Account(Name = 'Test');
        insert a;     

        Id pricebookId = Test.getStandardPricebookId();                         

        Product2 prd1 = new Product2 (Name='Test Product Entry 1',Description='Test Product Entry 1', isActive = true);
        insert prd1;

        PricebookEntry pe=new PricebookEntry(UnitPrice = 1,Product2Id=prd1.id,Pricebook2Id=pricebookId,isActive=true);
        insert pe;

        Order o = new Order(name='Test1',AccountId=a.id,EffectiveDate=system.today(),status='draft', PriceBook2Id=pricebookId);
        insert o;

        OrderItem oi = new OrderItem(OrderId=o.id,Quantity=1,PricebookEntryId=pe.id, unitPrice=1);
        insert oi;


        Task t = new Task(whatid=o.id,Priority = 'normal',status='open',subject='Email:xxxx');
        insert t;
        
        system.assertequals('Sent',o.status);
    }


}

 
My trigger is :
 
trigger TaskTrigger on Task (after insert) {
    List<Order> ordersToUpdate = new List<Order>();

    for(Task t : Trigger.new) {
        if(t.WhatId.getSObjectType() == Order.sObjectType 
            && t.Subject.startsWith('Email:')) {
                ordersToUpdate.add(new Order(Id = t.WhatId, Status = 'Sent'));
        }
    }

    update ordersToUpdate;
}



my test class is :
 
@isTest(seeAllData = true)
   public class Test7{
    public static testmethod void TaskTrigger_Test1()
    {
            Account a = new Account(Name = 'Test');
            insert a;
          
            //get standard pricebook
            Pricebook2  standardPb = [select id, name, isActive from Pricebook2 where IsStandard = true limit 1];
            
            Product2 prd1 = new Product2 (Name='Test Product Entry 1',Description='Test Product Entry 1',productCode = 'ABC', isActive = true);
            insert prd1;
            
            PricebookEntry standardPrice = new PricebookEntry(Pricebook2Id = standardPB.Id, Product2Id = prd1.Id, UnitPrice = 1, IsActive = true, UseStandardPrice = false);
            insert standardPrice;
             
            PricebookEntry pe=new PricebookEntry(UnitPrice = 1,Product2Id=prd1.id,Pricebook2Id=standardPB.id,isActive=true, UseStandardPrice = false);
            insert pe;
            
            Order o = new Order(name='Test1',AccountId=a.id,EffectiveDate=system.today(),status='draft');
            insert o;
            
            OrderItem oi = new OrderItem(OrderId=o.id,Quantity=decimal.valueof('1'),PricebookEntryId=pe.id);
            insert oi;


        Task t = new Task(whatid=o.id,Priority = 'normal',status='open',subject='Email:xxxx');
        insert t;
        
        system.assertequals('Sent',o.status);
    }


}





And the error is : System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, This price definition already exists in this price book: []

Any Ideas why?
Hello ,

I have a trigger fro defaulting the standard pricebook for the order
 
trigger InsertPriceBookTrigger on Order (before insert) { 
 List<Pricebook2> stdPBL =  [select id from Pricebook2 where IsStandard = TRUE];
 if(!stdPBL.isEmpty()){
  for(Order o: Trigger.new)
   o.PriceBook2Id = stdPBL[0].id;
  }
}

My test class is
 
@isTest
public class Test5{
    public static testmethod void InsertPriceBookTrigger_Test1()
    {
       Account a = new Account(
            Name = 'Test'
            
        );
        insert a;
        
        Order o = new Order(name='Test1',AccountId=a.id,EffectiveDate=system.today(),status='draft');
        insert o;

    List<Pricebook2> stdPBL =  [select id from Pricebook2 where IsStandard = TRUE];

    if (!stdPBL.isEmpty())
    {
        system.assertequals(stdPBL[0].id,o.PriceBook2Id);
    }
    } 
}

The problem is when I run the test the test class passes but covers only 50% of the trigger. 
Any ideas why??
Hello all,

I have these two trigger 
trigger InsertPriceBookTrigger on Order (before insert) { 
 List<Pricebook2> stdPBL =  [select id from Pricebook2 where IsStandard = TRUE];
 if(!stdPBL.isEmpty()){
  for(Order o: Trigger.new)
   o.PriceBook2Id = stdPBL[0].id;
  }
}

and 
 
​trigger TaskTrigger on Task (after insert) {
    List<Order> ordersToUpdate = new List<Order>();

    for(Task t : Trigger.new) {
        if(t.WhatId.getSObjectType() == Order.sObjectType 
            && t.Subject.startsWith('Email:')) {
                ordersToUpdate.add(new Order(Id = t.WhatId, Status = 'Sent'));
        }
    }

    update ordersToUpdate;
}

for these triggers created the following test class
 
@isTest
public class Test3{
    public static testmethod void InsertPriceBookTrigger_Test1()
    {
       Account a = new Account(
            Name = 'Test'

        );
        insert a;

        Order o = new Order(name='Test1',EffectiveDate=system.today(),status='draft');
        insert o;

    List<Pricebook2> stdPBL =  [select id from Pricebook2 where IsStandard = TRUE];

    if (!stdPBL.isEmpty())
    {
        system.assertequals(stdPBL[0].id,o.PriceBook2Id);
    }
    } 

    public static testmethod void TaskTrigger_Test1()
    {

            Order o = new Order(name='Test1',EffectiveDate=system.today(),status='draft');
            insert o;

        Task t = new Task(whatid=o.id,Priority = 'normal',status='open',subject='Email:xxxx');
        insert t;

        system.assertequals('Sent',o.status);
    }


}

It fails to cover the triggers. The error on the test history is :


System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Account Name:You must enter a value: []

Any ideas why?
Hello,


I have 2 triggera into sandbox that work s perfectly and I want to transfer it into production. The only problem is that I need to write a test class for each one in order to cover 75% of the triggers in order to fullfill this. My triggers are
 
trigger InsertPriceBookTrigger on Order (before insert) { 
 List<Pricebook2> stdPBL =  [select id from Pricebook2 where IsStandard = TRUE];
 if(!stdPBL.isEmpty()){
  for(Order o: Trigger.new)
   o.PriceBook2Id = stdPBL[0].id;
  }
}
 
​trigger TaskTrigger on Task (after insert) {
    List<Order> ordersToUpdate = new List<Order>();

    for(Task t : Trigger.new) {
        if(t.WhatId.getSObjectType() == Order.sObjectType 
            && t.Subject.startsWith('Email:')) {
                ordersToUpdate.add(new Order(Id = t.WhatId, Status = 'Sent'));
        }
    }

    update ordersToUpdate;
}

Any ideas would be helpfull. Is there any generic way to do this? Any manuals or anything to study through in order to achieve this (and for future purposes as well)
Hi trying to create a package to move it from sandbox to prod via Force.com. When I try to do it and input my login credentials as well with my secur token i get the following error.

User-added image

Any ideas?
Hello,

I have created a custom object called Reservaitons. I am looking for a way to update a field as soon as I receive a second reservation(2nd line item).

I tried a workflow rule but on the criteria I couldn't find anything that is about a second line item. My unique field is ReservationID but the client might already have a reservation on his card. 
HI All,


I have a custom object named Reservations where I have nearly to 65 custom fields. This object is related to Contacts.On contacts I have a custom field (checkbox) saying if the contact responded 60 days from the time I have send him a newsletter. 

So my problem is that if the client comes back to me with a new reservation before the 60 days expires that custom field on contact should be checked.
If not will remain unchecked.
Any suggestions?
Hi all,


My business scenario that I am having problems to resolve is the following. I am sending quotes to our clients with various products(different product families). 
As soon as the client accepts the terms I create an order per each product family as I have suppliers per product family. As you understand this is a duplication of my work creating the opp and then the quote. 
Ideally with a hit of a button I could transfer lets say products a,b,c of product family A into the assigned order form layout for product family A. With another button the products d,e,f of product family B will go to the order form layout of pro fami. B.

I do not know if this can be done either by a custom button or a visualforce page. Anyhow I am seeking help from experts like you guys in the developer forum.

Thank you very much
Hi all,


Has anyone tried the 3CX integration for Salesforce. If yes can you please be kind and let me kow of advantages/disadvantages regarding this provider. If it's easy can you send some screenshots as well when you receive an incoming call how the interface looks.

Thank you in advance
Hello,


I am trying to insert new records into a custom object (production) via apex data loader. When I do so I get an error like
 
​ ReservationTrigger: execution of AfterInsert

caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing.
Even if a field is indexed a filter might still not be selective when:
1. The filter value includes null (for instance binding with a list that contains null)
2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times)

Trigger.ReservationTrigger: line 11, column 1

My trigger is 
trigger ReservationTrigger on Reservations__c (after insert,after update) {
    // Get the IDs of related contacts
    Set<Id> contactIds = new Set<Id>();
    for(Reservations__c oneReservation:trigger.new){
        if(oneReservation.ReservationStatus__c == 'Confirmed'){
            contactIds.add(oneReservation.Email__c);
        }
    }
    // Count the distinct Reservation_Number__c from the Reservation objects of all related contacts
    Map<Id, Integer> countDistinctReservationMap = new Map<Id, Integer>();
    for (AggregateResult aggRes : [SELECT COUNT_DISTINCT(ReservationCode__c) resNum, Email__c conId FROM Reservations__c WHERE Email__c IN: contactIds GROUP BY Email__c ]) {
         Id conId = (Id) aggRes.get('conId');
         Integer resNum  = (Integer) aggRes.get('resNum');
         countDistinctReservationMap.put(conId, resNum);
    }
    // Now fetch the Contacts in a list
    List<Contact> listContacts = [Select Id, customRollupField__c from Contact Where Id IN:contactIds];
    if(listContacts.size()>0) {
         for(Contact con : listContacts) {
              // fetch or get the distinct count or rollup from the map and copy it to the contact's field
              con.customRollupField__c = countDistinctReservationMap.get(con.Id);
         }
    }
    // Update the contacts
    update listContacts;
}

Any Ideas why?
I have moved my custom object(Reservations) with the custom fields(near to 50 fields) created in Sandbox into Production but when i try and create a new res I can use only the standard field of that custom object. All the other fields are not visible. When I go to the edit of the page layout I can see them but when I preview the layout they are missing. Did I forgot something during the transition from Sandbox to Production?
Hi all,


Due to my poor knowledge on apex I am seeking for help in this forum. I am really new to this so please spare me.
With help from another Dev a trigger was created for a custom object where using the Count_Dinstinct it was reading the unique ReservationCode__c and rolling up the custom field on Contacts if the trigger was firing due to its rules. 
Trigger is : 
 
trigger ReservationTrigger on Reservations__c (after insert,after update) {
    // Get the IDs of related contacts
    Set<Id> contactIds = new Set<Id>();
    for(Reservations__c oneReservation:trigger.new){
        if(oneReservation.ReservationStatus__c == 'Confirmed'){
            contactIds.add(oneReservation.Email__c);
        }
    }
    // Count the distinct Reservation_Number__c from the Reservation objects of all related contacts
    Map<Id, Integer> countDistinctReservationMap = new Map<Id, Integer>();
    for (AggregateResult aggRes : [SELECT COUNT_DISTINCT(ReservationCode__c) resNum, Email__c conId FROM Reservations__c WHERE Email__c IN: contactIds GROUP BY Email__c ]) {
         Id conId = (Id) aggRes.get('conId');
         Integer resNum  = (Integer) aggRes.get('resNum');
         countDistinctReservationMap.put(conId, resNum);
    }
    // Now fetch the Contacts in a list
    List<Contact> listContacts = [Select Id, customRollupField__c from Contact Where Id IN:contactIds];
    if(listContacts.size()>0) {
         for(Contact con : listContacts) {
              // fetch or get the distinct count or rollup from the map and copy it to the contact's field
              con.customRollupField__c = countDistinctReservationMap.get(con.Id);
         }
    }
    // Update the contacts
    update listContacts;
}

My problem is how to get the custom object onto the test class. 

Due to my poor knowledge I think that a test class should include  

Account a = new Account(Name = 'Test');
        insert a;     

     Contact c = new Contact(AccountId=a.Id, lastname='testing', firstname='apex', Email= 'xxxxx');
        insert c;

but here is where I stuck. How to get the custom object onto the test class with the count dinstinct??

Thank you in advance
 
Hi all,


I have a custom text field that I want to include into a workflow where my end result will be a field update(checkbox). What I want as a rule is when this custom text field is the same then the update won't take place. ie. when abc1234 = abc 1234 then nothing will happen. 

My question is how can I create this rule? (For a contact I have a custom object where it has records. In some cases two records have the same custom text field.)