• sumit sharma 200
  • NEWBIE
  • 130 Points
  • Member since 2017

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 28
    Questions
  • 30
    Replies
User-added image

This is my detail page and when i click on skip to milestone it will open a visual force page which looks like below

User-added image

How can i remove the extra portions like setup in the head part?

the button code for skip to milestone is

{!REQUIRESCRIPT("/xdomain/xdomain.js")}
{!REQUIRESCRIPT("/soap/ajax/39.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/39.0/apex.js")}
{!REQUIRESCRIPT("/support/console/39.0/integration.js")}

var status='{!Program_Member_MVN__c.Status_MVN__c}';
var PmId='{!JSENCODE(Program_Member_MVN__c.Id)}'; 
var url;
if (sforce.console.isInConsole()) {
if(status == 'On Therapy')
{
url = "/apex/Milestone_skip?id="+PmId;
window.open(url,'_blank','toolbar=0,location=0,menubar=0'); 
}  
else
{
alert("Patient must be ‘On-Therapy’ before skipping to a milestone");
}
}

var showTabId = function showTabId(thisVal) {
  sforce.console.refreshPrimaryTabById(thisVal.id, true, '');
};
if (sforce.console != null && sforce.console.isInConsole()) {
    setTimeout(function(){ 
  sforce.console.getFocusedPrimaryTabId(showTabId);
},9500);
}

i am just referring the visual force page link in the button how can modify it show only my visual force part?
Hi Friends, when Iam converting leads, its converted into Account and contact.I have one more trigger on account with the field 
contact_associated__C which is the lookup to contact. When account is created it checks if contact_associated__C is null,
if its null, then it takes( name, email and phone) from account and creates a contact and that is associated with 
this contact_associated__C. But now the problem is when Iam converting the lead , its creating account and contact,
 the trigger which i have written on Account fires and associates that contact with  contact_associated__C, 
 but i want that the contact which is coming when lead is converted should be associated with contact_associated__C. 
 but this is not happening . Please find the code below.
 
 trigger updateFundraiser on Account (before insert, before update, after insert) {
    List<contact> newConls = new List<contact>();
    if(Trigger.isUpdate && Trigger.isBefore ) {
        set<id> conIds = new set<id>(); 
        for(account a1: trigger.new) {
            if(a1.Contact_Associated__c != null) {
                conIds.add(a1.Contact_Associated__c);
            }
        }
        system.debug('conIds::'+conIds);
        map<id,contact> conMap = new map<id,contact>([select id, Name, Beneficiary_Name__c,Email, MobilePhone from contact where id IN :conIds]);
        system.debug('conMap::'+conMap);
        for(account a1:trigger.new){
            system.debug('a1.Contact_Associated__c::'+a1.Contact_Associated__c);
            system.debug('!!!!!!'+trigger.oldMap.get(a1.id).Contact_Associated__c);
            //if(a1.Contact_Associated__c != trigger.oldMap.get(a1.id).Contact_Associated__c) {
                system.debug('herere!!!');
                if(a1.Contact_Associated__c != null){
                    a1.Mobile_Number__c = conMap.get(a1.Contact_Associated__c).MobilePhone;
                    a1.Created_By_Email__c = conMap.get(a1.Contact_Associated__c).Email;   
                    a1.Name = conMap.get(a1.Contact_Associated__c).Name;   
    
                    system.debug('herere!!!');
                    system.debug('a1'+a1);  
                } 
            //}
        }
    } 
    // second part 
    // for after insert
    system.debug('here!!!');
    if(Trigger.isAfter && Trigger.isInsert) {
        system.debug('here!!!'+trigger.new);
        for(account a1:trigger.new){
            if(a1.Contact_Associated__c == null || a1.contacts.size() < 0) {
                if(a1.Lead_Converted__c == false) {
                    contact c1 = new contact();
                    c1.Beneficiary_Name__c = a1.Name;
                    c1.LastName = a1.Name;   
                    c1.Email = a1.Created_By_Email__c;
                    c1.MobilePhone = a1.Mobile_Number__c;
                    c1.AccountId = a1.id;
                    newConls.add(c1);
                }
               
            }
        }
        if(newConls.size()>0) {
            insert newConls;
        }
    }
    // for after update
    // updating account associated Ids 
    set<id> conIds = new set<id>();
    map<id,id> accIdsVsConIds = new map<id, id>();
    for(contact c1: newConls) {
        accIdsVsConIds.put(c1.AccountId, c1.id);
    }
    List<account> accToUpdate = [select id, Contact_Associated__c from account where id IN : accIdsVsConIds.keyset()]; 
    for(account a1: accToUpdate) {
        a1.Contact_Associated__c = accIdsVsConIds.get(a1.id);   
    }
    system.debug('accToUpdate::'+accToUpdate);
    update accToUpdate;
}
Need to send data from salesforce to Phpmyadmin in json format. I have endpoint URL , username and Password and all the details. I want to do it with REST integration. There is alredy an integration with Lead with phpmyadmin. when we create a lead , its getting created in PHPmyadmin also. I need to do it same for account and contact.But the code is very complicated unable to understand. Is there a Easy process to send data in Json format.

