• MKR
  • NEWBIE
  • 469 Points
  • Member since 2019
  • Solution Architect

  • Chatter
    Feed
  • 15
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 56
    Replies
I am trying to write a trigger on Case object where I am trying to retreive the number of how many contacts have the same email as the email from which the case has originated in the web-to-case scenario. But I am getting the error on the first line itself, the error msg is :

Error: Compile Error: Unexpected token '='. at line 3 column 53

I know the code might not be perfect as I am still learning so I am seeking help, the following is the code I have till now:
trigger CountContact on Case (before insert) 
{
    Case.Count_of_Records_with_Web_email_address__c = [select count() from Contact where Contact.Email = Case.SuppliedEmail];
    
    if (Case.Count_of_Records_with_Web_email_address__c > 1)
    {
        return;
    }
    Else
    {
        Contact Cont = [select Contact from Contact where Contact.Email = Case.SuppliedEmail];
        Case cas;
        cas.Email = Cont.Email;
        cas.Account = Cont.Account;
    }
}

Thanks in advance.

Regards.
Hi guys,

I am relatively new to writing triggers and I am running into an issue with one that I am currently working on. 

I would like to update custom fields in the OpportunityLineItem object with the value from the OpportunityLineItemSchedule.Quantity field. I have 12 custom fields in the OpportunityLineItem for each month of the year, Jan to Dec.

Here is the code that I have so far but I am running into an error "Method does not exist or incorrect signature: void put(Id, Decimal) from the type Map<Id,Integer>" on Line 6.

trigger MapMontsOnSchedule on OpportunityLineItemSchedule (after insert, before update) {
Map<Id,Integer> OpportunityLineItemIdwithOpportunityLineItemScheduleField = new Map<Id, Integer>();
 
    for(OpportunityLineItemSchedule sch:trigger.new)
    {
        OpportunityLineItemIdwithOpportunityLineItemScheduleField.put(sch.OpportunityLineItemId, sch.Quantity);
    }
 
    List<OpportunityLineItem> listUpdatedOpportunityLineItem = new List<OpportunityLineItem>();
 
    for(OpportunityLineItem oli:[Select id, January__c From OpportunityLineItem Where Id IN :OpportunityLineItemIdwithOpportunityLineItemScheduleField.Keyset()])
    {
        if(OpportunityLineItemIdwithOpportunityLineItemScheduleField.containsKey(oli.id))
        {
            listUpdatedOpportunityLineItem.add(new OpportunityLineItem(Id = oli.id, January__c=OpportunityLineItemIdwithOpportunityLineItemScheduleField.get(oli.id)));
        }
    }
    update listUpdatedOpportunityLineItem;
}

 
I have written a Batch Class which is called by a Scheduable class I have written. Im still trying to get my head round tests classes.

I have a test class for the Batch Class. But i dont know how to do write a test class where the schedulable class is calling a Batch Class. This is my Schedule class can someone explain to me what im actually testing for on this one because like I said i fully understand test classes.
 
global class OrderBatchEditScheduler implements Schedulable{
    global void execute(SchedulableContext sc)
    {
       
        OrderDailyBatchEdit b = new OrderDailyBatchEdit();
      
        Database.executebatch(b,200);
    }
   
}

 
When I calculate the age by using DOB and it's not working properly.If I enter date 8/14/2017 and compare age is more than 2 years and condition is not satisfying because i will devide the days with 365.2425 and it showing as result 1.998672115 but I need more than two years for the date i entered because 8/14/2019 to 8/14/2019 is more than 2 years .I calculate the above date as

 public static Boolean above2Years(Date dateOfBirth) {          
Decimal totaldays=
 dateOfBirth != null ? dateOfBirth.daysBetween(system.today()) : 0;
        return (totaldays/365.2425) > 2 ? true : false;
    }
      

Can you please help on this one
Hey guys , I am beginner to salesforce, my reqirement is I have to find the Second Maximum amount of oppurtunity using Soql query,, so what will be the query ??
  • August 12, 2019
  • Like
  • 0
I'm trying to create a very simple Apex trigger that will do different actions on an Opportunity Product deletion, depending on which product it is.
I"m encountering a very basic problem and I'm sure I'm just missing something simple here? any guidance would be greatly appreciated.

