• affu
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 17
    Questions
  • 28
    Replies

Hi,

 

I have three objects Obj1,Obj2 and Obj3

Relation between these three objects is Obj2 and Obj3 are the childs for Obj1

Requirement - i have created a visual force page in Obj2 and i want to call list of Obj3 records where Obj2 related with Obj1.

 

 

Thanks in Advance.....

  • May 13, 2013
  • Like
  • 0
public class SearchController
{
 public String nameQuery {get; set;}
 public List<Client__c> clients {get; set;}
  
 public PageReference executeSearch()
 {
  String queryStr='%' + nameQuery + '%';
  clients=[select id, Name
            from Client__c
            where name like :queryStr];
            
  return null;
 }
  
 public SearchController()
 {
  // if query appears in URL, execute it
  String urlQuery=ApexPages.currentPage().getParameters().get('query');
   
  if ( (null!=urlQuery) && (0!=urlQuery.length()) )
  {
   nameQuery=urlQuery;
   executeSearch();
  }
 }
}

 Please help me to write test class.....

 

Thanks in advance......

  • February 12, 2013
  • Like
  • 0

Apex Trigger:

trigger TriggerForReceipts on Receipt__c (after update) {  
List<smagicinteract__smsMagic__c> smsObjects = new List<smagicinteract__smsMagic__c>();
    Id receiptsId = null;  
    for (Receipt__c receipt : Trigger.new)
    {       
      continue;
      
      receiptsId = receipt.id;
        system.debug(system.logginglevel.INFO,'receiptsId :'+receiptsId);
        Receipt__c receiptObject=[select Id, Opportunity_Contact_Number__c, Name from Receipt__c where Id =:receiptsId];
        system.debug(system.logginglevel.INFO,'receiptObject :'+receiptObject);
        Receipt__c beforeUpdateReceipt = System.Trigger.oldMap.get(receiptsId);
        ReceiptsSMSController receiptSMSController = new ReceiptsSMSController();
        if(receiptObject.Opportunity_Contact_Number__c != null){ 
            if(receipt.Payment_Towards__c == 'On Booking'){
                if(receipt.Payment_Towards__c  != beforeUpdateReceipt.Payment_Towards__c){
                   system.debug(system.logginglevel.INFO,'in PaymentTowardsOnBooking..'+receipt.Payment_Towards__c);
                   smsObjects = receiptSMSController.sendSMS(smsObjects, receipt, 'Booking Payment');
                }                
            }
            if(receipt.Payment_Towards__c == 'On Booking' && receipt.Realization_Status__c == 'Done'){
                if((receipt.Payment_Towards__c  != beforeUpdateReceipt.Payment_Towards__c) && (receipt.Realization_Status__c  != beforeUpdateReceipt.Realization_Status__c)){
                   system.debug(system.logginglevel.INFO,'in PaymentTowardsAndRealizationStatus..'+receipt.Payment_Towards__c);
                   smsObjects = receiptSMSController.sendSMS(smsObjects, receipt, 'Booking payment realization');
                }                
            }
            if(receipt.Realization_Status__c == 'Bounced'){
                if(receipt.Realization_Status__c  != beforeUpdateReceipt.Realization_Status__c){
                   system.debug(system.logginglevel.INFO,'in RealizationStatusBounced..'+receipt.Realization_Status__c);
                   smsObjects = receiptSMSController.sendSMS(smsObjects, receipt, 'Cheque bounce');
                }                
            }
             if(receipt.Payment_Towards__c == 'Agreement Signing'){
                if(receipt.Payment_Towards__c  != beforeUpdateReceipt.Payment_Towards__c){
                   system.debug(system.logginglevel.INFO,'in PaymentTowardsOnBooking..'+receipt.Payment_Towards__c);
                   smsObjects = receiptSMSController.sendSMS(smsObjects, receipt, 'Agreement signing payment');
                }                
            }
            if(receipt.Payment_Towards__c == 'Agreement Signing' && receipt.Realization_Status__c == 'Done'){
                if((receipt.Payment_Towards__c != beforeUpdateReceipt.Payment_Towards__c) && (receipt.Realization_Status__c != beforeUpdateReceipt.Realization_Status__c)){
                   system.debug(system.logginglevel.INFO,'in PaymentTowardsAndRealizationStatus..'+receipt.Payment_Towards__c);
                   smsObjects = receiptSMSController.sendSMS(smsObjects, receipt, 'Booking payment realization');
                }                
            }
        }
        
    }
    system.debug(system.logginglevel.INFO,'smsObjects..'+smsObjects);
    insert smsObjects;
   
}

 Apex Class:

@isTest
private class TriggerForReceipts {