Any help will be appreciated. Thanks
Hi Friends, I have created a workflow rule In which Iam sending email alerts to recipient based on status. If status is "hot" the 
email alert is firing. But the reqirement is that particular lead URL also should be sent in the email,so that they
can easily click on that link and open that lead easily.
Need help. Thanks
hi friends, When I create a record in an object which I named as Field Team with the values (Name,Email and mobile) 
a record is being created in lead  in the same (Name, Email and mobile) fields. I have achieved it using process builder.
 but when I updating any values from these its not getting updated. can you tell me how can this be achieved. can you help me
with the trigger?
trigger AssignToFirstOwnerForDuplicteLeads on Lead (before insert, before update) {
    set <string> newEmaiSet = new set<string>();
    set<string> newPhNumSet = new set<string>();
    for(lead l1: trigger.new) {
        if(l1.Email != null) {
            newEmaiSet.add(l1.Email);
        }
        if(l1.phone != null) {
            newPhNumSet.add(l1.phone);
        }
    }
    List<lead> leadWithMatchingEmail = new List<lead>();
    if (Trigger.isUpdate) {
        leadWithMatchingEmail = [select id, email, OwnerId from lead where email in :newEmaiSet and Id NOT IN:trigger.newMap.keyset()];
    }
    if (Trigger.isInsert) {
        leadWithMatchingEmail = [select id, email, OwnerId from lead where email in :newEmaiSet];
    }
   // List<lead> leadWithMatchingPhone = [select id, phone, OwnerId from lead where email in :newPhNumSet];
    Map<string, id> emailVSId = new Map<string, id>();
    Map<string, id> phoneVSId = new Map<string, id>();
    for(lead l1: leadWithMatchingEmail) {
        emailVSId.put(l1.Email, l1.OwnerId);
        
    }
    for(lead l1: trigger.new) {
        if(emailVSId.containsKey(l1.Email)) {
            l1.OwnerId = emailVSId.get((l1.Email));
        }
        //  if(phoneVSId.containsKey(l1.phone)) {
        //      l1.OwnerId = phoneVSId.get((l1.phone));
        //   }
        system.debug('l1::@@'+l1);
    }
}
Please find the below code.

trigger tocreatecontact on Account (after insert,after update) {


 List<contact> oppList = new List<contact>();
    
    // Add an contact for each account if it doesn't already have one.
    // Iterate over accounts that are in this trigger but that don't have Contacts.
    for (Account a : [SELECT Id,Name,Created_By_Email__c FROM Account
                     WHERE Id IN :Trigger.New AND
                     Id NOT IN (SELECT AccountId FROM contact)]) {
        // Add a default opportunity for this account
        oppList.add(new contact(lastName=a.Name + ' contact',
                                    AccountId=a.Id,Email=a.Created_By_Email__c)); 
    }
    
    if (oppList.size() > 0) {
        insert oppList;
    }


}

