• Abdul Khatri
  • PRO
  • 3213 Points
  • Member since 2015

  • Chatter
    Feed
  • 104
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 975
    Replies

Hi Guys,

I am triggering a POST request via process builder and it works but can you please tell me how can I capture the HTTP response I get back? The external system will send me a string I would like to store on the record which started the process. 
 

@future(callout=true)

        public static void calloutmethod(String name){
                Http http = new Http();
                HttpRequest request = new HttpRequest();
                request.setEndpoint('XXX');
                request.setMethod('POST');
                request.setHeader('Content-Type', 'application/json;charset=UTF-8');
                request.setHeader('accept', 'application/json');
                request.setBody(name);
                
                response = http.send(request);
        }

Thanks a lot.

Krisz
Hi,

I am having a massive confusion,

We have a database of 400,000 records.. which calls for duplication.

I want to check if alternate phone number of any of the account matches with the Primary phone number of any of the account, If it does, there is a checkbox  called "Marked For deletion"  m that checkbox should get selected and primary phone number of that account should become the alternate phone number of the acount against which it has matched 

So lets say ,

Accoount : A  Primary No : 1234  Secondary No : 5678

Accoount : B  Primary No : 9241  Secondary No : 1234 

Accoount : C  Primary No : 9241  Secondary No :  1234

Account B and Account C should have marked for deletion checked.
and Account B's primary phone number should become Secondary phone number of Account A. 

Please help me in achieving this 
 
I need to update the Account Name (Account_Name__c) custom field in the Task tab, with the Account Name (AccountId). My current code is:

trigger Account_Name on Task (before insert, before update) {
    for(Task a : trigger.new) {        
        task.Account_Name__c = a.AccountId;
    }
}


I keep receiving an error that says: A value cannot be stored to Account_Name__c in type task. What am I doing wrong?
I have been asked to make a custom weighting option for one of the smaller businesses in our org. 

If the sales manager picks one of the following picklist options during his opportunity creation, the formula should calculate as appropriate:

Custom Opp Weighting Picklist
Existing client, existing product =  divide opportunity amount by 2
Existing client, new product = divide opportunity amount by 3
New client, existing product = divide opportunity amount by 5
New client, new product = divide opportunity amount by 10

Is there an esy way I can I achive this via a picklist? 

Would really appreciate any help!
 
We need to simulate running monthly scheduled batch apex jobs over multilple months/year to see mutiple records instances being recaluculed over time.

I can see that there are some comments from 2011 saying that this is not possible but just wanted to check in 2019? I am guessing not but just thought to ask.
Hello.
I can get user and public groups from public groups this SOQL,
but public groups add role, can not get add role.
How to get role from public groups?
[SELECT Id, DeveloperName, (SELECT UserOrGroupId FROM GroupMembers)
FROM Group WHERE DeveloperName IN :xxxxxx]
Have a picklist with 10 values, when it is picklist option 2 or 3, i want to check to see if a number field is not null.

NOT ( OR ( ISPICKVAL ( FieldName__c , "Option 2" ), ( ISPICKVAL ( FieldName__c , "Option 3" ) ) ) && NOT ( ISNULL ( NumberField__c ) = true ) )

It validates, but no matter what option 2 or 3 I pick, i can also put numbers in the number field and nothing seems to be stopping me from doing anything....
Hello Team,

While doing the trailhead for Quick Start - Apex Coding for Admins - Create a Trigger, while I am creating the candidate Nina Simone, and update the ZIP Code field as "20008", system gives me an error message stating as - Candidate Zip Code does not exist in specified State.

Kindly advise where I am going incorrect.

Thanks
Vinay Kumar Salve
Hi,

When a Campaign Member is removed from a campaign, it updates the IsDeleted flag, but does anyone know if this also updates the Last Modified date on the Campaign Member?

Thanks,

Kam
I am having trouble with a valdiation formula that checks two sets of criteria.
Criteria 1 - Field A = Yes AND Field B's number field is greater than 0.
Criteria 2 - Field A = Yes AND Field B's number field is greater than 0 AND Field C = Yes AND Field D not equal to BLANK

The first and second criteria reference the same elements but should be independent of each other. My formula "seems" to workfor Criteria 2 but not 1.

AND( NOT(ISPICKVAL(Furniture_Delivered_Model_Setup__c, 'No')), Attachment_Added__c>0, OR( AND( NOT(ISPICKVAL(Virtual_Tour__c, 'No')), NOT(ISBLANK(Model_Promo_Virtual_Tour__c)), NOT(ISPICKVAL(Furniture_Delivered_Model_Setup__c, 'No')), Attachment_Added__c>0) ))

Any help is greatly appreciated
  • February 20, 2019
  • Like
  • 0
Hello - How can I return a lead list called 'returnedLead' from a class to a trigger. Any assistance would be greatly appreciated. 