    static testMethod void test_TriggerForReceipts() {  
        Account a = new Account(name='test1', Phone='09003095572');
        insert a;
        Opportunity o2 = new Opportunity(
                  AccountId=a.Id,
                  Name='My Opportunity', 
                            StageName='Blocking', Booking_Receipt_Generated__c=true,
                            CloseDate=Date.today());
                            insert o2; 
        Receipt__c receiptObject=new Receipt__c(Name='1245*',Opportunity__c=o2.id,Instrument_Date__c=Date.today(),Bank_Reconciliation_Date__c=Date.today(),Transaction_No__c='123445',
                                 Mode_of_Payment__c='Cash',Payment_Towards__c='On Booking',Receipt_Date__c=Date.today());
       insert receiptObject;
        //Receipt__c receiptObject=[select Id, Opportunity_Contact_Number__c,Instrument_Date__c,Bank_Reconciliation_Date__c,
                                       // Receipt_Date__c,Mode_of_Payment__c,Amount__c,Transaction_No__c,Opportunity__c, Name from Receipt__c  limit 1 ];
        system.debug(system.logginglevel.INFO,'receiptObject :'+receiptObject);
        List<Receipt__c> receiptList = [select Id, Opportunity_Contact_Number__c,Instrument_Date__c,Bank_Reconciliation_Date__c,
                                        Receipt_Date__c,Payment_Towards__c,Mode_of_Payment__c,Amount__c,Transaction_No__c,Opportunity__c, Name from Receipt__c where Id =: receiptObject.Id];
        system.debug(system.logginglevel.INFO,'receiptList :'+receiptList);
        receiptList[0].Receipt_Date__c = Date.today();
         //Transaction_No__c
        update receiptList;
    }
}

 Thanks in advance......

  • October 03, 2012
  • Like
  • 0

Hai All,

 

I have one requirement, can we the get the Task list in Visualforce page?????

 

I have tried a lot but i couldnt find out the solution.

Here is the code. Im getting error as List Controllers are supported for Task

public with sharing class TaskPagination {
private final Task t;

public TaskPagination(ApexPages.StandardSetController controller) {
this.c = (Task)controller.getRecord();
}
public ApexPages.StandardSetController TaskRecords{
get {
if(TaskRecords == null) {
return new ApexPages.StandardSetController(Database.getQueryLocator(
[SELECT t.ActivityDate, t.Status FROM Task t]));
}
return TaskRecords;
}
private set;
}
public List<Task> getTaskPagination() {
return (List<Task>) TaskRecords.getRecords();
}
}

 Thanks in Advance..........

 

  • September 17, 2012
  • Like
  • 0

I have created a custom field in Task(Activity) and i want to update that field with Phone field from contacts.

 

Main reason for writting a trigger is i want to show it in a Task list view(visualforce page).

 

Here is the Trigger:

 

 

trigger CopyPhone on Task (after update) {

   Set<Id> contactIds = new Set<Id>();
    for(Task t : trigger.new){
        String wId = t.WhoId;
        if(wId!=null && wId.startsWith('003') && !contactIds.contains(t.WhoId)){
            contactIds.add(t.WhoId);
        }
    }
    List<Contact> taskcons = [Select Id,Phone from Contact where Id in :contactIds];
    Map<Id, Contact> conMap = new Map<Id, Contact>();
    for(Contact c : taskcons){
        conMap.put(c.Id,c);
    }
    for(Task t : trigger.new){
        String wId = t.WhoId;
        if(wId!=null && wId.startswith('003')){
            Contact thisCon = conMap.get(t.WhoId);
            if(thisCon!=null){
                t.ThirdPartyNo__c = thisCon.Phone;
            } 
        }
    }
}

 Thanks in Advance.........

  • September 13, 2012
  • Like
  • 0

Hi all,

 

I have written a Visualforce PDF with extension class to call the list of contacts and a button on Button on Opportunity pagelayout .

The buttons works as if stagename == site visit it should give an error else open the PDF.

But here the problem is onclick javascript is working properly but im not getting the CONTACT values in visualforce page.

Visualforce page and Button is on Opportunity 

 

 

Javascript&colon;

var a = '{!Opportunity.StageName}'; 
if(a == 'Site Visit') 
alert('Please fill the Application Details');  
else 
window.open('/apex/Application_PDF?scontrolCaching=1&id={!Opportunity.Id}');

 Thanks in Advance...

  • September 08, 2012
  • Like
  • 0

Hi,

 

I want to write a trigger to update a field in one object called schedules

 

scenario is:

 

i have no.of schedules related to opportunity and i have two fields in schedules named test1 and test2

lets say 

schedule record 1 - test1(field) value is 10 then the test2(field) should update as 10