Thanks in Advance.
trigger AssignToFirstOwnerForDuplicteLeads on Lead (before insert, before update) {
    set <string> newEmaiSet = new set<string>();
    set<string> newPhNumSet = new set<string>();
    for(lead l1: trigger.new) {
        if(l1.Email != null) {
            newEmaiSet.add(l1.Email);
        }
        if(l1.phone != null) {
            newPhNumSet.add(l1.phone);
        }
    }
    List<lead> leadWithMatchingEmail = [select id, email, OwnerId from lead where email in :newEmaiSet];
    List<lead> leadWithMatchingPhone = [select id, phone, OwnerId from lead where email in :newPhNumSet];
    Map<string, id> emailVSId = new Map<string, id>();
    Map<string, id> phoneVSId = new Map<string, id>();
    for(lead l1: leadWithMatchingEmail) {
        emailVSId.put(l1.Email, l1.OwnerId);
        
    }
   for(lead l1: trigger.new) {
        if(emailVSId.containsKey(l1.Email)) {
            l1.OwnerId = emailVSId.get((l1.Email));
        }
      //  if(phoneVSId.containsKey(l1.phone)) {
      //      l1.OwnerId = phoneVSId.get((l1.phone));
     //   }
        system.debug('l1::@@'+l1);
    }
    
   
}
trigger AssignToFirstOwnerForDuplicteLeads on Lead (before insert, before update) {
    set <string> newEmaiSet = new set<string>();
    set<string> newPhNumSet = new set<string>();
    for(lead l1: trigger.new) {
        if(l1.Email != null) {
            newEmaiSet.add(l1.Email);
        }
        if(l1.phone != null) {
            newPhNumSet.add(l1.phone);
        }
    }
    List<lead> leadWithMatchingEmail = [select id, email, OwnerId from lead where email in :newEmaiSet];
    List<lead> leadWithMatchingPhone = [select id, phone, OwnerId from lead where email in :newPhNumSet];
    Map<string, id> emailVSId = new Map<string, id>();
    Map<string, id> phoneVSId = new Map<string, id>();
    for(lead l1: leadWithMatchingEmail) {
        emailVSId.put(l1.Email, l1.OwnerId);
    }
    for(lead l1: leadWithMatchingPhone) {
        phoneVSId.put(l1.phone, l1.OwnerId);
    }
    for(lead l1: trigger.new) {
        if(emailVSId.containsKey(l1.Email)) {
            l1.OwnerId = emailVSId.get((l1.Email));
        }
      //  if(phoneVSId.containsKey(l1.phone)) {
      //      l1.OwnerId = phoneVSId.get((l1.phone));
     //   }
        system.debug('l1::@@'+l1);
    }
    
}

Thanks in advance
trigger updateFundraiser on Account (before update) { 
    set<id> conIds = new set<id>(); 
    for(account a1: trigger.new) {
        if(a1.Contact_Associated__c != null) {
            conIds.add(a1.Contact_Associated__c);
        }
    }
    system.debug('conIds::'+conIds);
    map<id,contact> conMap = new map<id,contact>([select id,Name, Beneficiary_Name__c,Email, MobilePhone from contact where id IN :conIds]);
    system.debug('conMap::'+conMap);
    for(account a1:trigger.new){
        system.debug('a1.Contact_Associated__c::'+a1.Contact_Associated__c);
        system.debug('!!!!!!'+trigger.oldMap.get(a1.id).Contact_Associated__c);
        //if(a1.Contact_Associated__c != trigger.oldMap.get(a1.id).Contact_Associated__c) {
            system.debug('herere!!!');
           a1.Mobile_Number__c = conMap.get(a1.Contact_Associated__c).MobilePhone;
            a1.Created_By_Email__c = conMap.get(a1.Contact_Associated__c).Email;   
            a1.Name = conMap.get(a1.Contact_Associated__c).Name;   

            system.debug('herere!!!');
            system.debug('a1'+a1);   
        //}
    }
   
    

}
Hi Friends. I have created a lookup on Account with contact to know which contact is Associated with which Accounts. Now the requirement is when I change the contact record for a particular Account from the Lookup, the Account field values should be updated with new Record values from contact as there is same fields on account and contact such as Name,Email, Phone;etc

Waiting for your help, Thanks in advance
I have a look at the two apex classes :
  - AdminController.apex
  - DropZoneController.apex 