Trigger:
if(Trigger.isUpdate){
                   //Passing Trigger.new and Trigger.old to LeadOwnerAssignment class
                    LeadOwnerAssignment.leadChanges(Trigger.new, Trigger.old);
}

Class: 
public class LeadOwnerAssignment {
    
    public static void leadChanges(List<Lead> newLead, List<Lead> oldLead){
        
        List<Lead> returnedLead = new List<Lead>();
        
        //Old Lead Map
        Map<String, String> mapOfOldAffinityType = new Map<String, String>();
        
        for(lead oldLds : oldLead) {
            mapOfOldAffinityType.put(oldLds.Affinity_Type__c, oldLds.LastNameStreetAndZipCode__c);
        }

        for(Lead ld : newLead) {
            if(ld.Affinity_Type__c != mapOfOldAffinityType.get(ld.Affinity_Type__c)){
                returnedLead.add(ld);     
            }
        }  
    }            
}

I have turned on "Associate a Contact with Multiple Accounts".  I use a visualforce page to display my accounts and I'm trying to figure out the name of the related list to use.  

I used AccountContactRoles but I'm not getting the right page layout or buttons as expected.  thanks!!! 
 

Fred

  • February 20, 2019
  • Like
  • 0
Apex Class
/*
Having the Utilities of the Askiiris Integration
*/
public without Sharing class Integration_Util {
    Public Static FINAL String DML_ERROR='Error Occured While Saving Record To database';
    /*
Method to log the integration trace in notes
*/
    Public Static void InsertNote(id parentId,string body,string title,boolean isPrivate,boolean ExceptionOccured){
        note resp = new note();
        resp.parentId = parentId; 
        resp.body =body; 
        resp.title = title; 
        resp.isPrivate = isPrivate; 
        database.insert(resp,false); 
    }
     /*
Method to send the Exception Email to CMSO-PS
*/
    public static void sendExceptionEmail(String[] emailId,String subject,String emailBody){
        Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
        semail.setToAddresses(emailId); 
        semail.setSubject(subject); 
        semail.setHtmlBody(emailBody); 
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] {semail}); 
    } 
    /*
Method to get the Integration Credentials
*/
    Public Static CredentialsWrapper getCredetials( String credentialDevName){
        Integration_Credentials_Mapping__mdt mdt=[select id,Production_End_point_URI__c,Sanbox_End_point_URI__c,
                                                  Sandbox_password__c,Sandbox_user_name__c,Production_password__c,
                                                  Production_user_name__c,security_hns__c,Suffix_URL_1__c,Suffix_URL_2__c,
                                                  Sandbox_Auth_URI__c,Production_Auth_URI__c
                                                  From Integration_Credentials_Mapping__mdt 
                                                  where DeveloperName=:credentialDevName LIMIT 100];
        
        boolean isSandbox=[SELECT issandbox from organization LIMIT 1].isSandbox;
        CredentialsWrapper credwrap=new CredentialsWrapper();
        if(isSandbox){
            credwrap.enpointUrl=mdt.Sanbox_End_point_URI__c;
            credwrap.username =mdt.Sandbox_user_name__c;
            credwrap.password =mdt.Sandbox_password__c;
            credwrap.authTokenUrl =mdt.Sandbox_Auth_URI__c; 
        }else{
            credwrap.enpointUrl=mdt.Production_End_point_URI__c;
            credwrap.username=mdt.Production_user_name__c;
            credwrap.password=mdt.Production_password__c;
            credwrap.authTokenUrl =mdt.Production_Auth_URI__c; 
        }
        credwrap.hnsUrl=mdt.security_hns__c;
        credwrap.isSandbox=isSandbox;
        credwrap.suffixUrl1=mdt.Suffix_URL_1__c;
        credwrap.suffixUrl2=mdt.Suffix_URL_2__c;
        
        return credwrap;
    } 
    /*
Wrapper class used wrap the Integration Credentials
*/
    Public without sharing class CredentialsWrapper{
        Public String username;
        Public String password;
        Public String enpointUrl;
        Public String hnsUrl;
        public Boolean isSandbox;
        Public String suffixUrl1;
        public String suffixUrl2;
        Public String authTokenUrl;
        
    }
    
}

My Test Class

@isTest
public class Integration_Util_UT {

    private static testmethod void InsertNote() {
    Integration_Util.InsertNote('00300000003T2PGAA0','hello','hello',True,True);
     }                    
                    
    private static testmethod void sendExceptionEmail() {
        Integration_Util.sendExceptionEmail('fdgd@df.com','hello','hello');
       }                
                    
    private static testmethod void getCredetials() {
        Integration_Util.getCredetials('hello');
        }                    
}                