schedule record 2 - test1(field) value is 20 then the test2(field) should update as 30

schedule record 3 - test1(field) value is 30 then the test2(field) should update as 60

 

So the test2 field should update as test2 from the previous record and add it to current record

 

 

thanks in advance

  • July 26, 2012
  • Like
  • 0

Hi All,

 

I have a image in Visualforce pdf and i want it to display according to the field selection 

 

I have used the following code but it is not working

<apex:image url="{!$Resource.Image1}" rendered="{!Opportunity.Project_l__c='East Point'}" />

 

Project_I__c is a lookup field in Opportunity.

when i select this field as East Point it should show the image.

 

Please help me...

Thanks in advance.

  • July 02, 2012
  • Like
  • 0
How can we copy email id from person account to any other related object. E.g. Email id from Person account to Opportunity.
  • May 29, 2012
  • Like
  • 0

Hi All ,

 

I have Three Objects 

 

Opportunity 

Parking Detail  - junction object to Opportunity and Car Park

Car Park 

 

Opportunity fields - Stage: Picklist(site visit, booking. blocking)

Parking Detail fields - Opportunity: lookup , Carpark: lookup

Car Park fields - Status: Picklist(Available,booked,blocked)

 

Here the should fire when oportunity status=blocking Parking details should check all the records which related to that opportunity and should update the carpark status= blocked

 

Please help me

 

Thank u 

 

  • May 14, 2012
  • Like
  • 0

Hi all,

I have written a Trigger in Opportunity it fires when an opportunity is created automatically a record will be created in another object

Here i want multiple records to be created for one Opportunity

 

Objects :

Opportunity and

Record

 

Trigger:

trigger AutoCreateRecord on Opportunity (after insert){
    List<Record__c> Records = new List<Record__c>();
    for (Opportunity newOpportunity: Trigger.New){
        if(newOpportunity.CloseDate!=null && newOpportunity.StageName=='Closed Won'){
            Records.add(new Record__c(
                        Name ='1',
                        Opportunity__c = newOpportunity.Id,
                        Amount__c = 12));
        }
    }
    insert Records;
}

 

  • April 09, 2012
  • Like
  • 0

Hi all,

Please help me to write a Trigger.

 

In Opportunity i have a related list Schedule

It shows(has) three fields:-

 

Total Receipt Amount Realized - Curreny field, it rollups all the receipts by trigger( this is done)

Installement Basic Value - Currency field

Total Amount Setoff - formula field (Total Amount Realized -Installement Basic Value)

 

Here i want to write a Trigger it should work as below

 

I have three records in Schedule it shows

Schedule NameTotal Receipts Realized       Installement Basic Value       Total Amount Setoff

On Booking                      20000                                       10000                                        10000

Agreement Signing                                   20000                                        5000                                         15000

Excavation                                                   20000                                        5000                                         15000

 

For first record (On Booking) Total Amount Setoff is calculating correctly i.e., 20000-10000=10000 

 

For second record (Agreement Signing) it should take the first records (On Booking) Total Amount Setoff and it should deduct from Installement Basic Value and it should give the Total Amount Setoff in second record Amount as 10000-5000=5000.

The Result should be below mentioned

 

Schedule Name          Total Receipts Realized       Installement Basic Value       Total Amount Setoff

On Booking                              20000                                       10000                                        10000

Agreement Signing                20000                                        5000                                          5000

Excavation                                20000                                        5000                                          0

 

Thanks in advance.....

Schedule

  • March 27, 2012
  • Like
  • 0

Hi all,

Here iam posting button which executes java script 

This is about sending a single sms to one contact, but i want to send SMS for bulk contacts 

Any changes to be done?

 

{!REQUIRESCRIPT("/soap/ajax/14.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/14.0/apex.js")}

var packagePrefix = "smagicinteract__";
var recordType = 'Shipment_Details__c';
var idToUpdate = '{!Shipment_Details__c.Id}'
var phoneField = 'Dealer_Account_Mobile_No__c';
var nameField = '';
var queryString = parent.window.location.pathname;
if (parent.window.location.search){
queryString = queryString + parent.window.location.search
}
var url = "/apex/"+packagePrefix+"BulkSendSMS?retURL="+queryString + "&objectType="+recordType+"&recordIds="+ idToUpdate+"&phoneField="+phoneField+"&nameField=" ;
parent.window.location = url

 

  • March 15, 2012
  • Like
  • 0

I am getting 50% code coverage plz help urgent

 

Trigger

