• Mahesh K 22
  • NEWBIE
  • 79 Points
  • Member since 2016

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 16
    Questions
  • 18
    Replies
Hi,
I have two objects. Object1 and Object2.
I have 10 fields in object1. After creating a record in object1, I want to create a record in Object2.
I want only 3 field values from Object1.
If anyone have code syntax, please share.

Thanks in Advance

Regards,
Hari
I have written a apex class with test class both are running but my code coverage is only 66%.Please help to solve the problem.

Apex class-
global class Deleteoppotest implements Schedulable{

global void execute(SchedulableContext SC) {
    deleteoppo();
}

public static void deleteoppo() {

    for(List<opportunity> objoppo : [SELECT Id FROM opportunity WHERE CreatedDate <= :(Date.Today() - 200) LIMIT 10])
        {
            delete objoppo;
        }    
}

Test Class-
@isTest
private class Deleteoppotestcls {

static testMethod void myUnitTest() {
    // TO DO: implement unit test



    Opportunity op = new Opportunity();
    op.Name = 'test1';
    op.StageName = 'Qualified';
    op.CloseDate = Date.Today();
    op.Description ='testingoppotestcls';
    op.Business_Type__c = 'Domestic';


    insert op;


    Deleteoppotest.deleteoppo();

}
}

 
Hi to All,
         
          I would like to know Why dont we call future methods in batch class 
          Give me exaplanation and one example .
            Plz guys  
senario:
  We have two users and like A and B
 they have same profile and role,and in owd we have public read only,
 Once A user can create a records and B user cannt create records how can we do that?
Hi TO All,
Its very Important  and urgent
exaplain about salesforce architecture ?
This is my mailid : mahi.k418@gmail.com
trigger acctrgr on Account (before insert) {
    for(account a : trigger.new){
        if(a.phone == null){
            a.phone.adderror('phone filed not equla to null');
        }
    }
}
1. salesprocess flow of execution
2.service clooud process flow of execution
HI To All,
        
              I would like to know best realtime senarios on future method and queuable apex 
 
Hi To All
       
              i would like to know of ajax function like Action Function,Action Status,Action Region,ActionPollar,Action Support,
           How it works and when these can be use?????????
global class batchapex implements database.Batchable <sObject>,database.stateful {
    public integer i = 0;
       global database.QueryLocator start(database.BatchableContext bc){
           string query ='select id,First_name__c,Last_Name__c,Phone_No__c from Registration__c' ;
           system.debug('======================>'+query);
        return database.getQueryLocator(query);
    }
    global void execute(database.BatchableContext bc,list<Registration__c> reg){
        list<Registration__c> regupdate = new list<Registration__c>();
        for(Registration__c r:reg){
            r.Phone_No__c='04056' + i;
            r.Last_Name__c='mahesh'+i;
            r.Email__c = 'kmsr1055@gmail.com';
            regupdate.add(r);
            i++;
         }
        update regupdate;
      }
     global void finish(database.BatchableContext bc){
         Messaging.SingleEmailMessage email1= new Messaging.SingleEmailMessage();
       list<string> addemails = new list<string>();
               addemails.add('mahi.k418@gmail.com');
            email1.setToAddresses(addemails);
             email1.setPlainTextBody('this is inserting');
            email1.setSubject('inserting records into database');
            email1.setSenderDisplayName('Mahesh');
        Messaging.sendEmail(new Messaging.SingleEmailMessage [] {email1});
            
        }

}
Hi ALL,

I have 100 users in myorg.
 based on date of birth send greeting to particular users.

Please hlep me on this post.
Hello every one. can any one tell me how to write test class.
this is my code, i want to write test class
public class receipt80g{

   public receipt80g(ApexPages.StandardController controller) {
    
    List<Donation_Detail__c> donation=[select Donor__r.name,Bank_Name__c,Branch__c,Cheque_No__c,Amount__c,Mode_of_Payment__c,Date_of_Donation__c from Donation_Detail__c];
   
     }
}

thanks in advance.
Hi Dev's,

SOQL query for fetching records from Account not related to Contact object?(Only account records, which are not related to contact)?

Regards
Lakshmi

Thanks in advance..
 
HI ,

How to count the number of  records on opportunity  associated with on Account ? pls give me exammple ,
kindly help me on this 

viswsanath
Hi All,
I want to generate records from one object into another object. I have written a trigger for this and working fine.
I want this output in batch apex form
What ever I get the records in object1 today, I want a schedule batch apex that all records should get create in object2 at Midnight only.
How can I do this?
Please provide me syntax

Thanks in Advance

Regards,
Hari
Hi,
I have two objects. Object1 and Object2.
I have 10 fields in object1. After creating a record in object1, I want to create a record in Object2.
I want only 3 field values from Object1.
If anyone have code syntax, please share.

Thanks in Advance

Regards,
Hari
Hi,
The below trigger showing the field name " ModifiedAddress__c" doesnt exist. whereas the field API name is correct. Any idea plz why its giving such error.? Thanks
User-added image

Here, the full code below,
trigger trgContactChanges on Account (before update) {
   
    //This trigger perform when there is a change in Contact
   
    //To compare old and new value of Account
    if(Trigger.IsBefore && Trigger.IsUpdate) {
       
        for(Account NewAccount : Trigger.New) {
           
            for(Account OldAccount : Trigger.Old) {
               
                NewAccount.ModifiedAddress__c = false;
               
                //Compare Old Contact Phone Number with New Contact Phone Number
                if(NewAccount.Contact_Phone_Number_Mobile__c != oldAccount.Contact_Phone_Number_Mobile__c) {
                    NewAccount.ModifiedPhone1__c = true;
                } else {
                    NewAccount.ModifiedPhone1__c = false;
                }
               
                if(NewAccount.Contact_Phone_Number_Mobile2__c != oldAccount.Contact_Phone_Number_Mobile2__c) {
                    NewAccount.ModifiedPhone2__c = true;
                } else {
                    NewAccount.ModifiedPhone2__c = false;
                }
               
                if(NewAccount.Contact_Phone_Number_Mobile3__c != oldAccount.Contact_Phone_Number_Mobile3__c) {
                    NewAccount.ModifiedPhone3__c = true;
                } else {
                    NewAccount.ModifiedPhone3__c = false;
                }
               
                //Compare Old Contact Email Address with New Contact Email Address
                if(NewAccount.Contact_Email_Address__c != oldAccount.Contact_Email_Address__c) {
                    NewAccount.ModifiedEmail1__c = true;
                } else {
                    NewAccount.ModifiedEmail1__c = false;
                }
               
                if(NewAccount.Contact_Email2_Address__c != oldAccount.Contact_Email2_Address__c) {
                    NewAccount.ModifiedEmail2__c = true;
                } else {
                    NewAccount.ModifiedEmail2__c = false;
                } 
               
                if(NewAccount.Contact_Email3_Address__c != oldAccount.Contact_Email3_Address__c) {
                    NewAccount.ModifiedEmail3__c = true;
                } else {
                    NewAccount.ModifiedEmail3__c = false;
                }
               
                //Compare Old Contact LastName with New Contact LastName
                if(NewAccount.LastName != oldAccount.LastName) {
                    NewAccount.ModifiedLastName__c = true;
                } else {
                    NewAccount.ModifiedLastName__c = false;
                }
               
            }
        }
       
    }
   
}
 
I am trying to display images on Vf page which i am able to but I want to display images horizantally on my VF page.

below is my VF page code which now displays images vertically.
 
<apex:page standardController="Account" extensions="AccountController" showHeader="false" sidebar="false" standardStylesheets="false">
    <table class="detailList" border="0" cellpadding="0" cellspacing="5">
        <apex:repeat value="{!Images}" var="I">
            <tr>
                <td><image src="{!I.url}" alt="{!I.name}"/></td>
            </tr>
        </apex:repeat>
    </table>
</apex:page>

 
HI Friends,

im trying to get the records for nested query in developer, i couldn ot able to do it can some one suggest me where im wrong 

SELECT ENQ_Project_Name__c,ENQ_AFE__c,ENQ_Inspection_Level__c,
                         ENQ_Status__c,ENQ_Surveillance_Discipline__c,ENQ_Other__c,
                         (SELECT ENQ_QSC__c,ENQ_QSC_Contact__c FROM ENQ_Surveillance_Reports__c)
                          FROM ENQ_Assignment_Package__c 

Error message : 
ENQ_QSC__c,ENQ_QSC_Contact__c FROM ENQ_Surveillance_Reports__c)
                                   ^