My error : "Method does not exist or incorrect signature: void sendExceptionEmail(String, String, String) from the type Integration_Util"
Also the current code coverage is 31%, please hep me to get code coverage 
Thanks in advance
I seem to be stuck on this trailhead module or write negative tests unit, while I have 93 percent code coverage, I can't seem to get the code coverage to hit 100 percent at the "returnValue" piece doesn't seem to hit.
My code is as follows.

Calculator Class
 
public class Calculator {
 public class CalculatorException extends Exception{}

  public static Integer addition(Integer a, Integer b){
   return a + b;
    }

   public static Integer subtraction(Integer a, Integer b){
    return a - b;
    }

 public static Integer multiply(Integer a, Integer b){
  if(b==0 || a==0){
  throw new CalculatorException('It doesn\'t make sense to multiply by 
   zero');
  }
  return a * b;
  }

 public static Decimal divide(Integer numerator, Integer denominator){
  if(denominator == 0){
  throw new CalculatorException('you still can\'t divide by zero');
   }
 Decimal returnValue = numerator / denominator;
  if(returnValue < 0){
    throw new CalculatorException('Division returned a negative value.' + 
 returnValue);
 }
   return returnValue;
  }


 }

And my test class as follows
 
@isTest
   public class Calculator_Tests {

@isTest
 public static void addition() {
    Calculator.addition(1, 0);
   }
@isTest
  public static void subtraction() {
    Calculator.subtraction(1, 0);
   }

@isTest
 public static void divide_throws_exception_for_division_by_zero() {
 Boolean caught = false;
 try {
    Calculator.divide(1, 0);
  } catch (Calculator.CalculatorException e) {
    System.assertEquals('you still can\'t divide by zero', e.getMessage(), 
  'caught the right exception');
    caught = true;
   }
   System.assert(caught, 'threw expected exception');
   }