trigger UpdateOfDealerName On Opportunity (before insert,before update) {
    for(Opportunity o: Trigger.New) {
        if((o.RecordTypeName__c == 'Petty Sales')&&((o.User_ID__c =='Custom Partner User - Karnataka')||
            (o.User_ID__c =='Custom Partner User - Non Karnataka'))) {       
            
            o.AccountId = [select Account_Name__c from User where ID =: UserInfo.getUserId() Limit 1].Account_Name__c;
         }
    }
}

 Testclass

 

@istest
private class TestClass {
    public static testmethod void testing() { 
        Account a = new Account(Name='Test Account');
        insert a;
        Opportunity o = new opportunity(name='test opportunity', Accountid=a.id, stagename='Payment Collected', CloseDate=System.Today());
        insert o;
        o.AccountId = [select Account_Name__c from User where ID =: UserInfo.getUserId() Limit 1].Account_Name__c;
        update a;
        update o;
    }
}

 

  • March 13, 2012
  • Like
  • 0

Hi all,

I have written a Trigger but i am not able to write testclass and tried different ways plz help me out...

 

This trigger works as roll-up summary 

trigger TotalQtyShippedInsaleorderitem on Dispatch_Detail_Item__c (after delete, after insert, after undelete, 
after update) {
  Map<Id,Sale_Order_Item__c> mapsoi = new Map<Id,Sale_Order_Item__c>();
    Set<Id> soiId = new Set<Id>();
    try {
        // If insert, update or undelete put the new values into soiId
        if(Trigger.isInsert || Trigger.isUpdate || Trigger.isUndelete){
            for(Dispatch_Detail_Item__c ddi : Trigger.new) {
                soiId.add(ddi.Sale_Order_Item__c);
            }
        }
        // If we are updating, some Sale_Order_Item__c values might change, so include that as well as deletes
        if(Trigger.isUpdate || Trigger.isDelete){
            for(Dispatch_Detail_Item__c ddi : Trigger.old) {
                soiId.add(ddi.Sale_Order_Item__c);
            }
        }
        
        soiId.remove(null);
        for(Id pId : soiId) {
            mapsoi.put(pId,new Sale_Order_Item__c(Id=pId,Total_Of_Dispatches_Shipped__c=0));
        }
        
        for(Dispatch_Detail_Item__c ddi : [select Total_Amt_Shipped__c,Sale_Order_Item__c from Dispatch_Detail_Item__c WHERE Sale_Order_Item__c IN: soiId]) {
            mapsoi.get(ddi.Sale_Order_Item__c).Total_Of_Dispatches_Shipped__c += ddi.Total_Amt_Shipped__c;
        }
        
        update mapsoi.values();
    }
    catch(Exception e) {
        System.debug('### Exception: ' + e.getMessage());
    }

}

 Here is the Testclass, There are two objects "Sale order item" and" Dispatch detail item" but the problem is"sale order item" is related to "sale order" object and i have some mandatory lookups and master detail fields like DEALER ACCOUNT master detail to ACCOUNT , CUSTOMER ACCOUNT lookup to ACCOUNT and OPPORTUNITY lookup . How can i call this id's.

@istest
private class TotalShippedTestClass {
    static testMethod void myUnitTest() { 
        Sale_Order_Item__c soi = new Sale_Order_Item__c(Sale_Order__c='a0KO000000096Wl');
        Dispatch_Detail_Item__c ddi = new Dispatch_Detail_Item__c(Sale_Order_Item__c=soi.id);
        insert soi;
        insert ddi;
        update soi;
        update ddi;
    }
}

 

  • March 12, 2012
  • Like
  • 0

Here im posting Trigger and Testclass. Plz help in code coverage....Urgent......

 

Trigger:

 

trigger Update_completed_activities_in_Opportunity on Task (after update)
{
list<opportunity> liOpportunities = new list<opportunity>();
list<id> liIDs = new list<id>();


for(Task sTask : trigger.new)
{
if(sTask.Status == 'Completed' && ('' + sTask.WhatId).startsWith('006'))
{
liIDs.add(sTask.WhatId);
}
system.debug('Task123'+sTask);
for(Opportunity sOppty : [ select id,Welcome_Call_Completed__c, 
Welcome_Kit_Dispatched__c,
Agreement_Amount_Received__c,
Construction_Agreement_Received__c,
Sale_Agreement_Received__c from Opportunity where Id in : liIDS])

{
system.debug('sOppty123'+sOppty); 
if (liOpportunities .isEmpty())
{
return; // the task is not referring to an opportunity so exit the trigger
}
sOppty = liOpportunities[0]; // the zero'th, i.e. first (only) opportunity in the lis


liOpportunities.add(sOppty);
system.debug('OpportunityList'+liOpportunities);

if(sTask.Status == 'completed' && sTask.Subject == 'Welcome Call' && !sOppty.Welcome_Call_Completed__c)
{
sOppty.Welcome_Call_Completed__c = true;
}
if(sTask.Status == 'completed' && sTask.Subject == 'Dispatch Welcome Kit' && !sOppty.Welcome_Kit_Dispatched__c)
{
sOppty.Welcome_Kit_Dispatched__c = true;
}
if(sTask.Status == 'completed' && sTask.Subject == 'Collect Agreement Amount' && sOppty.Agreement_Amount_Received__c == Null)
{
sOppty.Agreement_Amount_Received__c = System.today();
}
if(sTask.Status == 'completed' && sTask.Subject == 'To check physical receipt of Agreement Copies' && !sOppty.Construction_Agreement_Received__c && !sOppty.Sale_Agreement_Received__c)
{
sOppty.Construction_Agreement_Received__c = true;
sOppty.Sale_Agreement_Received__c = true;
}
}
}
update liOpportunities;
}

 

 TestClass:

 