ERROR at Row:3:Column:69
Didn't understand relationship 'ENQ_Surveillance_Reports__c' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.

Thanks
Vijaykumar 
Hi All,

A batch apex is called from trigger.If I import records through dataloader do the trigger calls the apex 100 times.How do we handle this situation.I heard that while importing data through dataloader trigger should be deactivated.Is it the accurate solution.
Thanks
This is the controller class:

public class MYAPEX_Acc
{
    public static void createcon(List<Account> lstaccforcon)
    {
        List<Contact> lstcon = new List<Contact>();
        for(Account acc : lstaccforcon)
        {
        Contact newcon = new Contact();
        newcon.AccountId = acc.Id;
        newcon.FirstName = acc.Name;
        newcon.Description = acc.Description;
        newcon.Phone = acc.Phone;
        newcon.Email = acc.Email__c;
        lstcon.add(newcon);        
        }
        try{
        INSERT lstcon;
        }
        catch(exception e)
        {
        }
    }
}


This is the trigger :

trigger AishuAccount on Account (before insert,before update,after insert,after update) 
{
    List<Account> lstacc = new List<Account>();
    List<Account> lstaccforcon = new List<Account>();
    List<Contact> lstcon = new List<Contact>();

    If(Trigger.isAfter)
        {
        If(Trigger.isInsert)
        {
      
        for(Account acc : Trigger.new)
        {
        If(acc.Phone != NULL && acc.Name != NULL)
        lstaccforcon.add(acc);
        }
        }
       
        If(lstaccforcon.size() > 0)
        {
        MYAPEX_Acc.createcon(lstaccforcon);
        }
    }
    
}