Apex Trigger:
trigger OppProdDelete on OpportunityLineItem (after delete) {
     for(OpportunityLineItem prod : Trigger.Old) {
          system.debug('OppProdDelete: Product2.Name=' + prod.Product2.Name); // option 1 - gives me null
         system.debug('OppProdDelete: Product2.Name=' + prod.PricebookEntry.Product2.Name); // option 2 - gives me null
}
I tried both option 1 and 2 above to get the product name so I can take the appropriate actions, but both return NULL. How do I reference the product name?

Thanks,
​​​​​​​Alex
I have the following Apex class and test class that is only getting 15/21 lines covered. The part that is not covered is in bold below. Any ideas how I can get the setter covered in this Apex?

public class changeControlExtension {
    public Infrastructure_Change_Control__c cc {get;set;}
     
    public changeControlExtension(ApexPages.StandardController stdCtrl) {
        cc = (Infrastructure_Change_Control__c)stdCtrl.getRecord();
    }
     
    //get the multi-select pick list values
    public List<SelectOption> getMSPicklist {
        get {
            List<SelectOption> options = new List<SelectOption>();
            for(Schema.PicklistEntry obj : Infrastructure_Change_Control__c.Department_Approvals__c.getDescribe().getPicklistValues()) {
                options.add(new SelectOption(obj.getValue(), obj.getLabel()));
            }
            return options;
        }  
        set;
    }
     
    //get and set the multi-select pick list as checkboxes
    public String[] MSItems {
        get {
            List<String> selected = new List<String>();
            List<SelectOption> options = this.getMSPicklist;
            for(SelectOption obj : options) {
                if (this.cc.Department_Approvals__c !=null && this.cc.Department_Approvals__c.contains(obj.getValue()))
                    selected.add(obj.getValue());
            }
            return selected;
        }
        set {
            String selectedCheckBox = '';
            for(String s : value) {
                if (selectedCheckBox == '')
                    selectedCheckBox += s;
                else selectedCheckBox += ';' + s;
            }
            cc.Department_Approvals__c = selectedCheckBox;

        }
    }
}

Test Class
@isTest
public class changeControlExtension_Test {

    private static testmethod void changeControl() {
     
     Case cas = new Case(Subject = 'Testcase');
     insert cas;
     
     Infrastructure_Change_Control__c cc = new Infrastructure_Change_Control__c(Name = 'Test Change', Related_Case__c = cas.id);
     insert cc;
             
     ApexPages.StandardController controller = new ApexPages.StandardController(cc);
     changeControlExtension extension = new changeControlExtension(controller);
     
     Test.startTest();
     List<SelectOption> options = extension.getMSPicklist;
     cc.Department_Approvals__c = options.get(0).getValue();
     String[] items = extension.MSItems;
     Test.stopTest();
     
     System.assertNotEquals(options.get(0).getValue(), null);
     System.assertNotEquals(items, null);
        
    }

}
Hello Developers,
I'm new at apex development, maybe someone could explain me how write a test for this type of apex class or give me some kind of example ?

public class emailSending {
public string toMail { get; set;}
public string ccMail { get; set;}
public string repMail { get; set;}
    public void sendMail(){
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
string[] to = new string[] {toMail};
string[] cc = new string[] {ccMail};
email.setToAddresses(to);
if(ccMail!=null && ccMail != '')
     email.setCcAddresses(cc);
if(repmail!=null && repmail!= '')
    email.setInReplyTo(repMail);
email.setSubject('Test Mail');
email.setHtmlBody('Hello, <br/><br/>This is the test mail that you generated. <br/>The Email Id for which this mail was generated by '+toMail+'<br/><br/>Regards<br/> Developer');
try{
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { email });
}catch(exception e){
apexpages.addmessage(new apexpages.message(apexpages.severity.error,e.getMessage()));
}
toMail = '';
ccMail = '';
repMail = '';
}
}
I am getting the following error:

Uncaught Error in $A.getCallback() [Cannot read property 'Account__c' of null]

when I try to set a variable in my JS Helper class of my Lightning component.

It occurs at the following lines:
 
console.log('Parent Id is '+parentRecordId);
                component.set('v.addressDetails.Account__c', parentRecordId);

If I look at the console, I can see that parentRecordId is set, and a 
field exists on the object called Account__c. 

Can anyone explain what this error indicates and how to resolve it?

Thanks

Barry 
1.customer__c(master obj) and address__c(detail obj).
address__c has has 2 checkbox field Nagpur__c and Pune__c and customer__c has TextField Hometown__c 
if Nagpur__c is checked, Hometown__c = 'nagpur';
if Pune__c is checked, Hometown__c = 'pune';
2. is it true, that master-detail relation trigger like above wont require query ?
 
