• Anthony McDougald
  • NEWBIE
  • 140 Points
  • Member since 2018

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 41
    Replies
I am completely new to Apex and could really use some help with what seems to be a simple task.  I have a formula on the contact, Persona_True__c, that returns a 1 if the custom field "persona" is populated and a 0 if it is blank.

I would like to have a roll-up summary that sums this field at the account level in a field called Related_Personas__c.  

Because we can't roll-up from contact to account I'm reading that this type of action needs to be a trigger, but I don't even know where to start.  Does anyone have any thoughts or expertise they can share to help me out? 

I am trying to create a process through Process builder to update the following Fields if the field Future Interest = True:
Lead Disposition = Contacted DM
Outbound Disposition = Not Interested
Status = Nurture.

What I am trying to achieve is when a user marks Future interest as true I want these field to auto update to the above mentioned values.

BillAndPayWrapper(BillingHistoryServiceSet__x billPay, String companyCode) {
            this.postDate      = billPay.PostingDate__c;
            this.invoice      = billPay.InvoiceNo__c;
            this.amount      = billPay.TotalDueAmt__c.setScale(2);
            this.billPeriod  = billPay.BillPeriod__c;

billPeriod is string and BillPeriod__c field under external object is data type text . It is external data and i get it as YYYY/MM. But i need to format it to MM/YYYY
Hello, I am trying to unlock a "Matter" record when the record goes into an approval process. A trigger will see that it is locked and then unlock the record. This is working, but my test class is only covering 66%. How can I get it to 100%? Thanks!

Trigger
trigger UnlockMatter on litify_pm__Matter__c (after insert, after update) {
    for(litify_pm__Matter__c matter : trigger.New) {
        If(Approval.isLocked(matter.Id)) {
            Approval.unlock(matter.Id);
        }
    }
}

Test Class
@isTest
public class TestUnlockMatter {
     @isTest static void TestEditMatterInApproval() {
          // Test data setup
          
          // Create A Party to assign to the matter
          Account party = new Account(litify_pm__First_Name__c='Jim', litify_pm__Last_Name__c='Halpert');
          insert party;
          
          // Create A Matter that is locked and unlock and edit it
          litify_pm__Matter__c matter = new litify_pm__Matter__c(litify_pm__Display_Name__c='Jim Halpert vs. Dwight Schrute', litify_pm__Client__c= party.Id);
          insert matter;
          Approval.lock(matter.Id);
         
         //Perform Test
         Test.startTest();
         Approval.unlock(matter.Id);
         matter.litify_pm__Display_Name__c ='Jim Halpert vs. Micheal Scott';
         Test.stopTest();
     }
}

 
The requirement is to fire trigger in case of record update, but do not want to update record in-case of mass update i.e. bulk update via data loader. 
Hi All,

We have a created a user and given all the required permissions to that user to run batch job. When we run the job manually it is running successfully, but do the same while scheduling it is failing. throwing the error as "System.LimitException: reports:Too many query rows: 50001
".
I have given all the permissions to objects, related fields Custom settings.
1. I have given "Manage custom report" permission and "View All custom setting" permission for custom settings. Do we need to give any other permission related to custom setting or metadata or report. Is there anything I am missing while granting permission.
Can anyone help me on this who have experienced the same issue.

Thanks,
Sirisha
I am attempting to query our Salesforce system from a Marketing Cloud Data Extension.  One of the fileds that I want to Query using SQL Query from the Marketing Cloud is Contact Role.  This field happens to be a multiselect picklist.  I would like to be able to query multiple items in my picklist.  For instance, return all contacts who have "Director of Nursing" and "Administrator" selected in the MultiSelect Picklist.  Unfortunately it only returns exact matches.  Any tips to get this to work correctly? 

Select C.Name, C.Email, C.Organization_Physical_State__c, C.Contact_Role__c

From Contact_Salesforce C


Where C.Contact_Role__c IN ('Administrator', 'Director of Nursing') AND

(C.Email IS NOT NULL AND 
C.Closed__c = 'False' AND
Account_Salesforce.Closed__c = 'False' AND
C.Organization_Record_Type__c = 'Long Term Care' AND 
Organization_Account_Type__c = 'Nursing Home' )


AND

(C.Organization_Physical_State__c = 'South Dakota' OR 
C.Organization_Physical_State__c = 'North Dakota')

 

Hi,

Im using nested loop for fetching case comments depending on the languages(its a list), To achieve this I have implemented nested Loop.
1st loop fetches all the languages from the custom object and 
2nd loop fetches case comments depending on the language.
While im using this  "Too many SOQL queries" is firing please suggest me solution.

 

This one appears to be stumping a number of people.

The general use case is to trigger off of a milestone target date in Process Builder, or Workflows, or other Service Cloud processes, or in my situation - creating a Calendar that displays cases with upcoming SLA milestone target dates.

The work around appears to be to populate a custom case field (such as Due_Date__c) and then use that field as the trigger or reference point.

I just don't know how to populate a case's Due_Date__c with the case's SLA Milestone Target Date. I brought this up to Premiere Support and they referred me to here since they confirmed that:

"we cannot achieve this by process. I'm afraid this is also difficult through triggers or flow."

So it looks like this may require some Apex magic. I'm not that familiar with Apex or how to trigger it per se, but I understand basic code syntax. Would someone like to take a crack at solving how to update a custom due date field with a case's milestone target date?
I am not a developer in the slightest sence however I have an idea for an app that I think would be relatively easy to build and would be helpful for many orgs. Can someone point me in a direction as to where to look for a developer? What developing and maintaining an app entails? Even if you would be potentially interested in working with me on this, that would be greatly appreaciated. 

Also, I am sorry if this is the wrong forum to post questions like this in. I just don't know where to start at and figured since this was developer based, the knowledge here would be a great place to start. 

I'm trying to create a validation rule  that would prevent a user from saving an opportunity record if a picklist is NULL at the StageName QR Request. 

The below VR gets triggered way before the StageName I listed above. 

Can someone let me know what I'm doing wrong or update this code? 

Thanks

 
AND(
  ISPICKVAL( StageName, 'QR Request'),
  NOT(ISPICKVAL( Qualified_Resolution_Type__c,'ISNULL' ))
)

 
  • November 30, 2019
  • Like
  • 0
I am completely new to Apex and could really use some help with what seems to be a simple task.  I have a formula on the contact, Persona_True__c, that returns a 1 if the custom field "persona" is populated and a 0 if it is blank.

I would like to have a roll-up summary that sums this field at the account level in a field called Related_Personas__c.  

Because we can't roll-up from contact to account I'm reading that this type of action needs to be a trigger, but I don't even know where to start.  Does anyone have any thoughts or expertise they can share to help me out? 
I have a trigger to check the duplicate records in salesforce..its working fine when I'am inserting a duplicate record manually, So it is throwing the "dublicates record found" error mesage,
but, 
Now when i'm deleting that record from salesforce and
when I'm trying to upload the same record twice (created 2 rows containing same data in my input csv file) by workbench, trigger is not getting fired ,and it is successfully inserting both the records with the same data to salesforce, whereas the expectation is first row data should get inserted and for second row, it should throw the error(because its a dublicate data).

Can anyone please help me out with this ?
I have written the below code and the test class is failed Can someone help me with the code. I have to add products on quoteline items

@isTest
public class testclass {
    static testMethod void testUpdateAccount() {
        Quotes__c a = new Quotes__c(Name='testAccount',OpportunityId__c= 'testAccount');
        insert a; 
        
        Product2__c prod = new Product2__c(Name = 'Laptop X200', 
                                           Family__c = 'None');
        insert prod;
        
        Id PricebookId = Test.getStandardPricebookId();
        
        PricebookEntry__c StandardPrice = new PricebookEntry__c(
            Pricebook2Id__c = PricebookId, Product2Id__c = prod.Id,
            UnitPrice__c = 10000, IsActive__c = true);
        insert StandardPrice;
        
        
        PricebookEntry__c customPB = new PricebookEntry__c(Name='Custom Pricebook', IsActive__c=true);
        insert customPB;
        
        PricebookEntry__c customPrice = new  PricebookEntry__c(
            Pricebook2Id__c = customPB.Id, Product2Id__c = prod.Id,
            UnitPrice__c = 12000, IsActive__c = true);
        insert customPrice;
        
        
        QuoteLineitem__c quote = new QuoteLineitem__c (
                                                          Product2Id__c='G=10000',
                                                          Discount__c= 20,
                                                          Line_Item_Description__c='Test'
                                                          );
        
        insert Quote; 
        
        System.assertEquals('test', a.Name);
        
    }
}

Controller Class

public class ProductSearchPopupController {
   
    public String query {get; set;}
    public List<PricebookEntry__c> products {get; set;}
    public List<wrapProduct> wrapProductList {get; set;}
    public List<PricebookEntry__c> selectedProduct{get;set;}
    public List<QuoteLineitem__c> quoteLineList{get;set;}
    public List<wrapProduct> selectedWrapperList{get;set;}
    public Boolean normalList{get;set;}
    public Boolean selectedList{get;set;}
    public Boolean block{get;set;}
    public Boolean block1{get;set;}
    public Boolean block2{get;set;}
    public String SalesPrice {get; set;}
    public integer Discount {get; set;}
    public String Quantity {get; set;}
    public String ServiceDate {get; set;}
    Id recordId;
    
    public ProductSearchPopupController(ApexPages.StandardController controller){
        recordId = controller.getId();
        system.debug('recordId '+recordId);
        wrapProductList = new List<wrapProduct>();
        selectedWrapperList = new List<wrapProduct>();
        normalList = true;
        selectedList = false;
        block = true;
        block1 = false;
        block2 = false;
    }
    
    public PageReference runQuery(){
        if(query == null || query == ''){
            system.debug('query '+query);
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Info,'Please enter Product to search for'));
            
            return null;
        }
        system.debug('query '+query);
        List<List<PricebookEntry__c>> searchResults=[FIND :query IN ALL FIELDS RETURNING PricebookEntry__c (id, Name, ProductCode__c, Product2Id__r.Product_Description__c,UnitPrice__c, UseStandardPrice__c)];
        if(searchResults[0]!=null){
            for(PricebookEntry__c a: searchResults[0]) {
                // As each Account is processed we create a new wrapAccount object and add it to the wrapAccountList
                wrapProductList.add(new wrapProduct(a));
                block = true;
                block1 = true;
                block2 = false;
            }
        }
        return null;
    }
    public PageReference ProceedWithSelectedToNextPage(){
        selectedWrapperList = new List<wrapProduct>();
        normalList = false;
        selectedList = true;
        for(wrapProduct selectedWrapObj: wrapProductList){
            system.debug('selectedWrapObj.selected  ---------'+selectedWrapObj.selected);
            if(selectedWrapObj.selected == true)
                selectedWrapperList.add(selectedWrapObj);
        }
        system.debug('selectedWrapperList size ---------'+selectedWrapperList.size());
        PageReference pageRef = new PageReference('/apex/AccountOpportunityTwoPage');
        pageRef.setRedirect(false);
        return pageRef;
    }
    public void processSelected() {
        selectedProduct = new List<PricebookEntry__c>();
        for(wrapProduct wrapProductObj : wrapProductList) {
            if(wrapProductObj.selected == true) {
                selectedProduct.add(wrapProductObj.acc);
                block = false;
                block1 = false;
                block2 = true;
                
            }
        }
    }
    
    public class wrapProduct{
        public PricebookEntry__c acc {get;set;}
        public Boolean selected {get;set;}
        public wrapProduct(PricebookEntry__c p) {
            this.acc = p;
            this.selected = false;
        }
        
    }
    
    public pagereference saveproduct(){ 
        List<QuoteLineitem__c> quoteLineList = new  List<QuoteLineitem__c>();
        if(!selectedProduct.isEmpty()){
            for(PricebookEntry__c sp:selectedProduct){
                system.debug('sp '+sp);
                QuoteLineitem__c qli = new QuoteLineitem__c();
                qli.QuotesId__c = recordId;
                qli.ListPrice__c = sp.UnitPrice__c;
                qli.UnitPrice__c = sp.UnitPrice__c;
                qli.Product2Id__c = sp.Product2Id__c;    
                if(Discount!=0 || Discount!=null){
                    qli.Discount__c = Discount;
                }
                quoteLineList.add(qli);
            }
            
            
            if(quoteLineList.size()>0){
                insert quoteLineList;
                PageReference pageRef = new PageReference('https://proseraa.lightning.force.com/lightning/r/Quotes__c/'+recordId+'/view');
                pageRef.setRedirect(true);
                return pageRef;
            }
        }
        return null;
    }
   
}