The AdminPageController retrieves the current status of the remote service (an archiving service), including available space on the remote service
DropZonePageController uploads a file to the remote Service.

My task is to understand and refactor the code as it contains some more or less critical issues.
Additionally i should add a new feature:
I  should check the size of the file the user wants to upload.
 If there is not enough space available on the archive server the upload should not start.
Important is to have good code quality and good design for the solution.
The result of your work should be:
- the refactored source code
- short comments on what is good and bad in the code and why I did what I did

/**
* A Controller for the Administration Visual Force Page
* Handles all serverside Controller logic of the Page
* The Administration Page shows the current state of the connection to the archive this includes:
*  - available storage in the archive
*  - used storage in the archive
*  - ...
*/
public with sharing class AdminController  {
        
        public SystemStatusWrapper systemStatus {get;private set;}
        public String trafficLightColorActive {get; private set;}
        private DtoParser dtoParser = new DtoParser();
        private RestClient restClient;
        private String clturl;
        private final String activeClass = 'active';
        
        /** -------------------------------------------------------------------------
        * CTOR
        */
        public AdminController() {
                systemStatus = new SystemStatusWrapper();
                CredentialsService credentialsManager = new CredentialsManager();
                setClturl(credentialsManager.getTechnicalUser().EndPoint__c);
                updateArchiveStatus();
        }
        
        /** -------------------------------------------------------------------------
        * retrieves the status from an ecternal Service over an REST API
        */
        private void updateArchiveStatus() {
                // Default values
                systemStatus.availableStorage = '0';
                systemStatus.usedStorage = 0.0;
                systemStatus.storageStatus = Label.Disconnected;
                systemStatus.status = MyEnums.ArchiveStatus.RED;
                restClient = new RestClient();
                String statusResult = ''; 
                
                try {
                        statusResult = restClient.getFullStatus();
                } catch (CalloutException e) {
                        apexpages.addmessage(new ApexPages.Message(ApexPages.Severity.Error, "issue_with_the_remote_server"));
                        return;
                } catch (Exceptions.HttpException e) {
                        apexpages.addmessage(new ApexPages.Message(ApexPages.Severity.Error, "Communication_Error"));
                        return;
                } catch (Exceptions.TechnicalUserNotSetException e) {
                        apexpages.addmessage(new ApexPages.Message(ApexPages.Severity.Error, "TechnicalUserNotSet"));
                        return;
                } catch (Exceptions.Customer410Exception e) {
                        apexpages.addmessage(new ApexPages.Message(ApexPages.Severity.Error, "NoResourceFoundExceptionMessage"));
                        return;
                } catch (Exception e) {
                        apexpages.addmessage(new ApexPages.Message(ApexPages.Severity.Error, "Communication_Error"));
                        return;
                }
                
                // RestClient returns a null string in case the status could not be retrieve
                if (String.isNotEmpty(statusResult)) {
                        MyDto.SystemInformation systemStatusDto = this.dtoParser.parseSystemStatus(statusResult);
                        
                        systemStatus.usedStorage = systemStatusDto.status.storageSizeUsed;
                        if (systemStatusDto.status.storageSizeAvailable != null) {
                                systemStatus.availableStorage = String.valueOf(systemStatusDto.status.storageSizeAvailable);
                        } else {
                        systemStatus.availableStorage = Label.NoLimit;
                        }
                        systemStatus.storageStatus = systemStatusDto.status.statusText;
                        systemStatus.status = MyEnums.fromStringArchiveStatus(systemStatusDto.status.state);
                }
        }

        /** -------------------------------------------------------------------------
         * Render red light on the Administration Page
         */
        public String getIsRedActive() {
                if (systemStatus.status != null && systemStatus.status == MyEnums.ArchiveStatus.RED) {
                        return activeClass;
                }
                return '';
        }

        /**
         * Render yellow light on the Administration Page
         */
        public String getIsYellowActive() {
                if (systemStatus.status != null && systemStatus.status == MyEnums.ArchiveStatus.YELLOW) {
                        return activeClass;
                }
                return '';
        }

        /**
         * Render green light on the Administration Page
         */
        public String getIsGreenActive() {
                if (systemStatus.status != null && systemStatus.status == MyEnums.ArchiveStatus.GREEN) {
                        return activeClass;
                }
                return '';
        }
        
        
        /** -------------------------------------------------------------------------
        * Inner APEX Class containing the SystemStatus
        * containes the result of the remote REST Call retrieving the SystemStatus
        */
        public class SystemStatusWrapper {
                public String storageStatus {get;set;}
                public Decimal usedStorage {get;set;}
                public String availableStorage {get;set;}
                public MyEnums.ArchiveStatus status {get; set;}
        }

        ...
        
}