Getting System.DMLException in test class for below trigger. Please help me to solve it.

Trigger:- 

trigger OpportunityHowell on Opportunity (after Insert,after Update) {
   
  List<Opportunity> listOpportunitiesToUpdate = new List<Opportunity>();
  Set<Id> allOids = new Set<Id>();
  for(Opportunity o: Trigger.new){
    if(o.Multiplier__c != null && o.Multiplier__c != trigger.oldMap.get(o.id).Multiplier__c){
      allOids.add(o.id);
    }
  }
  listOpportunitiesToUpdate = [select id, (SELECT Id,Dollar_Sales_Howell__c from OpportunityLineItems) from Opportunity where id in :allOids];
  for(Opportunity o:listOpportunitiesToUpdate){
    o.Sum_of_Dollar_Sales_Howell__c = 0;
    for(OpportunityLineItem oli: o.OpportunityLineItems)
    Try{
      o.Sum_of_Dollar_Sales_Howell__c += oli.Dollar_Sales_Howell__c;
      }
    Catch(Exception e)
    {
  }
  if(listOpportunitiesToUpdate.size()>0)   
    update listOpportunitiesToUpdate;    
    }
  }

Test class:-

@isTest
public class OpportunityHowellTest {

    public static testMethod void TestOppty(){
        
         Set<Id> allOids = new Set<Id>();
         MHC2__Project__c p = new MHC2__Project__c(Name='Test Project',MHC2__MHC_Project_Bid_Date__c=System.Today(),MHC2__MHC_Target_Bid_Date__c=System.Today());
        insert p;
        Account a = new Account(Name='Test Account');
        insert a;
        
        Opportunity op = new Opportunity();
        op.Name = 'My Test Opportunity';
        op.Multiplier__c = 2;
        op.Sum_of_Dollar_Sales_Howell__c = 0;
        op.Bid_Date_Time__c = System.Now().addDays(30);
        op.CloseDate = System.Now().addDays(45).date();
        op.StageName = 'Bidding';
        op.AccountId = a.Id;
        op.Bid_Type__c = 'Lump Sum';
        op.Project__c = p.Id;
        insert op;
        
        op.Multiplier__c = 5;
        
        update op;
     
        
       OpportunityLineItem oli = new OpportunityLineItem();
        oli.Quantity = 1.0;
        oli.OpportunityId = op.Id;
        oli.Invoiced__c = false;
        insert oli; 
  }
}

Error:-

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, OpportunityHowell: execution of AfterInsert

caused by: System.NullPointerException: Attempt to de-reference a null object

Trigger.OpportunityHowell: line 6, column 1: []

Hello friends. I have a method that creates records in custom metadata. It works as expected but now I am having a hard time figuring out how to get test coverage for it. 

Initially got an error on the line that enques the deployment via Metadata.Operations.enqueueDeployment which said that metadata cannot be deployed in a test context.

Then I found the suggestion of just skipping that line with a ternary operator, which is the version I have posted here. And that gives me 'Fake Job Id' is not a proper id. Strange that this seems to have worked for other people on that stackexchange post. 

 

At this point I need to seek some advice from those of you that are more experienced. Thanks!!

 

@future
    public static void createCustomMetaData(string acctName, string acctId) {

    string fullname = 'Product_Selection_Search_Parameter.'+acctName.replace(' ','_');    
    // Set up custom metadata to be created in the subscriber org. thanks to https://www.sfdcpanther.com/create-update-custom-metadata-using-apex/
    Metadata.CustomMetadata customMetadata =  new Metadata.CustomMetadata();
    customMetadata.fullName = fullname;
    customMetadata.label = acctName;

    Metadata.CustomMetadataValue typeField = new Metadata.CustomMetadataValue();
    typeField.field = 'Type__c';
    typeField.value = 'Top-Up';
	Metadata.CustomMetadataValue acctField = new Metadata.CustomMetadataValue();
    acctField.field = 'Value__c';
    acctField.value = acctId;

    customMetadata.values.add(typeField);
	customMetadata.values.add(acctField);

    Metadata.DeployContainer mdContainer = new Metadata.DeployContainer();
    mdContainer.addMetadata(customMetadata);

    // Setup deploy callback, MyDeployCallback implements
    // the Metadata.DeployCallback interface 
    CustomMetadataCallback callback = new CustomMetadataCallback();

    // Enqueue custom metadata deployment
    // jobId is the deployment ID
    Id jobId = Test.isRunningTest() ? 'Fake Job Id' : Metadata.Operations.enqueueDeployment(mdContainer, callback);
    }