  @isTest
 public static void divide_throws_exception_for_division_by_two() {
 Boolean caught = true;
 try {
    Calculator.divide(1, 2);
 } catch (Calculator.CalculatorException e) {
    System.assertEquals('you still can\'t divide by zero', e.getMessage(), 
  'caught the right exception');
    caught = true;
   }
   System.assert(caught, 'threw expected exception');
 }


@isTest
public static void multiply_by_one() {
  Boolean caught = false;
  try {
    Calculator.multiply(1, 0);
    } catch (Calculator.CalculatorException e) {
    System.assertEquals('It doesn\'t make sense to multiply by zero', 
    e.getMessage(), 'caught the right exception');
     caught = true;
    }
    System.assert(caught, 'threw expected exception');
  }

@isTest
 public static void multiply_by_two() {
  Boolean caught = true;
  try {
     Calculator.multiply(1, 2);
   } catch (Calculator.CalculatorException e) {
    System.assertEquals('It doesn\'t make sense to multiply by zero', 
  e.getMessage(), 'caught the right exception');
    caught = true;
   }
   System.assert(caught, 'threw expected exception');
}   
}

 
Hello All,
I am very new to writing code and am having a hard time getting assignment rules to fire once a lead is entered into a visualforce page. I ahve found a few examples out there where folks suggest DML code, however I am not sure if I can put on the Visual Force page or if I should create a seperate class (or if I should create a trigger to fire after the lead is created). Salesfroce suggested I create a class and gave me the following code:
public Lead sample {get; set;}
    public AssignLeadsUsingAssignmentRules(ApexPages.StandardController controller) 
               {
        sample = new Lead();        
    }
   public void LeadAssign()     {             
        Database.DMLOptions dmo = new Database.DMLOptions();             
        dmo.assignmentRuleHeader.assignmentRuleId= '01Q0m0000006EH9';                     
        sample.setOptions(dmo); 
        insert sample; 
    } 
Below is my Visual Force page:
<apex:page standardController="Lead" showHeader="false" sidebar="true" extensions="AssignLeadsUsingAssignmentRules">
<apex:form >
     <apex:pageBlock title="Lead Information">
       <apex:pageBlockSection >
           <apex:pageBlockSection >
           <apex:inputField value="{!Lead.Lead_Referred_By__c}" required="True"/> 
           <apex:inputField value="{!Lead.Club2__c}" required="True"/>
           <apex:inputField value="{!Lead.company}" required="True"/>
           <apex:inputField value="{!Lead.NumberOfEmployees}" required="True"/>
           <apex:inputField value="{!Lead.FirstName}" required="True"/>
           <apex:inputField value="{!Lead.LastName}" required="True"/>
           <apex:inputField value="{!Lead.Phone}" required="True"/>
           <apex:inputField value="{!Lead.Email}" required="False"/>
           <apex:inputField value="{!Lead.Title}" required="True"/>
           <apex:inputField value="{!Lead.Additional_Comments__c}"/>
           </apex:pageBlockSection>
       </apex:pageBlockSection>  
            <apex:pageBlockButtons >
            <apex:commandButton action="{!save}" value="Save"/>
                </apex:pageBlockButtons>
</apex:pageBlock>
 </apex:form>
</apex:page>

My issue is that the CLub2__c field is used to dirive a Territory filed on the lead, the assignemnt rules fires off of the Territory field. Any code, tips , suggestions, prayers are greatly appreciated.
I have three for loops in my controller and when I run the test, I get code coverage everywhere except inside of the three for loops. Can someone point me in the right direction?
 
public with sharing class applyPayments_Controller {
    public List<InvoiceWrapper> searched_invoices {get;set;}
    public List<gii__OrderInvoice__c> selectedInvoices {get;set;}
    public string accountName {get;set;}
    public boolean viewTable;
    public date paymentDate {get;set;}
    public string paymentMethod {get;set;}
    public string reference {get;set;}
    public decimal amount {get;set;}
    public string comments {get;set;}
    
    public Boolean getViewTable()
    {
        return this.viewTable;
    }
    
    public applyPayments_Controller()
    {
        viewTable=false;
        searched_invoices = new List<InvoiceWrapper>();
    }
    
    public void searchInvoices()
    {   
        string likeAccountName = '%' + accountName + '%';
        searched_invoices.clear();
        for(gii__OrderInvoice__c i: [select Id, Name, Total_Invoice__c, gii__BalanceAmount__c, Past_Due__c, Account_Name__c, gii__Status__c from gii__OrderInvoice__c 
                                     where (Account_Name__c LIKE :likeAccountName AND gii__Status__c != 'Cancelled' AND Past_Due__c != 'PAID')
                                     order by Account_name__c, Name])
        {
            searched_invoices.add(new InvoiceWrapper(i));
        }
        
        viewTable = true;
    }
    
    public PageReference Next()
    {
        selectedInvoices = new List<gii__OrderInvoice__c>();
        selectedInvoices.clear();
        for (InvoiceWrapper wrapInvoiceObj : searched_invoices)
        {
            if(wrapInvoiceObj.selected == true)
            {
                selectedInvoices.add(wrapInvoiceObj.inv);
            }
        }
        
        paymentDate = System.Today();
        PageReference applyPaymentsVF_2 = new PageReference('/apex/applyPaymentsVF_2');
        return applyPaymentsVF_2;
    }
    
    public void applyPayment()
    {
        for(gii__OrderInvoice__c inv : selectedInvoices)
        {
            gii__ARInvoicePayment__c payment = new gii__ARInvoicePayment__c();
            payment.gii__Invoice__c = inv.id;
            payment.gii__Reference__c = reference;
            payment.gii__Comments__c = comments;
            payment.gii__PaymentMethod__c = paymentMethod;
            payment.gii__PaymentDate__c = paymentDate;
            payment.gii__PaidAmount__c = inv.gii__BalanceAmount__c;
            insert payment;
        }    
    }
    
    //This is wrapper/container class
    public class InvoiceWrapper
    {
        public String accName {get;set;}
        public String invName {get;set;}
        public decimal total {get;set;}
        public decimal balance {get;set;}
        public String status {get;set;}
        public gii__OrderInvoice__c inv {get;set;}
        public Boolean selected {get;set;}
        public InvoiceWrapper(gii__OrderInvoice__c i)
        {
            inv = i;
            selected = false;
            accName = i.Account_Name__c;
            invName = i.Name;
            total = i.Total_Invoice__c;
            balance = i.gii__BalanceAmount__c;
            status = i.Past_Due__c;
        }
    } 
}
 
@isTest
public class applyPayments_ControllerTest {
    public static testMethod void testMyController()
    {  
        gii__SalesOrder__c so = new gii__SalesOrder__c();
        Id RecordTypeIdSO = Schema.SObjectType.gii__SalesOrder__c.getRecordTypeInfosByName().get('Service Call Order').getRecordTypeId();
        so.RecordTypeId = RecordTypeIdSO;
        so.gii__OrderType__c = 'Standard';
        insert so;
        
        gii__OrderInvoice__c inv = new gii__OrderInvoice__c();
        inv.gii__SalesOrder__c = so.Id;
        insert inv;
        
        applyPayments_Controller controller = new applyPayments_Controller();
        applyPayments_Controller.InvoiceWrapper wrp = new applyPayments_Controller.InvoiceWrapper(inv);
        controller.searchInvoices();
        controller.getViewTable();
        controller.Next();
        controller.applyPayment();
    }
}

 
Hello,
I have an Apex Trigger that I needs to perform the following:
  • prevent duplicate lead from being inserted during an import
  • add task to existing Lead that was found within SF
The trigger belows does meet my requiremtns except that it also adds a task to the newly inserted Lead.  The Newly inserted Lead does not exsit in Salesforce so I am not sure why a task is being added.
trigger LeadPreventDuplicate on Lead (after insert,after update) {

    Map<String, Lead> leadMap = new Map<String, Lead>();

      for (Lead lead : System.Trigger.new) 
      { 

       if ((lead.Email != null) && (System.Trigger.isInsert ||
            (lead.Email != System.Trigger.oldMap.get(lead.Id).Email))) 
            {
              leadMap.put(lead.Email, lead);
            }
      }

      List<task> addtask=New List<task>();
     
      for (Lead lead : [SELECT Email FROM Lead WHERE Email IN :leadMap.KeySet()]) 
      {
        Lead newLead = leadMap.get(lead.Email);
        addtask.add(new Task(
        WhoID =lead.id, 
        Status = 'Active',
        Subject = 'Test Task',
        ActivityDate = system.today()));
      
       } 
       insert addtask; 
      
       Lead[] dupes = new Lead[0];
          Set<String> email = new Set<String>(), dupEmail = new Set<String>();
              for(Lead record: Trigger.new)
              email.add(record.email);
              email.remove(null);
              for(Lead record: [SELECT Id, Email FROM Lead WHERE Email IN :email])
                    if(!Trigger.newMap.containsKey(record.id))
                    dupEmail.add(record.Email);
              for(Lead record: Trigger.new)
        if(dupEmail.contains(record.Email))
            dupes.add(record.clone(true));
        else
            dupEmail.add(record.Email);
    delete dupes;
}

Thanks for the assistance.
M
 
I'm trying to pull a few fields into an IF formula and I'm not receiving a syntax error but the formula isn't calculating.  What am I missing?

Monthly Revenue at End of Contract
IF(((Contract_Term_Yrs__c * 12) < Months_to_sign_existing_clients__c),((Contract_Term_Yrs__c * 12) * New_Monthly_Revenue_Existing__c),(Months_to_sign_existing_clients__c * New_Monthly_Revenue_Existing__c))
Contract_Term_Yrs__c =  Number Field
Months_to_sign_existing_clients__c = Formula Field(Number)
New_Monthly_Revenue_Existing__c = Formula Field(Currency) 



 
the trigger should be on account to check the assets and if ALL Assets where product family = "bla bla "  and their status was "Canceled" the trigger should update bla bla Account stage (API Name = Account_Status__c )  to "Cancel".
Hello
I have requirement to calculate today hours for the current week. 
We have custom object Tracker__C and field Hours__C. Hours__C is user entered field. Next to the user entered field we wanted to show the users total hours he has entered thus far this week. 
For example  (Day of the week - Hours entered - Total hours this week)
Monday - 4 - 4
Tuesday - 6 - 10
Wednesday - 2 - 12
Thursday - 8 - 20
Friday - 8 - 28

All help appreciated
Thanks
Dinesh
  • January 14, 2019
  • Like
  • 0
Hi,

I am looking to see the best approach for Salesforce CI. I have gone through many forum and blogs but haven't been able to grasp them. I tried to setup CI for the entire org but facing a lot of challeges which I guess you guys quite aware of.

What I am looking to do incremental deployment based on the git diff, dynamically generate package.xml based on the metadata committed which I think would be manageable something like sfdc-git-package https://www.npmjs.com/package/sfdc-git-package. I am having a hard time implementing this.

Please someone help
Can someone help me to show how I can change the Sales Console Lightning Layout. Currently it is showing as shown in the screen shot below as 3 Column layout. I wanted to change the layout to show the highlight panel on top. I am finding no help from Salesforce help section or trailhead for this. Please bear in mind I am talking about Lightning Sales Console and not Classic. I did the Edit Page and takes me but doesn't allow me to change the layout. 

User-added image
Is there a way to hide "Save & New" Button from the Task page Layout?

User-added image

I looked at everywhere and couldn't find the solution. I do want to give them Create/Edit Permission so no option there to remove that.

Please help
Custom URL for the cast creating inline headers and side bar. I tried the following addition things