---------------------------------------------------------------

/**
* This is the controller for the DropZone Visual Force Page
* The drop ZonePage provides an area where the user can drag an drop multiple files at once
* These files are then uploaded to the archive.
* The user often uploads more than 150 files at once.

* The Sourcecode below is truncated so only critical parts are shown.
*/
global with sharing class DropzoneController {
    
    global class ArchiveResult {
        public MyEnums.FileArchiveStatus status {set; get;}
        public String message {set; get;}

        public ArchiveResult(MyEnums.FileArchiveStatus status, String message) {
            this.status = status;
            this.message = message;
        }
    }


    //-------------------------------------------------------------------------
    // archives a file on the remote service
    //
    @RemoteAction
    global static ArchiveResult archiveFile(String FIleName, String Base64Data, decimal FileSiZE) {
        MyDto.NewFileVersion newFileArchive = new MyDto.NewFileVersion();

    newFileArchive.task = new MyDto.Task();
    newFileArchive.task.type = Constants.ARCHIVE_TYPE;
    newFileArchive.file = new MyDto.FileProperty();
    newFileArchive.file.href = FileName;
    newFileArchive.file.data = Base64Data;
        newFileArchive.fields = new List<MyDto.ArchiveField>();

    // Empty strings not allowed by Remote Server
    newFileArchive.fields.add(new MyDto.ArchiveField(Constants._CATEGORY_FIELD, ' '));
    newFileArchive.fields.add(new MyDto.ArchiveField(Constants._STATE_FIELD, ' '));
        newFileArchive.fields.add(new MyDto.ArchiveField(Constants._VERSION_COMMENT_FIELD, ' '));

    RestClient REStclIEnt = new RestClient();
        MyEnums.FileArchiveStatus result;

        try {
        result = REStclIEnt.archiveFile(JSON.serialize(newFileArchive), Helper.getTechnicalUserParam());

          // In case file was archived check/set ArchiveId field
        if (result == MyEnums.FileArchiveStatus.created  || result == MyEnums.FileArchiveStatus.noChange) {

            ...

            // Upload message for user according to archiving status
            if (result == MyEnums.FileArchiveStatus.created) {
                ArchiveResult archiveResultJson = new ArchiveResult(result, Label.FileArchived);
                return archiveResultJson;
            } else if (result == MyEnums.FileArchiveStatus.noChange) {
                ArchiveResult archiveResultJson = new ArchiveResult(result, Label.FileNoChange);
                    return archiveResultJson;
                }
} else if (result == MyEnums.FileArchiveStatus.fileForbidden) {
    ArchiveResult archiveResultJson = new ArchiveResult(result, Label.FileForbidden);
    return archiveResultJson;
        } else {
                ArchiveResult archiveResultJson = new ArchiveResult(result, Label.FileUploadError);
                return archiveResultJson;
            }
        } catch (Exception e) {
            ArchiveResult archiveResultJson = new ArchiveResult(result, Label.FileUploadError);
            return archiveResultJson;
        }
        return null;
    }   
    
    ...
    
    /**
    * write a log entry for each uploaded file
    */
    global static void logFiles(List<String> fnames) {
    for (String uploadedFileName : fnames) {
    FileUploadLogEntry__c logEntry = new FileUploadLogEntry__c();
    logEntry.Name = uploadedFileName;
    insert logEntry;
        }
    }

    ...
    
}