Here is the test class
@isTest
public with sharing class di_PartnerCreation_Test {
    
    @TestSetup
    static void makeData(){
        TestData_Research_Director director = new TestData_Research_Director();
        director.Construct_Account(new TestData_Research(), true);
        director.Construct_NonStandardPBE(new TestData_Research(), true);
    }

    public static testMethod void testDIPartnerCreationMethods_Act() {
        Account act = [select Id, Name from Account limit 1];
        PriceBook2 pb = [select Id from PriceBook2 where IsStandard = false];

        map<string, string> pbTest = di_PartnerCreation_lcController.getPriceBookOptions(act, 'AUD');
        boolean exProds = di_PartnerCreation_lcController.hasExistingProducts(act.Id);
        di_PartnerCreation_lcController.createProducts(act, 'AUD');
        di_PartnerCreation_lcController.createPriceBookEntries(act, 'AUD', pb.Id);
    }

    public static testMethod void testDIPartnerCreationMethods_NoAct() {

        map<string, string> currencyMap = di_PartnerCreation_lcController.getCurrencies();

    }
}

 
Hi, My apex code is giving the following error; translationStatusUpdate: execution of AfterUpdate caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.translationStatusUpdate: line 28, column 1

Here is the code snippet;
 
trigger translationStatusUpdate on Translation__c (after insert, after update) {
    
    for(Translation__c trans:Trigger.new){
        if(trans.Translation_Status__c != null && trans.Case__c != null){
            //Case[] transCase = [SELECT Id, Translation_Status__c, CaseNumber FROM Case WHERE Id = :trans.Case__r.Id LIMIT 1];
            //String CaseId = transCase.get(Id);
                       
            if(trans.Translation_Status__c == 'Completed'){
                Boolean isComplete = TRUE;
                Translation__c[] otherTransCases = [SELECT Id, Translation_Status__c FROM Translation__c WHERE Case__c = :trans.Case__c AND Id <> :trans.Id];
                for(Translation__c otherTrans:otherTransCases){
                    if(otherTrans.Translation_Status__c <> 'Completed'){
                        isComplete = FALSE;
                        break;
                    }
                }
                if(isComplete){
                    //update new Case(Id = trans.Case__r.Id, Translation_Status__c = 'Completed');
                    trans.Case__r.Translation_Status__c = 'Completed';
                }
            }
            else{
                //update new Case(Id = trans.Case__r.Id, Translation_Status__c = trans.Translation_Status__c);
                trans.Case__r.Translation_Status__c = trans.Translation_Status__c;
            }
        }
    }
}

In general what is the best way to update the field on a parent object based on a child object? The Translation_Status__c field on Translation__c is a Master-Detail relationship.
 
What is the access token expiry duration? (Obtained by user-password flow or jwt flow)
I am dynamically trying to create lightning:recordEditForm by passing record Id, object name, record type id and then rendering fields using iterator.
Because of aura:iteration, all lightning:inputs have same onchange method
I want to find the id of the lightning:input which caused the onchange method to fire.

Code :
 
<lightning:recordEditForm onsubmit="{!c.beforeSave}"
                                  onsuccess="{!c.afterSave}"
                                  recordId="{!v.obj_id}"
                                  recordTypeId="{!v.rec_type_id}"
                                  objectApiName="{!v.obj_name}">
            <lightning:messages />
            <aura:iteration items="{!v.form_field_list}" var="field">
                <lightning:inputField aura:id="{!field.field_api}"
                                      fieldName="{!field.field_api}"
                                      onchange="{!c.handleInputChange}"/>
            </aura:iteration>
            <div class="slds-m-top_medium">
                <lightning:button variant="brand" 
                                  type="submit" name="save" 
                                  label="Save"/>
            </div>
        </lightning:recordEditForm>

 
I am trying to write a trigger on Case object where I am trying to retreive the number of how many contacts have the same email as the email from which the case has originated in the web-to-case scenario. But I am getting the error on the first line itself, the error msg is :

Error: Compile Error: Unexpected token '='. at line 3 column 53