Hi all,

I'm trying to create a validation rule via trigger when two multiselect picklist values are the same then the validation to fire.

trigger differentValues on User (before insert) {

    for(User u : Trigger.New) {
        if(u.Restrict_access_by_Country__c =='DE' && u.TestMultiSelectCountry__c== 'DE' ) {
        u.addError('Values cannot be the same');
    }
    }
}

This trigger it's not firing.. I'm confused why not?
Hey there, I'm new to development and APEX classes, so apologies if this is easy. But basically we have Zuora package (for billing) and I'm updating one of the classes for default values when creating a quote. Most of the code works, except when I add in a reference to Billing Country on the Account it says it doesn't exist. My code for that particular part is below, and full code below that.

Error: 
Error: Compile Error: Variable does not exist: billingcountry at line 23 column 20
// Retrieve the account ID from the quote
      Id accountId = (Id) record.get('zqu__Account__c');
      
      List<Account>accounts = [SELECT Id, BillingCountry FROM Account WHERE Account.ID = :accountID];
      
      if (accounts.billingcountry == 'Canada')
      {
      record.put('zqu__PaymentGateway__c', 'Standard');
      } else {
      record.put('zqu__PaymentGateway__c', 'USD2');
      }
Full code:
global class ZuoraDefaultValues extends zqu.CreateQuoteController.PopulateDefaultFieldValuePlugin{  
   global override void populateDefaultFieldValue
(SObject record, zqu.PropertyComponentController.ParentController pcc)
   {    
      super.populateDefaultFieldValue(record, pcc);  
      
      //Populate default values in the quote header  
      Id OpptId = (Id) record.get('zqu__Opportunity__c');    
      List<Opportunity> Opportunity= [SELECT Id, Name FROM Opportunity WHERE Opportunity.Id = :OpptId ]; 
       
      record.put('Name', 'Quote For ' + Opportunity[0].Name + ' ' + Date.today().format());
      record.put('zqu__InitialTerm__c', 12);    
      record.put('zqu__RenewalTerm__c', 12);    
      record.put('zqu__ValidUntil__c', Date.today().addDays(30));    
      record.put('zqu__StartDate__c', Date.today());
      record.put('zqu__PaymentMethod__c', 'Credit Card');  
      
      // Retrieve the account ID from the quote
      Id accountId = (Id) record.get('zqu__Account__c');
      
      List<Account>accounts = [SELECT Id, BillingCountry FROM Account WHERE Account.ID = :accountID];
      
      if (accounts.billingcountry == 'Canada')
      {
      record.put('zqu__PaymentGateway__c', 'Standard');
      } else {
      record.put('zqu__PaymentGateway__c', 'USD2');
      }
    

      // Find the contacts associated with the account         
      List<Contact>contacts = [SELECT Id, Name FROM Contact WHERE Account.Id = :accountId];
      
      // Assuming the contacts are present set the billTo and soldTo to the first contact
      if  (contacts.size() > 0) {
         // System.debug('mp: about to add ' + contacts[0].Id + ' as a contact ID');
         record.put('zqu__BillToContact__c', contacts[0].Id);
         record.put('zqu__SoldToContact__c', contacts[0].Id);

         // Beforeretrieving  the lookup  options, needs to populate the map first
         super.setLookupOptions(pcc);
      
         // Now retrieve the lookup component options
         zqu.LookupComponentOptions billToOptions = super.getLookupOption('zqu__BillToContact__c');
         billToOptions.targetId = contacts[0].Id;
         billToOptions.targetName = contacts[0].Name;
         zqu.LookupComponentOptions soldToOptions  = super.getLookupOption('zqu__SoldToContact__c');
         soldToOptions.targetId = contacts[0].Id;
         soldToOptions.targetName = contacts[0].Name;
      }
   }
}

 
Hello everyone, I'm new to salesforce and I need solution, any help would be great.
My requirement as- We cannot track history for  opportunity line item, soo i have created a custom object, when opportunity stage is after save change from close won to any, the previous value and new change value show display on custom object's field.
The custom object name is "Adjustment".
please suggest me changes in my code 