@isTest
private class Activity_Receipt_Trigger_Test{


    static testMethod void myopptyTest() {
     
     
        Account A = new account(name='Ac');
        insert A;
        
        Opportunity O = new opportunity (name='Oppty', 
                                         Accountid = A.id, 
                                         Stagename = 'Sold', 
                                         CloseDate = System.Today(),
                                         Welcome_Call_Completed__c = False,
                                         Welcome_Kit_Dispatched__c = False,
                                         Agreement_Amount_Received__c = Null,
                                         Construction_Agreement_Received__c = False,
                                         Sale_Agreement_Received__c = False);
        insert O;
        
        Task T = new task(Subject='Welcome Call', Status='Not Started', whatid = O.id);
        insert T;
        Task T1=new task(Subject='Dispatch Welcome Kit', Status='Not Started', whatid = O.id);
        insert T1;
        Task T2=new task(Subject='Collect Agreement Amount' , Status='Not Started', whatid = O.id);
        insert T2;
        Task T3=new task(Subject='To check physical receipt of Agreement Copies' , Status='Not Started', whatid = O.id);
        insert T3;
        Receipt__c R = new Receipt__c (name='test123', Realization_status__c = 'Not Done', Payment_Towards__c = 'Agreement Signing', Opportunity__c = O.id);
        insert R;
        R.Realization_Status__c ='Done';
        Update R;
       
        T.Status = 'Completed';
        T1.Status='Completed';
        T2.Status='Completed';
        T3.Status='Completed';
        Update T;
        Update T1;
        Update T2;
        Update T3;
        O.Agreement_Amount_Realized__c = System.today();
        O.Agreement_Amount_Received__c = System.today();
        O.Booking_Amount_Realized__c = System.today();
        O.Welcome_Call_Completed__c = true;
        O.Welcome_Kit_Dispatched__c = true;
        O.Construction_Agreement_Received__c = true;
        O.Sale_Agreement_Received__c = true;
        
        Update O;
        
}
}

 

  • March 06, 2012
  • Like
  • 0

Hi,

I have written a Trigger and Testclass. Im getting 59% coverage plz refer the code

* Urgent

 

Trigger -