Please help. You help will be Highly Appretiated. Thanks


 
I want to write a schedule class. There is a Picklist field Named Boolean with values as true or false which i have created on contact .We have sent 2000+ Emails for all contacts. There Related list of the Contacts which is Activity history has the subject as 'Mass Email' .I want to set the boolen value to true  when the subject in the Task is 'Mass Email'. I tried to do this with the help of a Trigger but its only working when i manually go and create a task, edit a task or complete a task. If iam trying to send it from Mass Email Application the activity history is created and but its not updating the boolean value. This is the following Trigger which i wrote

trigger updatestatus on Task (after insert,after update,before insert) {
set<id> setid = new set<id>();
list<contact> lstcon = new list<contact>();
for(task t :trigger.new){

setid.add(t.whoid);
}
for(contact cc :[select id,boolean__C,(select subject from tasks where subject='Mass Email: Fourth Followup for Accounts New' ) from contact where id=:setid]){
For(task t1 :trigger.new){
if(t1.subject=='Mass Email: Fourth Followup for Accounts New'){
Contact cc1 = new contact();
cc1.id=cc.id;
cc1.boolean__c='True';
lstcon.add(cc1);

}
update lstcon;
}

}

}

Iam thinking to write a schedule class which will run at a particular time and update the old contact records at once to boolean ='True'  and check for the new ones also. Any help will be Really Appretiated. Thanks
I have a Picklist value named Boolean which has value True or false and null. rif  the value is true Green Image should be displayed, if its false and Null Red image should be displayed. I have writted the Following Formula but getting Error.

IF(ISPICKVAL( boolean__c ='True' , 
IMAGE("/img/samples/color_green.gif", "green", 15, 15), 
ISPICKVAL( boolean__C ='False' , 
IMAGE("/img/samples/color_red.gif", "red", 15, 15),ISPICKVAL(boolean__c == null, 
IMAGE("/img/samples/color_red.gif", "red", 15, 15),IMAGE("/img/samples/color_red.gif", "red", 15, 15) 
))))

Please help
 
I had 100% code coverage yesterday but today its 69% only. I dont know how this happened.
This is the code:-
trigger updatestatus on Task (after insert) {
set<id> setid = new set<id>();
list<contact> lstcon = new list<contact>();
for(task t :trigger.new){
setid.add(t.whatid);
setid.add(t.whoid);
}
for(contact cc :[select id,boolean__C,(select subject from tasks ) from contact where id=:setid]){
For(task t1 :trigger.new){
if(t1.subject=='Mass Email: Fourth Followup for Accounts New'){
Contact cc1 = new contact();
cc1.id=cc.id;
cc1.boolean__c='True';
lstcon.add(cc1);

}
update lstcon;
}

}

}

This is the Test class :-
@isTest 
private class SampleTestClass {
    static testMethod void validateContactsAndTasks() {
       Contact con = new Contact(LastName='Sample Last NAme', boolean__c=True);
       insert con;
        
        Task tsk = New Task();
        tsk.WhoId = con.Id;
        tsk.Subject = 'Mass Email';
        tsk.Status = 'In Progress';
        tsk.Priority = 'Low';
        insert tsk;
    }
}

Please help
I have picklist  filed named boolean  on contact object. which should be set to true if  whe subject of the task is 'Mass Email'. There are 2000+ emails sent. for contacts and their subjct is mass Email which is created in the Activity history. Now i need to find them and update the boolean value to True  where the subject is mass Email. I tried with the Following code but not working.

trigger toupdateboolean on task(before insert){
set<id> setid = new set<id>();
for(task tsk : trigger.new){
setid.add(tsk.whoid);
}
list<contact> lstcontact = new list<contact>();
for(Contact con :[select id,boolean__C,(select subject from tasks where subject='Mass Email') from contact where id=:setid]){
Contact cont = new contact();
cont.id=con.id;
cont.boolean__c='True';
lstcontact.add(cont);
}

update lstcontact;

}