I know the code might not be perfect as I am still learning so I am seeking help, the following is the code I have till now:
trigger CountContact on Case (before insert) 
{
    Case.Count_of_Records_with_Web_email_address__c = [select count() from Contact where Contact.Email = Case.SuppliedEmail];
    
    if (Case.Count_of_Records_with_Web_email_address__c > 1)
    {
        return;
    }
    Else
    {
        Contact Cont = [select Contact from Contact where Contact.Email = Case.SuppliedEmail];
        Case cas;
        cas.Email = Cont.Email;
        cas.Account = Cont.Account;
    }
}

Thanks in advance.

Regards.
Hi Team,

I have the interface mentioned below,
public interface MainInterface {
 
  void bInsert();
  void bUpdate();
  void bDelete();
  void aInsert();
  void aUpdate();
  void aDelete();
  void aUndelete();
 
}
I want to get overall code coverage of 100% for the interface, Any suggestions please?

public class AdjustingSalesPrice {

    public static void UpdateSalesPrice(List<Opportunity> newList) {
        
         try{
            
            Set<Id> oppId = new Set <Id> ();
            
            for(Opportunity op : newList){
                oppId.add(op.Id);
                system.debug('Opportunity id:' +oppId);
            }
            Double Num;
             Double Num3;
             Double Num2;
             Double quantity = 0;
            List<Opportunity> OppList = [SELECT Id, Name, Target_R4WR__c,List_Recurring_4_Week_Rev__c, Upselling__c,Target_Recurring_Discount__c,
                                         (SELECT Id, Torq_One_Time__c, UnitPrice,ListPrice FROM OpportunityLineItems where Torq_One_Time__c = false )
                                         FROM Opportunity WHERE Id=:oppId limit 1];
             
              List<OpportunityLineItem> OliList =  [SELECT id, OpportunityId, UnitPrice, Torq_One_Time__c,Quantity
                                                FROM OpportunityLineItem
                                                WHERE OpportunityId IN :oppId
                                                AND Torq_One_Time__c = False AND UnitPrice > 0];
             
             system.debug('ListSizeof Oppline' +OliList.size());
             for(OpportunityLineItem Oli:OliList){
               Quantity = quantity+Oli.Quantity;
                 Num3 = Quantity;
             }
            system.debug('ListSize of Num3' +Num3);
         
            List<OpportunityLineItem> updateOppOli = new List <OpportunityLineItem>();
            List<Opportunity> updateOpp = new List <Opportunity>();
            
            for(Opportunity opp: OppList){
                
                for(OpportunityLineItem Oli: opp.OpportunityLineItems){
                    
                    System.debug('OpportunityLineItems:' +oli);
                    if(Opp.Upselling__c == True){
                    if(Oli.Torq_One_Time__c == false &&  opp.Target_R4WR__c > opp.List_Recurring_4_Week_Rev__c && Oli.UnitPrice > 0 && Oli.UnitPrice == Oli.ListPrice){
                     Num = opp.Target_R4WR__c - opp.List_Recurring_4_Week_Rev__c; 
                        system.debug('Minus value'+Num);
                     Num2 = Num/Num3;
                        system.debug('divided value'+Num2);
                        Oli.UnitPrice = Num2 + Oli.UnitPrice;
                        updateOppOli.add(Oli);
                      System.debug('UpdateSalesPrice Number of Queries used in this apex code so far: ' + Limits.getQueries()); 
                    }
                    }
                    
                    if(opp.Upselling__c == false){ 
                        if(Oli.Torq_One_Time__c == false &&  opp.Target_R4WR__c == Null && opp.Target_Recurring_Discount__c == Null && Oli.UnitPrice > 0 ){
                        Oli.UnitPrice = Oli.ListPrice;
                        system.debug('Unit Price'+oli.UnitPrice);
                        updateOppOli.add(Oli);
                    
                   system.debug('updateOppOli'+updateOppOli);
                    }
                    }
    }
      }
           
               Map<Id, OpportunityLineItem> Olimap = new Map<Id, OpportunityLineItem>();
            Olimap.putAll(updateOppOli);
           
            if(Olimap.size() > 0){
                update Olimap.values();
                system.debug(Olimap.size()+' Opportunity Line Items Updated sucessfully: '+Olimap.values());
            }
         }
        catch(Exception e){
            System.debug('Exception Occured::'+e.getMessage());
        }
}
}
Hi,