trigger trackOppProduct on OpportunityLineItem (after insert,after update) {
    List<Adjustment__c> lstOLIH = new List<Adjustment__c>();
    List<Adjustment__c> lstOLIH1 = new List<Adjustment__c>();
    for (Integer i=0; i < Trigger.new.size(); i++) {        
        if(Trigger.isInsert)
        {
            
            for (OpportunityLineItem objOLI1 : trigger.new){
                Adjustment__c objOLIH1 = new Adjustment__c();            
                objOLIH1.ServiceDate__c = objOLI1.ServiceDate;
                objOLIH1.Discount__c = objOLI1.Discount;
                objOLIH1.Description__c = objOLI1.Description;
                objOLIH1.ListPrice__c = objOLI1.ListPrice;
                objOLIH1.ProductCode__c = objOLI1.ProductCode;
                objOLIH1.Quantity__c = objOLI1.Quantity;
                objOLIH1.UnitPrice__c = objOLI1.UnitPrice;
                objOLIH1.TotalPrice__c = objOLI1.TotalPrice;
                objOLIH1.OpportunityLineItem__c = objOLI1.Id;
                
                lstOLIH1.add(objOLIH1);
            }
            insert lstOLIH1;
        }
        
        else
        {        
            for (OpportunityLineItem objOLI : trigger.old){
                Adjustment__c objOLIH = new Adjustment__c();           
                objOLIH.ServiceDate__c = objOLI.ServiceDate;
                objOLIH.Discount__c = objOLI.Discount;
                objOLIH.Description__c = objOLI.Description;
                objOLIH.ListPrice__c  = objOLI.ListPrice;
                objOLIH.ProductCode__c = objOLI.ProductCode;
                objOLIH.Quantity__c = objOLI.Quantity;
                objOLIH.UnitPrice__c = objOLI.UnitPrice;
                objOLIH.TotalPrice__c = objOLI.TotalPrice;
                objOLIH.OpportunityLineItem__c = objOLI.Id;
                
                lstOLIH.add(objOLIH);
            }
            insert lstOLIH;
        }
    }
}

 
  • November 23, 2019
  • Like
  • 0