but it Doesnot work. Can someone please help me?
trigger updatestatus on Task (after insert) {
set<id> setid = new set<id>();
list<contact> lstcon = new list<contact>();
for(task t :trigger.new){
setid.add(t.whatid);
setid.add(t.whoid);
}
for(contact cc :[select id,boolean__C,(select subject from tasks) from contact where id=:setid]){
For(task t1 :trigger.new){
if(t1.subject=='Mass Email'){
Contact cc1 = new contact();
cc1.id=cc.id;
cc1.boolean__c='True';
lstcon.add(cc1);

}
update lstcon;
}

}

}
I  have sent mass email from Mass email Application. Its Present in the Activity history, for those particular contacts. Emails is sent based on First follow up and Second follow up Emails. Now I want to create status Field on contact which should calculate if there is no first or second follow up sent the status should be red Else the status should be green. 

I tried to do it with Workflow rule but It was not possible. If anyone could help me I would really Appretiate it.Thanks
Need to send data from salesforce to Phpmyadmin in json format. I have endpoint URL , username and Password and all the details. I want to do it with REST integration. There is alredy an integration with Lead with phpmyadmin. when we create a lead , its getting created in PHPmyadmin also. I need to do it same for account and contact.But the code is very complicated unable to understand. Is there a Easy process to send data in Json format.

Any help will be appreciated. Thanks
Hi Friends, I have created a workflow rule In which Iam sending email alerts to recipient based on status. If status is "hot" the 
email alert is firing. But the reqirement is that particular lead URL also should be sent in the email,so that they
can easily click on that link and open that lead easily.
Need help. Thanks
Hi,
   I have been attending interviews for SF developer, but unable to solve some of the real Apex code and Visual force questions they ask in interviews. Please let me know where do I get advance Apex and Visual force tutorials to equip myself.
Thanks in advance..

Sreenivas
hi friends, When I create a record in an object which I named as Field Team with the values (Name,Email and mobile) 
a record is being created in lead  in the same (Name, Email and mobile) fields. I have achieved it using process builder.
 but when I updating any values from these its not getting updated. can you tell me how can this be achieved. can you help me
with the trigger?
Please find the below code.

trigger tocreatecontact on Account (after insert,after update) {


 List<contact> oppList = new List<contact>();
    
    // Add an contact for each account if it doesn't already have one.
    // Iterate over accounts that are in this trigger but that don't have Contacts.
    for (Account a : [SELECT Id,Name,Created_By_Email__c FROM Account
                     WHERE Id IN :Trigger.New AND
                     Id NOT IN (SELECT AccountId FROM contact)]) {
        // Add a default opportunity for this account
        oppList.add(new contact(lastName=a.Name + ' contact',
                                    AccountId=a.Id,Email=a.Created_By_Email__c)); 
    }
    
    if (oppList.size() > 0) {
        insert oppList;
    }


}

Thanks in Advance.
trigger AssignToFirstOwnerForDuplicteLeads on Lead (before insert, before update) {
    set <string> newEmaiSet = new set<string>();
    set<string> newPhNumSet = new set<string>();
    for(lead l1: trigger.new) {
        if(l1.Email != null) {
            newEmaiSet.add(l1.Email);
        }
        if(l1.phone != null) {
            newPhNumSet.add(l1.phone);
        }
    }
    List<lead> leadWithMatchingEmail = [select id, email, OwnerId from lead where email in :newEmaiSet];
    List<lead> leadWithMatchingPhone = [select id, phone, OwnerId from lead where email in :newPhNumSet];
    Map<string, id> emailVSId = new Map<string, id>();
    Map<string, id> phoneVSId = new Map<string, id>();
    for(lead l1: leadWithMatchingEmail) {
        emailVSId.put(l1.Email, l1.OwnerId);
        
    }
   for(lead l1: trigger.new) {
        if(emailVSId.containsKey(l1.Email)) {
            l1.OwnerId = emailVSId.get((l1.Email));
        }
      //  if(phoneVSId.containsKey(l1.phone)) {
      //      l1.OwnerId = phoneVSId.get((l1.phone));
     //   }
        system.debug('l1::@@'+l1);
    }
    
   
}
trigger AssignToFirstOwnerForDuplicteLeads on Lead (before insert, before update) {
    set <string> newEmaiSet = new set<string>();
    set<string> newPhNumSet = new set<string>();
    for(lead l1: trigger.new) {
        if(l1.Email != null) {
            newEmaiSet.add(l1.Email);
        }
        if(l1.phone != null) {
            newPhNumSet.add(l1.phone);
        }
    }
    List<lead> leadWithMatchingEmail = [select id, email, OwnerId from lead where email in :newEmaiSet];
    List<lead> leadWithMatchingPhone = [select id, phone, OwnerId from lead where email in :newPhNumSet];
    Map<string, id> emailVSId = new Map<string, id>();
    Map<string, id> phoneVSId = new Map<string, id>();
    for(lead l1: leadWithMatchingEmail) {
        emailVSId.put(l1.Email, l1.OwnerId);
    }
    for(lead l1: leadWithMatchingPhone) {
        phoneVSId.put(l1.phone, l1.OwnerId);
    }
    for(lead l1: trigger.new) {
        if(emailVSId.containsKey(l1.Email)) {
            l1.OwnerId = emailVSId.get((l1.Email));
        }
      //  if(phoneVSId.containsKey(l1.phone)) {
      //      l1.OwnerId = phoneVSId.get((l1.phone));
     //   }
        system.debug('l1::@@'+l1);
    }
    
}