trigger ePeople_ApartmentBlock on Opportunity (after update) {
    Map<Id,Id> opptyAppMap1 = new Map<Id,Id>();
    Map<Id,Id> opptyAppMap2 = new Map<Id,Id>();
    Map<Id,Id> opptyAppMap3 = new Map<Id,Id>();
    Map<Id,Id> opptyAppMap4 = new Map<Id,Id>();
    List<Apartment__c> testApp1 = new List<Apartment__c>();
    List<Apartment__c> testApp2 = new List<Apartment__c>();
    List<Apartment__c> testApp3 = new List<Apartment__c>();
    List<Apartment__c> testApp4 = new List<Apartment__c>();
    List<Apartment__c> testApp5 = new List<Apartment__c>();
    Set<Id> oldAppSetId = new Set<Id>();
    Set<Id> delOppAppId = new Set<Id>();
    for(Opportunity opp:Trigger.new){
        if(opp.Apartment__c != null && (opp.StageName == 'Site Visit' || opp.StageName == 'Closed Lost')){
            opptyAppMap1.put(opp.Apartment__c, opp.Id);
        }
        else if(opp.Apartment__c != null && opp.StageName == 'Booking'){
            opptyAppMap2.put(opp.Apartment__c, opp.Id);
        }
        else if(opp.Apartment__c != null && (opp.StageName == 'Blocking' || opp.StageName == 'Negotiation/Review')){
            opptyAppMap3.put(opp.Apartment__c, opp.Id);
        }
        else if(opp.Apartment__c != null && opp.StageName == 'Agreement Done'){
            opptyAppMap4.put(opp.Apartment__c, opp.Id);  
        }
        else if(System.Trigger.oldMap.get(opp.Id).Apartment__c != null && opp.Apartment__c != System.Trigger.oldMap.get(opp.Id).Apartment__c)
        {
            Opportunity oldOpp =  Trigger.oldMap.get(opp.Id);
            oldAppSetId.add(oldOpp.Apartment__c);
        }
           
    for(Apartment__c c:[select Id, Status__c from Apartment__c where Id IN:opptyAppMap1.keySet()]){
        if(c.Status__c != 'Available'){
            c.Status__c = 'Available';
        }   
        testApp1.add(c);
    }
    update testApp1;
    for(Apartment__c c:[select Id, Status__c from Apartment__c where Id IN:opptyAppMap2.keySet()]){
        if(c.Status__c != 'Booked'){
            c.Status__c = 'Booked';
        }   
        testApp2.add(c);
    }
    update testApp2;
    for(Apartment__c c:[select Id, Status__c from Apartment__c where Id IN:opptyAppMap3.keySet()]){
        if(c.Status__c != 'Blocked'){
            c.Status__c = 'Blocked';
        }    
        testApp3.add(c);
    }
    update testApp3;
    for(Apartment__c c:[select Id, Status__c from Apartment__c where Id IN:opptyAppMap4.keySet()]){
        if(c.Status__c != 'Sold'){
            c.Status__c = 'Sold';
        }    
        testApp4.add(c);
    }
     update testApp4;
     
    for(Apartment__c c : [select Id, Status__c from Apartment__c where Id IN:oldAppSetId]){
        if(c.Status__c != 'Available'){
            c.Status__c = 'Available';
        }    
        testApp5.add(c);
    }
     update testApp5;
    
    }
    for(Opportunity opp:Trigger.old){
     if(Trigger.isDelete){ 
       Opportunity oldOpp = Trigger.oldMap.get(opp.Id);
       system.debug('OpportunityMap'+oldOpp);
       delOppAppId.add(oldOpp.Apartment__c);
     } 
    }
}

 Testclass -

@isTest
private class ePeople_AptOpportunityTest{
    static testMethod void AptTest()
    {
      Account a = new Account(name='Ramesh');
      insert a;
      Project__c pr = new Project__c(Name='VV');
      insert pr;
      Block__c b = new Block__c(Name='Block 1',Project__c=pr.id);
      insert b;
      Apartment__c c = new Apartment__c(Name='A1',Block__c=b.id, Status__c = 'Blocked');
      insert c;
      Apartment__c c1 = new Apartment__c(Name='A1',Block__c=b.id, Status__c = 'Booked');
      insert c1;
      Opportunity o=new Opportunity(Name='ram test',AccountId=a.Id, CloseDate=Date.today(),StageName='Blocking', Apartment__c = c.id);
      insert o; 
      a.Name='Ramesh';
      update a;
      o.StageName ='Booking' ;
      o.StageName = 'Blocking';
      c.Status__c = 'Available';
      update c;
      update o;
    }
}q

 

  • February 29, 2012
  • Like
  • 0

Hi,

 

I have three objects Obj1,Obj2 and Obj3

Relation between these three objects is Obj2 and Obj3 are the childs for Obj1

Requirement - i have created a visual force page in Obj2 and i want to call list of Obj3 records where Obj2 related with Obj1.

 

 

Thanks in Advance.....

  • May 13, 2013
  • Like
  • 0
public class SearchController
{
 public String nameQuery {get; set;}
 public List<Client__c> clients {get; set;}
  
 public PageReference executeSearch()
 {
  String queryStr='%' + nameQuery + '%';
  clients=[select id, Name
            from Client__c
            where name like :queryStr];
            
  return null;
 }
  
 public SearchController()
 {
  // if query appears in URL, execute it
  String urlQuery=ApexPages.currentPage().getParameters().get('query');
   
  if ( (null!=urlQuery) && (0!=urlQuery.length()) )
  {
   nameQuery=urlQuery;
   executeSearch();
  }
 }
}

 Please help me to write test class.....

 

Thanks in advance......

  • February 12, 2013
  • Like
  • 0

Apex Trigger:

trigger TriggerForReceipts on Receipt__c (after update) {  
List<smagicinteract__smsMagic__c> smsObjects = new List<smagicinteract__smsMagic__c>();
    Id receiptsId = null;  
    for (Receipt__c receipt : Trigger.new)
    {       
      continue;
      
      receiptsId = receipt.id;
        system.debug(system.logginglevel.INFO,'receiptsId :'+receiptsId);
        Receipt__c receiptObject=[select Id, Opportunity_Contact_Number__c, Name from Receipt__c where Id =:receiptsId];
        system.debug(system.logginglevel.INFO,'receiptObject :'+receiptObject);
        Receipt__c beforeUpdateReceipt = System.Trigger.oldMap.get(receiptsId);
        ReceiptsSMSController receiptSMSController = new ReceiptsSMSController();
        if(receiptObject.Opportunity_Contact_Number__c != null){ 
            if(receipt.Payment_Towards__c == 'On Booking'){
                if(receipt.Payment_Towards__c  != beforeUpdateReceipt.Payment_Towards__c){
                   system.debug(system.logginglevel.INFO,'in PaymentTowardsOnBooking..'+receipt.Payment_Towards__c);
                   smsObjects = receiptSMSController.sendSMS(smsObjects, receipt, 'Booking Payment');
                }                
            }
            if(receipt.Payment_Towards__c == 'On Booking' && receipt.Realization_Status__c == 'Done'){
                if((receipt.Payment_Towards__c  != beforeUpdateReceipt.Payment_Towards__c) && (receipt.Realization_Status__c  != beforeUpdateReceipt.Realization_Status__c)){
                   system.debug(system.logginglevel.INFO,'in PaymentTowardsAndRealizationStatus..'+receipt.Payment_Towards__c);
                   smsObjects = receiptSMSController.sendSMS(smsObjects, receipt, 'Booking payment realization');
                }                
            }
            if(receipt.Realization_Status__c == 'Bounced'){
                if(receipt.Realization_Status__c  != beforeUpdateReceipt.Realization_Status__c){
                   system.debug(system.logginglevel.INFO,'in RealizationStatusBounced..'+receipt.Realization_Status__c);
                   smsObjects = receiptSMSController.sendSMS(smsObjects, receipt, 'Cheque bounce');
                }                
            }
             if(receipt.Payment_Towards__c == 'Agreement Signing'){
                if(receipt.Payment_Towards__c  != beforeUpdateReceipt.Payment_Towards__c){
                   system.debug(system.logginglevel.INFO,'in PaymentTowardsOnBooking..'+receipt.Payment_Towards__c);
                   smsObjects = receiptSMSController.sendSMS(smsObjects, receipt, 'Agreement signing payment');
                }                
            }
            if(receipt.Payment_Towards__c == 'Agreement Signing' && receipt.Realization_Status__c == 'Done'){
                if((receipt.Payment_Towards__c != beforeUpdateReceipt.Payment_Towards__c) && (receipt.Realization_Status__c != beforeUpdateReceipt.Realization_Status__c)){
                   system.debug(system.logginglevel.INFO,'in PaymentTowardsAndRealizationStatus..'+receipt.Payment_Towards__c);
                   smsObjects = receiptSMSController.sendSMS(smsObjects, receipt, 'Booking payment realization');
                }                
            }
        }
        
    }
    system.debug(system.logginglevel.INFO,'smsObjects..'+smsObjects);
    insert smsObjects;
   
}

 Apex Class:

@isTest
private class TriggerForReceipts {

    static testMethod void test_TriggerForReceipts() {  
        Account a = new Account(name='test1', Phone='09003095572');
        insert a;
        Opportunity o2 = new Opportunity(
                  AccountId=a.Id,
                  Name='My Opportunity', 
                            StageName='Blocking', Booking_Receipt_Generated__c=true,
                            CloseDate=Date.today());
                            insert o2; 
        Receipt__c receiptObject=new Receipt__c(Name='1245*',Opportunity__c=o2.id,Instrument_Date__c=Date.today(),Bank_Reconciliation_Date__c=Date.today(),Transaction_No__c='123445',
                                 Mode_of_Payment__c='Cash',Payment_Towards__c='On Booking',Receipt_Date__c=Date.today());
       insert receiptObject;
        //Receipt__c receiptObject=[select Id, Opportunity_Contact_Number__c,Instrument_Date__c,Bank_Reconciliation_Date__c,
                                       // Receipt_Date__c,Mode_of_Payment__c,Amount__c,Transaction_No__c,Opportunity__c, Name from Receipt__c  limit 1 ];
        system.debug(system.logginglevel.INFO,'receiptObject :'+receiptObject);
        List<Receipt__c> receiptList = [select Id, Opportunity_Contact_Number__c,Instrument_Date__c,Bank_Reconciliation_Date__c,
                                        Receipt_Date__c,Payment_Towards__c,Mode_of_Payment__c,Amount__c,Transaction_No__c,Opportunity__c, Name from Receipt__c where Id =: receiptObject.Id];
        system.debug(system.logginglevel.INFO,'receiptList :'+receiptList);
        receiptList[0].Receipt_Date__c = Date.today();
         //Transaction_No__c
        update receiptList;
    }
}

 Thanks in advance......

  • October 03, 2012
  • Like
  • 0