Challenge Not yet complete... here's what's wrong:
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: HSJBEABZ
I don't have much experience with Apex so I was wondering if anybody here can help me out.
We have a custom object named OrderLine.  It has data for our Sales Order lines in our ERP which is being Dataloaded every night.  It has Order_Number__c, Account_Number__c and Part_Number__c.  I need a custom field on the QuoteLine object named Sales_Order_Number__c updated when a record in OrderLine is created or edited that meets the following criteria:
OrderLine.AccountNumber = QuoteLine.AccountNumber
OrderLine.PartNumber = QuoteLine.Product (or PartNumber)
OrderLine.CreatedDate > QuoteLine.CreatedDate.

Is this possible?  Thank you.
BillAndPayWrapper(BillingHistoryServiceSet__x billPay, String companyCode) {
            this.postDate      = billPay.PostingDate__c;
            this.invoice      = billPay.InvoiceNo__c;
            this.amount      = billPay.TotalDueAmt__c.setScale(2);
            this.billPeriod  = billPay.BillPeriod__c;

billPeriod is string and BillPeriod__c field under external object is data type text . It is external data and i get it as YYYY/MM. But i need to format it to MM/YYYY
I am completely new to Apex and could really use some help with what seems to be a simple task.  I have a formula on the contact, Persona_True__c, that returns a 1 if the custom field "persona" is populated and a 0 if it is blank.

I would like to have a roll-up summary that sums this field at the account level in a field called Related_Personas__c.  

Because we can't roll-up from contact to account I'm reading that this type of action needs to be a trigger, but I don't even know where to start.  Does anyone have any thoughts or expertise they can share to help me out?