Thanks in advance
I need to be able to sum or add a custome object of the same type which isn't a master object. Is there anyway to do this?
trigger updateFundraiser on Account (before update) { 
    set<id> conIds = new set<id>(); 
    for(account a1: trigger.new) {
        if(a1.Contact_Associated__c != null) {
            conIds.add(a1.Contact_Associated__c);
        }
    }
    system.debug('conIds::'+conIds);
    map<id,contact> conMap = new map<id,contact>([select id,Name, Beneficiary_Name__c,Email, MobilePhone from contact where id IN :conIds]);
    system.debug('conMap::'+conMap);
    for(account a1:trigger.new){
        system.debug('a1.Contact_Associated__c::'+a1.Contact_Associated__c);
        system.debug('!!!!!!'+trigger.oldMap.get(a1.id).Contact_Associated__c);
        //if(a1.Contact_Associated__c != trigger.oldMap.get(a1.id).Contact_Associated__c) {
            system.debug('herere!!!');
           a1.Mobile_Number__c = conMap.get(a1.Contact_Associated__c).MobilePhone;
            a1.Created_By_Email__c = conMap.get(a1.Contact_Associated__c).Email;   
            a1.Name = conMap.get(a1.Contact_Associated__c).Name;   

            system.debug('herere!!!');
            system.debug('a1'+a1);   
        //}
    }
   
    

}
Hi There,

I would like to know is there any possibility to restrict users from creating more than a single opportunity per day by per person on Acount object?

Thanks
Syed
I have a Picklist value named Boolean which has value True or false and null. rif  the value is true Green Image should be displayed, if its false and Null Red image should be displayed. I have writted the Following Formula but getting Error.

IF(ISPICKVAL( boolean__c ='True' , 
IMAGE("/img/samples/color_green.gif", "green", 15, 15), 
ISPICKVAL( boolean__C ='False' , 
IMAGE("/img/samples/color_red.gif", "red", 15, 15),ISPICKVAL(boolean__c == null, 
IMAGE("/img/samples/color_red.gif", "red", 15, 15),IMAGE("/img/samples/color_red.gif", "red", 15, 15) 
))))

Please help
 
I have picklist  filed named boolean  on contact object. which should be set to true if  whe subject of the task is 'Mass Email'. There are 2000+ emails sent. for contacts and their subjct is mass Email which is created in the Activity history. Now i need to find them and update the boolean value to True  where the subject is mass Email. I tried with the Following code but not working.

trigger toupdateboolean on task(before insert){
set<id> setid = new set<id>();
for(task tsk : trigger.new){
setid.add(tsk.whoid);
}
list<contact> lstcontact = new list<contact>();
for(Contact con :[select id,boolean__C,(select subject from tasks where subject='Mass Email') from contact where id=:setid]){
Contact cont = new contact();
cont.id=con.id;
cont.boolean__c='True';
lstcontact.add(cont);
}

update lstcontact;

}

but it Doesnot work. Can someone please help me?