I want to update the one record data from pageblock/data table.please let me know f anybody knows this.it is urgent

Hai All,

 

I have one requirement, can we the get the Task list in Visualforce page?????

 

I have tried a lot but i couldnt find out the solution.

Here is the code. Im getting error as List Controllers are supported for Task

public with sharing class TaskPagination {
private final Task t;

public TaskPagination(ApexPages.StandardSetController controller) {
this.c = (Task)controller.getRecord();
}
public ApexPages.StandardSetController TaskRecords{
get {
if(TaskRecords == null) {
return new ApexPages.StandardSetController(Database.getQueryLocator(
[SELECT t.ActivityDate, t.Status FROM Task t]));
}
return TaskRecords;
}
private set;
}
public List<Task> getTaskPagination() {
return (List<Task>) TaskRecords.getRecords();
}
}

 Thanks in Advance..........

 

  • September 17, 2012
  • Like
  • 0

I have created a custom field in Task(Activity) and i want to update that field with Phone field from contacts.

 

Main reason for writting a trigger is i want to show it in a Task list view(visualforce page).

 

Here is the Trigger:

 

 

trigger CopyPhone on Task (after update) {

   Set<Id> contactIds = new Set<Id>();
    for(Task t : trigger.new){
        String wId = t.WhoId;
        if(wId!=null && wId.startsWith('003') && !contactIds.contains(t.WhoId)){
            contactIds.add(t.WhoId);
        }
    }
    List<Contact> taskcons = [Select Id,Phone from Contact where Id in :contactIds];
    Map<Id, Contact> conMap = new Map<Id, Contact>();
    for(Contact c : taskcons){
        conMap.put(c.Id,c);
    }
    for(Task t : trigger.new){
        String wId = t.WhoId;
        if(wId!=null && wId.startswith('003')){
            Contact thisCon = conMap.get(t.WhoId);
            if(thisCon!=null){
                t.ThirdPartyNo__c = thisCon.Phone;
            } 
        }
    }
}

 Thanks in Advance.........

  • September 13, 2012
  • Like
  • 0

Hi all,

 

I have written a Visualforce PDF with extension class to call the list of contacts and a button on Button on Opportunity pagelayout .

The buttons works as if stagename == site visit it should give an error else open the PDF.

But here the problem is onclick javascript is working properly but im not getting the CONTACT values in visualforce page.

Visualforce page and Button is on Opportunity 

 

 

Javascript&colon;

var a = '{!Opportunity.StageName}'; 
if(a == 'Site Visit') 
alert('Please fill the Application Details');  
else 
window.open('/apex/Application_PDF?scontrolCaching=1&id={!Opportunity.Id}');

 Thanks in Advance...

  • September 08, 2012
  • Like
  • 0

Hi,

 

I want to write a trigger to update a field in one object called schedules

 

scenario is:

 

i have no.of schedules related to opportunity and i have two fields in schedules named test1 and test2

lets say 

schedule record 1 - test1(field) value is 10 then the test2(field) should update as 10

schedule record 2 - test1(field) value is 20 then the test2(field) should update as 30

schedule record 3 - test1(field) value is 30 then the test2(field) should update as 60

 

So the test2 field should update as test2 from the previous record and add it to current record

 

 

thanks in advance

  • July 26, 2012
  • Like
  • 0

Hi All,

 

I have a image in Visualforce pdf and i want it to display according to the field selection 

 

I have used the following code but it is not working

<apex:image url="{!$Resource.Image1}" rendered="{!Opportunity.Project_l__c='East Point'}" />

 

Project_I__c is a lookup field in Opportunity.

when i select this field as East Point it should show the image.

 

Please help me...

Thanks in advance.

  • July 02, 2012
  • Like
  • 0
How can we copy email id from person account to any other related object. E.g. Email id from Person account to Opportunity.
  • May 29, 2012
  • Like
  • 0

Hi All ,

 

I have Three Objects 

 

Opportunity 

Parking Detail  - junction object to Opportunity and Car Park

Car Park 

 

Opportunity fields - Stage: Picklist(site visit, booking. blocking)

Parking Detail fields - Opportunity: lookup , Carpark: lookup

Car Park fields - Status: Picklist(Available,booked,blocked)

 

Here the should fire when oportunity status=blocking Parking details should check all the records which related to that opportunity and should update the carpark status= blocked

 

Please help me

 

Thank u 

 

  • May 14, 2012
  • Like
  • 0