I'm getting System.TypeException: Invalid conversion from runtime type List<ANY> to Map<String,ANY> error in Test Class. The response body that I have created is res.setBody('[{"attributes": {"type": "Account"},"name": "test"}]');
 This is the line of the main class where test class throws error.
Map<String, object> o = (Map<String, object>) JSON.deserializeUntyped(input);
Any help would be appreciated.
Thanks!!
Hello,

could some one help me in parsing the below json,

{
"d": {
"results": [
{
"__metadata": {
"id": "https://testasugo.sharepoint.com/_api/Web/GetFolderByServerRelativePath(decodedurl='/Shared Documents/Salesforce/Salesforcetwo')",
"uri": "https://testasugo.sharepoint.com/_api/Web/GetFolderByServerRelativePath(decodedurl='/Shared%20Documents/Salesforce/Salesforcetwo')",
"type": "SP.Folder"
},
"Name": "Salesforcetwo"
},
{
"__metadata": {
"id": "https://testasugo.sharepoint.com/_api/Web/GetFolderByServerRelativePath(decodedurl='/Shared Documents/Salesforce/sub Salesforce')",
"uri": "https://testasugo.sharepoint.com/_api/Web/GetFolderByServerRelativePath(decodedurl='/Shared%20Documents/Salesforce/sub%20Salesforce')",
"type": "SP.Folder"
},
"Name": "sub Salesforce"
}
]
}
}


if i am using deserialization as i cannot use __metadata variable i am always getting null,could you help me in getting the value of __metadata in apex
I need to know if there is  any way i can access user license expiration date through query or with some api?
Hi,

I hit the First error: [null] AsyncApexExecutions Limit exceeded and now I can't start batches on the full sandbox because of It. I read that this is 24h limit so I waited for a day (week atm). Unfortunately, It didn't help. Is there a way to fix the sandbox?
User has edit access on the Territory2 standard field on opportunity. But the change link is not appearing to change the value. Admins can do it but other users do not see the change link to change the territory on opportunity.
Hi guys,

I am relatively new to writing triggers and I am running into an issue with one that I am currently working on. 

I would like to update custom fields in the OpportunityLineItem object with the value from the OpportunityLineItemSchedule.Quantity field. I have 12 custom fields in the OpportunityLineItem for each month of the year, Jan to Dec.

Here is the code that I have so far but I am running into an error "Method does not exist or incorrect signature: void put(Id, Decimal) from the type Map<Id,Integer>" on Line 6.

trigger MapMontsOnSchedule on OpportunityLineItemSchedule (after insert, before update) {
Map<Id,Integer> OpportunityLineItemIdwithOpportunityLineItemScheduleField = new Map<Id, Integer>();
 
    for(OpportunityLineItemSchedule sch:trigger.new)
    {
        OpportunityLineItemIdwithOpportunityLineItemScheduleField.put(sch.OpportunityLineItemId, sch.Quantity);
    }
 
    List<OpportunityLineItem> listUpdatedOpportunityLineItem = new List<OpportunityLineItem>();
 
    for(OpportunityLineItem oli:[Select id, January__c From OpportunityLineItem Where Id IN :OpportunityLineItemIdwithOpportunityLineItemScheduleField.Keyset()])
    {
        if(OpportunityLineItemIdwithOpportunityLineItemScheduleField.containsKey(oli.id))
        {
            listUpdatedOpportunityLineItem.add(new OpportunityLineItem(Id = oli.id, January__c=OpportunityLineItemIdwithOpportunityLineItemScheduleField.get(oli.id)));
        }
    }
    update listUpdatedOpportunityLineItem;
}

 
I have written a Batch Class which is called by a Scheduable class I have written. Im still trying to get my head round tests classes.

I have a test class for the Batch Class. But i dont know how to do write a test class where the schedulable class is calling a Batch Class. This is my Schedule class can someone explain to me what im actually testing for on this one because like I said i fully understand test classes.
 
global class OrderBatchEditScheduler implements Schedulable{
    global void execute(SchedulableContext sc)
    {
       
        OrderDailyBatchEdit b = new OrderDailyBatchEdit();
      
        Database.executebatch(b,200);
    }
   
}

 
Hi,
I'm trying to create a connection between our Org and a third party system through the SOAP API. Are there any practical examples of this? (I've done the trailheads but they haven't given many practical examples).

I need a button to call the third-party web services through SOAP API, search and retrieve results then populate fields on the salesforce record the button is clicked from.