            urlConcat += '&inline=0';
            urlConcat += '&isdtp=lt';
            urlConcat += '&isdtp=nv';
            urlConcat += '&isdtp=vw';

the only one that work is '&isdtp=nv' but after saving the activity, the hyperlink in the related list doesn't work. I have attached a screen shot 

User-added image

Anyone can help?

 
Hi,

I am looking to see the best approach for Salesforce CI. I have gone through many forum and blogs but haven't been able to grasp them. I tried to setup CI for the entire org but facing a lot of challeges which I guess you guys quite aware of.

What I am looking to do incremental deployment based on the git diff, dynamically generate package.xml based on the metadata committed which I think would be manageable something like sfdc-git-package https://www.npmjs.com/package/sfdc-git-package. I am having a hard time implementing this.

Please someone help
I'm an admin that doesn't know apex and I'm troubleshooting a custom field on the Cases object that's getting blanked out.  SFDC support told me which apex class is doing it, apparently because they see field update depencies associated with it which list the custom field in question.  

Since I'm not a developer, and the developer that wrote this isn't with the company, I'm having a hard time figuring out why it's doing this.  Can anyone tell me what this apex class is doing?

global class CaseTeamMembersCleanupBatch implements Database.Batchable<sObject>{

    
    global Database.QueryLocator start(Database.BatchableContext BC){
        
        String query = 'SELECT Id,Name, OwnerId FROM Account';
        if(Test.isRunningTest())
            query = 'SELECT Id, Name, OwnerId FROM Account order by Id Desc limit 200';
    return Database.getQueryLocator(query);
  }
    
    global void execute(Database.BatchableContext BC, List<Account> scope){
        
        Map<Id, Id> AccountIds = new Map<Id, Id>();
        Map<Id, List<AccountHistory>> accountHistoryMap;
        Map<Id, Set<Id>> oldOwnerMap;
        List<CaseTeamMember> teamMembersForDelete = new List<CaseTeamMember>();
        
        
        //List<Account
        //get account Ids in this context
        
        for(Account act: scope){
            AccountIds.put(act.Id, act.OwnerId);
        }
        
        accountHistoryMap = new Map<Id, List<AccountHistory>>();
        oldOwnerMap = new Map<Id, Set<Id>>();
        String oldValue;
        
        List<AccountHistory> accountHistoryLst = [Select Id, OldValue, NewValue, Field, AccountId from AccountHistory 
                                  where field = 'Owner' and AccountId In: AccountIds.KeySet()];
        if(Test.isRunningTest())
            accountHistoryLst = new List<AccountHistory>{ new AccountHistory(field='Owner', AccountId=scope[0].Id)};
        for(AccountHistory hist: accountHistoryLst)
        {
            oldValue = (Test.isRunningTest()) ? System.UserInfo.getUserId() : String.ValueOf(hist.OldValue);
            if(System.Pattern.matches('[a-zA-Z0-9]{18}|[a-zA-Z0-9]{15}', oldValue)){
                if(oldOwnerMap.containsKey(hist.AccountId)){
                    //accountHistoryMap.get(hist.AccountId).add(hist);
                    if( ! oldOwnerMap.get(hist.AccountId).Contains(Id.ValueOf(oldValue))) {
                        if(Id.ValueOf(oldValue) != AccountIds.get(hist.AccountId) ){
                            oldOwnerMap.get(hist.AccountId).add(Id.ValueOf(oldValue));
                        }
                    }
                }
                else
                {
                    //accountHistoryMap.put(hist.AccountId, new List<AccountHistory>{hist});
                    oldOwnerMap.put(hist.AccountId, new Set<Id> {Id.ValueOf(oldValue)}) ;
                }
            }                         
        }
        
        
        //Get all the cases from account with team members
        Set<Id> AccountOldValues = new Set<Id>();
        for(Case csc: [Select Id, AccountId, (Select Id, MemberId from TeamMembers ) 
                       from Case where AccountId IN: oldOwnerMap.KeySet()])
        {
            AccountOldValues = oldOwnerMap.get(csc.AccountId);
            for(CaseTeamMember member: csc.TeamMembers){
                
                //check if this member is part of old value from history table
                if(AccountOldValues.contains(member.MemberId)){
                    teamMembersForDelete.add(member);
                }
            }
        }
        
        if(teamMembersForDelete.size()!=0)
          delete teamMembersForDelete;
        
    }
    
    global void finish(Database.BatchableContext BC){
        
    }

}
trigger LinkEnCusToAccP on Acc_P__c (before insert, before update) {
    // Data load bypass    
    if(IsUtil.adminByPass()) return;
    
    Private Integer iCount = 0;

    for (Acc_P__c a : Trigger.new) {
        if(Trigger.isUpdate) {
            if(a.Account__c != Trigger.old[iCount].Account__c) {
                a.Ent_Cus__c = [select Ent_Cus__c from Account where Id = :a.Account__c limit 1].Ent_Cus__c;
            }
            iCount++;
        } else {
            if(a.Account__c != null) {
                a.Ent_Cus__c = [select Ent_Cus__c from Account where Id = :a.Account__c limit 1].Ent_Cus__c;
            }
        }
    }
}
Hi everyone-

I have a custom field that I want to display the Last Name, First Name of a given account. For example, If the account name is "John and Jane Smith Household", I need the formula to populate the L,F Name field to say "Smith, John and Jane". Does anyone know the formula to do this?
HI 

I am trying to parse this 

<advertisers type="array">
  <advertiser>
    <id type="integer">7</id>
    <name>ABC Telecom</name>
  </advertiser>
  <advertiser>
    <id type="integer">106</id>
    <name>ABC_Ozone</name>
  </advertiser><advertiser>
    <id type="integer">13</id>
    <name>Acme Corp</name>
  </advertiser>
</advertisers>


with this code
 
public with sharing class xmltosobject{
    public string s='';
    public void readxml(ID TestObjectID){
        XMLParsing__c TObj = [SELECT xml__c FROM XMLParsing__c where id= : TestObjectID];
        s= TObj.Event_Message_XML__c ;
        List<ParsedXML__c> newaccounts = new List<ParsedXML__c> ();
        
        Dom.Document docx = new Dom.Document();
        docx.load(s);
        dom.XmlNode xroot = docx.getrootelement() ;
        
        dom.XmlNode [] xrec = xroot.getchildelements() ; //Get all Record Elements
        
        for(Dom.XMLNode child : xrec) //Loop Through Records
        {
            ParsedXML__c a = new ParsedXML__c();
            
            for (dom.XmlNode awr : child.getchildren() ) {
                if (awr.getname() == 'id') {
                    system.debug('Id' + awr.gettext());
                    a.accountnumber__c = awr.gettext();
                }  
                
                if (awr.getname() == 'name') {
                    system.debug('name' + awr.gettext());
                    a.name__c = awr.gettext();
                }  
                
                
            }
            newaccounts.add(a);
        }
        system.debug(newaccounts);//you could insert here or upsert based on ID with an external Id field
    }
}


I got an invalid type when running this in execute anonymous
 
String str = '<advertisers type="array"><advertiser><id type="integer">7</id><name>ABC Telecom</name></advertiser><advertiser><id type="integer">106</id><name>ABC_Ozone</name></advertiser><advertiser><id type="integer">13</id><name>Acme Corp</name></advertiser></advertisers>';
xmltosobject.readxml objPartnerCreds = new xmltosobject.readxml();
system.debug(objPartnerCreds);


 
I want to know what stage an opportunity that a contact is related to, on the contact record. What is the best way to do that.

Hi Guys,

I am triggering a POST request via process builder and it works but can you please tell me how can I capture the HTTP response I get back? The external system will send me a string I would like to store on the record which started the process. 
 

@future(callout=true)