I'm unable to create a contact with this code. please help
Hello can someone help me on below trigger.
I have a scenario that If account is updating for phone number then all associated contacts phone number should update with same number. 
I wrote the trigger as below.It doesnt throw any errors but the phone number doesnt gets updated.

trigger phupdate on account (after update) 
{
List<contact> ctlist =new list<contact>();
List<Id> ids = new List<Id>();
for(account ac: trigger.new)
{
ids.add(ac.Id);
}
Map<Id, contact> contactMap = new Map<Id, contact>([Select Id, Phone From contact Where Id In :ids]);
for(account ac: trigger.new)
{
contact c = contactMap.get(ac.Id);
if(c != null)
{
ac.Phone= c.Phone;
ctlist.add(c);
}
}
update ctlist;
}
 
  • October 02, 2016
  • Like
  • 0
Hi All

i need SOQL to find opportunities that where created 21 days ago.
example: today date 09/30/216. i need all opportunities create on 09/09/2016.
the problem i am having is the createddate is a  datetime and i need all the records from that date no mater what time they where created.
Hi,
I have a custom picklist field - Country on both Contact & Account objects. Whenever a related contact is created from account, I want to prepopulate the value of Country from the Account on the contact object. As I am new to development, I would appreciate an elaborated guidance. Thanks in advance !
Hi,
Need Help!!
trigger Update_modified_date on Task (after insert,after update) {      
     list<task> t=[SELECT LastModifiedDate FROM Task];
    list<lead> l=[select TaskLastModifiedDate__c from lead where Isconverted = false];
        for(task t1:t){
            //system.debug('this is ----------------------------------');
            for(lead l1:l){
                system.debug('this is ----------------------------------');
            l1.TaskLastModifiedDate__c=t1.LastModifiedDate;
            l.add(l1.TaskLastModifiedDate__c);  
                
            }
        }
    update l;
    }


Iam trying to copy last modified date of task in lead.But iam getting the following error.Please help.

Error: Incompatible element type Datetime for collection of Lead
I have written a apex class with test class both are running but my code coverage is only 66%.Please help to solve the problem.

Apex class-
global class Deleteoppotest implements Schedulable{

global void execute(SchedulableContext SC) {
    deleteoppo();
}

public static void deleteoppo() {

    for(List<opportunity> objoppo : [SELECT Id FROM opportunity WHERE CreatedDate <= :(Date.Today() - 200) LIMIT 10])
        {
            delete objoppo;
        }    
}

Test Class-
@isTest
private class Deleteoppotestcls {

static testMethod void myUnitTest() {
    // TO DO: implement unit test



    Opportunity op = new Opportunity();
    op.Name = 'test1';
    op.StageName = 'Qualified';
    op.CloseDate = Date.Today();
    op.Description ='testingoppotestcls';
    op.Business_Type__c = 'Domestic';


    insert op;


    Deleteoppotest.deleteoppo();

}
}