Can anyone show working practical code which I can amend for us?

Any help is much appreciated!
Many thanks,
Natasha :)
When I calculate the age by using DOB and it's not working properly.If I enter date 8/14/2017 and compare age is more than 2 years and condition is not satisfying because i will devide the days with 365.2425 and it showing as result 1.998672115 but I need more than two years for the date i entered because 8/14/2019 to 8/14/2019 is more than 2 years .I calculate the above date as

 public static Boolean above2Years(Date dateOfBirth) {          
Decimal totaldays=
 dateOfBirth != null ? dateOfBirth.daysBetween(system.today()) : 0;
        return (totaldays/365.2425) > 2 ? true : false;
    }
      

Can you please help on this one


<apex:page standardController="Account" >
    <apex:form>
        <apex:sectionHeader title="Person Customer Edit" subtitle="New Customer"/>
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!cancel}" value="cancel"/>
                </apex:pageBlockButtons>
            </apex:pageBlock>
        <apex:pageBlock>
<apex:pageBlockSection>
    <apex:pageBlockSectionItem>
<apex:outputlabel value="First Name"/>
<apex:outputpanel>
<apex:inputText value="{!salutation}" id="personSalutation"/>
<apex:inputText value="{!fname}" id="personFname"/>
</apex:outputpanel>
        </apex:pageBlockSectionItem>
</apex:pageBlockSection>
            </apex:pageBlock>
    <apex:pageBlock>
        <apex:pageBlockSection>
<apex:pageBlockSectionItem>
<apex:outputLabel value="Last Name" for="personLname"></apex:outputLabel>
<apex:inputText value="{!lname}" id="personLname"/>
</apex:pageBlockSectionItem>
           </apex:pageBlockSection> 
            </apex:pageBlock>
    </apex:form>
</apex:page>

this is my code which i was unable to do.
My Error: Unknown property 'AccountStandardController.salutation'
Hey guys , I am beginner to salesforce, my reqirement is I have to find the Second Maximum amount of oppurtunity using Soql query,, so what will be the query ??
  • August 12, 2019
  • Like
  • 0
Hi Guys,
can I get the details of Bulk upload jobs? I see in docs we can use REST API to get the Id and details like "/services/data/v45.0/jobs/ingest".
Is it possible to programmatically use this to fetch the number of records failed?
 
I have a requirement that for an account there should be unique email id for every related contact. But in my code it is not working as per the requirement, it is checking all the contacts irrespective of Account. 
But I need to check only Account related contacts email id's.Here is my code please help me where I am doing wrong.

trigger ContactTrigger on Contact (before insert,before update)
 {
   
  set<ID> accId = new set<ID>();
   list<string> ContactEmails=new list<string>();
    for(Contact conVar:trigger.new)
    {
        ContactEmails.add(conVar.email);
        accId.add(conVar.AccountId);
    }
    
    system.debug('ContactEmails ************' +ContactEmails);
    
    list<Contact> listOfDuplicateContacts=[select id,email,Account.ID from Contact where email in :ContactEmails AND AccountID IN : accId];
      system.debug('listOfDuplicateContacts ************' +listOfDuplicateContacts);
    
    for(Contact con:trigger.new)
    {
        if(trigger.isInsert){
        if(listOfDuplicateContacts.size()!=0)
        {
            con.addError('Contact email already exists with this name');
        }
        }
        if(trigger.isUpdate)
        {
           for(Contact oldContact :trigger.old)
           {
               if(con.Email!=oldContact.Email && listOfDuplicateContacts.size()!=0)
               {
                   con.addError('Contact email already exists with this name');
               }
           }
        }
    }
}
  • August 12, 2019
  • Like
  • 0
Hi All

I have setup a Sharepoint Online integration via the Files Connector which works great except I can't retrieve the ParentId__c of any of the objects returned. I can however filter on the ParentId__c field.

How do I get a populated ParentId__c field in my query results?

Example:
SELECT Id, Name__c, IsFolder__c, ParentId__c FROM items_Sharepoint_Online__x
This returns a set of results, but ParentId__c is empty for every row.

Example:
SELECT Id, Name__c, IsFolder__c, ParentId__c FROM items_Sharepoint_Online__x WHERE ParentId__c = 'xxx'
This correctly returns the child items of 'xxx' (but the ParentId__c returned in the results is still blank!)

Any help, much appreciated.

Thanks


 
  • August 05, 2015
  • Like
  • 0