        public static void calloutmethod(String name){
                Http http = new Http();
                HttpRequest request = new HttpRequest();
                request.setEndpoint('XXX');
                request.setMethod('POST');
                request.setHeader('Content-Type', 'application/json;charset=UTF-8');
                request.setHeader('accept', 'application/json');
                request.setBody(name);
                
                response = http.send(request);
        }

Thanks a lot.

Krisz
Hi,

I am trying to migrate custom fields on Opportunity object from one org to another and I am using Salesforce CLI for the migration. I have created a package.xml file and successfully retrieved and deployed all the metadata associated with the custom fields to another org. However, when I checked the target org I don't see the custom fields under Fields and Relationships section.

I have read some online posts regarding this and some people have answered saying this could be related to profiles. I am the System Administrator in both Source and Target org and also checked the field-level security of the custom fields but still couldn't find a way to make the fields visible in target org. Please let me know if any information is needed from my end. 

Thanks in advance for any help you can provide.

Package.XML file I used:
 
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>Opportunity.Customer Success</members>
        <name>BusinessProcess</name>
    </types>
    <types>
        <members>Account.Data_GB__c</members>
        <members>Account.Files_GB__c</members>
        <members>Account.Instance__c</members>
        <members>Account.Prod_Org_ID__c</members>
        <members>Opportunity.At_Risk__c</members>
        <members>Opportunity.BST_Agreement_Sent__c</members>
        <members>Opportunity.BST_Agreement_signed_Date__c</members>
        <members>Opportunity.Baseline_Tests_Passing_Date__c</members>
        <members>Opportunity.Bugs_with_Cases__c</members>
        <members>Opportunity.Cases__c</members>
        <members>Opportunity.Clone_Org_ID__c</members>
        <members>Opportunity.Committed_BST_Plan__c</members>
        <members>Opportunity.Completed__c</members>
        <members>Opportunity.Contacts__c</members>
        <members>Opportunity.Courtesy_License_Expires__c</members>
        <members>Opportunity.Current_Generator_s__c</members>
        <members>Opportunity.Customer_Pitch_Call__c</members>
        <members>Opportunity.Customer_Withdrew__c</members>
        <members>Opportunity.Data_GB_Total__c</members>
        <members>Opportunity.Delivery_Installation_Status__c</members>
        <members>Opportunity.Deployment_Workflow__c</members>
        <members>Opportunity.Drop_In_Framework__c</members>
        <members>Opportunity.Execute_Days__c</members>
        <members>Opportunity.Execute__c</members>
        <members>Opportunity.Initial_BST_Plan_Documented__c</members>
        <members>Opportunity.Is_On_Hold__c</members>
        <members>Opportunity.License_Provisioned__c</members>
        <members>Opportunity.Lightning_Analytics_User__c</members>
        <members>Opportunity.Missing_Onboarding_Fields__c</members>
        <members>Opportunity.On_Hold_Date__c</members>
        <members>Opportunity.Onboard_Days__c</members>
        <members>Opportunity.Onboard__c</members>
        <members>Opportunity.Onboarding_Fields_Completed__c</members>
        <members>Opportunity.Operating_Systems__c</members>
        <members>Opportunity.PII_Required_by_Tests__c</members>
        <members>Opportunity.PII_in_Sandbox__c</members>
        <members>Opportunity.Pilot_Agreement_Signed_Date__c</members>
        <members>Opportunity.Post_Sandbox_Activities__c</members>
        <members>Opportunity.Preferred_Browsers__c</members>
        <members>Opportunity.Primary_Cloud__c</members>
        <members>Opportunity.Prioritized_Use_Cases__c</members>
        <members>Opportunity.Prod_Data__c</members>
        <members>Opportunity.Prod_Files_GB__c</members>
        <members>Opportunity.Prod_Instance__c</members>
        <members>Opportunity.Prod_Org_ID__c</members>
        <members>Opportunity.Qualify_Days__c</members>
        <members>Opportunity.Qualify__c</members>
        <members>Opportunity.Reason_for_Hold__c</members>
        <members>Opportunity.Reason_for_Withdrawal__c</members>
        <members>Opportunity.Red_Account_Report__c</members>
        <members>Opportunity.Region__c</members>
        <members>Opportunity.Repo_Access__c</members>
        <members>Opportunity.SB0__c</members>
        <members>Opportunity.Salesforce_Withdrew__c</members>
        <members>Opportunity.Sandbox_CS_Instance__c</members>
        <members>Opportunity.Sandbox_Cloned_Date__c</members>
        <members>Opportunity.Sandbox_Data_GB__c</members>
        <members>Opportunity.Sandbox_Files_GB__c</members>
        <members>Opportunity.Sandbox_Name__c</members>
        <members>Opportunity.Sandbox_Org_ID__c</members>
        <members>Opportunity.Sandbox_Pilot_Record__c</members>
        <members>Opportunity.Sandbox_Preview__c</members>
        <members>Opportunity.Sandbox_Type__c</members>
        <members>Opportunity.Signature_Customer__c</members>
        <members>Opportunity.Source_Org_Identified__c</members>
        <members>Opportunity.Special_Requirements__c</members>
        <members>Opportunity.Status_Comments__c</members>
        <members>Opportunity.Test_Account__c</members>
        <members>Opportunity.Test_Code_Repo__c</members>
        <members>Opportunity.Test_Code_Shared__c</members>
        <members>Opportunity.Test_Context_Switching__c</members>
        <members>Opportunity.Test_Data_Method__c</members>
        <members>Opportunity.Test_Data_Source__c</members>
        <members>Opportunity.Testing_Practices__c</members>
        <members>Opportunity.Testing_Technology__c</members>
        <members>Opportunity.Total_Days__c</members>
        <members>Opportunity.Use_Cases_Documented_Date__c</members>
        <members>Opportunity.Wave_Mobile_User_del__c</members>
        <members>Opportunity.Wave_User_del__c</members>
        <members>Opportunity.X3rd_Party_API_Access__c</members>
        <members>Opportunity.X3rd_Party_APIs__c</members>
        <name>CustomField</name>
    </types>
    <types>
        <members>Opportunity</members>
        <name>CustomObject</name>
    </types>
    <types>
        <members>Admin</members>
        <name>Profile</name>
    </types>
    <version>45.0</version>
</Package>

- Bhupender Agarwal
Hi,

I am having a massive confusion,

We have a database of 400,000 records.. which calls for duplication.

I want to check if alternate phone number of any of the account matches with the Primary phone number of any of the account, If it does, there is a checkbox  called "Marked For deletion"  m that checkbox should get selected and primary phone number of that account should become the alternate phone number of the acount against which it has matched 

So lets say ,

Accoount : A  Primary No : 1234  Secondary No : 5678

Accoount : B  Primary No : 9241  Secondary No : 1234 

Accoount : C  Primary No : 9241  Secondary No :  1234

Account B and Account C should have marked for deletion checked.
and Account B's primary phone number should become Secondary phone number of Account A. 

Please help me in achieving this 
 
Hello Team,

While doing the trailhead for Quick Start - Apex Coding for Admins - Create a Trigger, while I am creating the candidate Nina Simone, and update the ZIP Code field as "20008", system gives me an error message stating as - Candidate Zip Code does not exist in specified State.

Kindly advise where I am going incorrect.

Thanks
Vinay Kumar Salve