• Andrew Hoban 6
  • NEWBIE
  • 324 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 68
    Questions
  • 108
    Replies
Hi,

I have a lightning web component that when a button is clicked, an apex method is performed to create a record.

After the record is created within apex, is it possible to get the record id of the new record back into the LWC to be used as part of the NavigationMixin?

Any example would be appreciated. 

Thanks
Hi,

I have an apex calss that has a list of records within a custom object. One of the fields within this object is Email_Address__c. There is also a lookup field to Account which is currently null.

Before I insert the custom object records, i need to find the corresponding account record based on email address. If there is an account with the same email address, i need to add the account id to the custom object list to populate the lookup field.

The example below has a list of records within the custom object and list of accounts - ive removed any duplicate accounts that have the same email address.

How would I join these two lists to add the account id to the custom object record?
 
List<Account> accList = [SELECT Id, Name, PersonEmail, CreatedDate, RecordTypeId FROM ACCOUNT];
List<Custom_Object__c> cusObjList = [SELECT Id, Account__c, Email_Address__c FROM Custom_Object__c]; 


Map<String,Account> mapStrByemail=new Map<String,Account>();

for(Account acc:accList){
    mapStrByemail.put(acc.PersonEmail,acc);//only bring back unique emails 
}



 
Hi,

I am getting a CPU Time-Out error message with reference to the trigger below.

The only records I want to be triggered are records that match the IF criteria, however all records will be processed within the loop.

When I add 800 test records that dont even meet the critera, im getting the CPU error.

What would be the best practice to only process the records that meet the criteria beofore entering the loop? 
 
trigger accountTrigger on Account (before insert, before update, after insert, after update) {
    
    if(Trigger.isBefore)
    {
        if(Trigger.isInsert) // Run only BEFORE Insert 
        {
            
            
        }
        
        if(Trigger.isUpdate) // Run only BEFORE update
        {
            
            
        }
        
        if (Trigger.isInsert || Trigger.isUpdate) {

            for(Account acc: Trigger.new){
               

                if (acc.EFCAIS__Status__c != NULL && acc.PersonBirthdate != Null){
                    
                    academyCriteriaHandler.calculateAgeInformationCriteria(Trigger.new, Trigger.oldMap, Trigger.newMap);
                } 
            }
            
        }
    }


 
Hi,

Is there a way, either through apex/process builder, to create a case when a task record is created and populate the newly created case record in the related to field?

 
Hi,

I have created a lightning:datatable that uses the inline edit functionality.

For long text area fields, is it possible to edit the css to allow text on multiple lines?

User-added image
Hi,

I have a Lightning:RecordEditForm that creates a record after the form has been submitted. Once the form has been saved, I require the values on the form to be set back to null, as multiple responses are reuqired without the page refreshing.

I have currently tried giving the lightning:inputField an aura id the setting that value to null within the onSuccess method but the value remains.

I have also tried e.force:refreshView but again the submitted value is present.

Component:
<lightning:recordEditForm aura:id="incidentForm" onsubmit="{!c.onRecordSubmit}" onsuccess="{!c.afterSubmit}" onload="{!c.onLoad}" objectApiName="Case" recordTypeId="0120c000001FwVPAA0">

    <lightning:inputField fieldName="Subject" aura:id="input_Subject" />
    
    <div class="slds-m-top_medium">
        <lightning:button disabled="{!v.disabled}" variant="brand" type="submit" name="save" label="Add" />
    </div>
</lightning:recordEditForm>

Controller:
//Submit Incident
    onRecordSubmit: function(component, event, helper) {        
        event.preventDefault(); // stop form submission
        
        var eventFields = event.getParam("fields");
        component.find('incidentForm').submit(eventFields);
        helper.fireRefreshEvt(component); 
    },

//On Success - After Incident Added 
    afterSubmit : function (component, event, helper) {
        component.find("input_Subject").set("v.value", "");      
        helper.getIncidents(component);
    },

Helper:
fireRefreshEvt : function(component) {
        var refreshEvent = $A.get("e.force:refreshView");
        if(refreshEvent){
            refreshEvent.fire();
        }
    }


 
Hi,

I have a trigger that uses system.today() in multiple if statements. 

I am having difficuly trying to cover this in my test class. One of the statements checks if the current month is either July or August. As im currently testing this in January, it will not be covered.

What is the best way to dynamically cover this scenario?

Thanks,

Trigger (Currnent month is Janurary)
if(System.today().Month() == 7 || System.today().Month() == 8){

}


 
Hi,

I have a trigger that automatically puts a recod for approval. Once the recod has been approved, a field called 'Create Case' is checked and a case is then a case is automatically created.

When creating the test class, the trigger.isinsert has been completed. It is the Trigger.isUpdate that is not been checked by the current test class.

Im not sure if its becasue the recod hasnt been approved, and is currently locked? The test class does not seem to throw any errors however.

Trigger:
 
trigger PassforApproval on Match_Day_Pass__c (after insert, after update) {
  List <Case> caseToInsert = new List <Case>();
   String body = ''; 
        
   if(ApproveProcessAutomationHandler.isFirstTime) {
     ApproveProcessAutomationHandler.isFirstTime =  false;
    
      for (Match_Day_Pass__c MDP : Trigger.New)
        {
      
           if(MDP.Full_Name__c != Null )
            {
                if(Trigger.isInsert){
                                
                //call approval method
                AutomatedApprovalRequest.submitApproval(MDP.id);
               
            
            }

           if(Trigger.isUpdate){
              
           
            if (mdp.Create_Case__c == TRUE && mdp.Case_Created__c == FALSE) {     
  			
            Match_Day_Pass__c newMDP = new Match_Day_Pass__c();            
            newMDP = [SELECT Id FROM Match_Day_Pass__c WHERE Id =: mdp.Id];                
            newMDP.Case_Created__c = TRUE;
                
            Case c = new Case ();
                Contact[] AccountsMatched = [Select id, Name from Contact where Accountid = '001f000000q4IJC'  And Name =:mdp.Full_Name__c  LIMIT 1];
                    if (AccountsMatched.size()>0) {
                        c.contactid = AccountsMatched[0].id;
                   }
            c.recordtypeid = '012f00000000WiV';
            c.Assignee__c = 'Unassigined';
            c.Subject = 'Match Day Pass approved for ' + Trigger.new[0].Full_Name__c;
            c.Description = 'Match Day Pass to be created for: ;
            c.Category_IT_Help_Desk__c = 'Admin and Services';
            c.Category_Detail_IT_Help_Desk__c = 'Matchday Pass';
            c.Ownerid = '00Gf0000000qaDp';
            insert c;
            upsert newMDP;
            }
               
         }

Test Class:
@isTest(SeeAllData = True)
public class PassforApprovalTest {
     static testMethod void PassforApproval(){
        
        Account a = New Account();
         a.Name = 'Test';
          insert a;
         
        Match_Day_Pass__c mdp = new Match_Day_Pass__c();
         mdp.Full_Name__c = 'Test';
         mdp.Create_Case__c = FALSE;
         mdp.Case_Created__c = FALSE;
         mdp.Area__c = 'Other';
         mdp.Type__c = 'Game Specific';
         insert mdp;
       test.startTest();
       
         mdp.Create_Case__c = TRUE;
        mdp.Case_Created__c = FALSE;
         upsert mdp;
         
         Match_Day_Pass__c mdpTest = [SELECT Id, Create_Case__c, Case_Created__c FROM Match_Day_Pass__c WHERE Id=:mdp.Id];
        system.assertEquals(TRUE, mdpTest.Create_Case__c);
        system.assertEquals(FALSE, mdpTest.Case_Created__c);
       system.debug(mdp.Create_case__c);
         Test.stopTest();
         Update mdp;
         Case c = new Case();
          c.recordtypeid = '012f00000000WiV';
           c.Assignee__c = 'Unassigined';
         c.subject = 'Test subject';
          c.description = 'test description';
         c.Category_Detail_IT_Help_Desk__c = 'Test';
         c.Category_Detail_IT_Help_Desk__c = 'Test';
          Insert c;
   
    }
}

 
HI,

I have a trigger on Cases that populates the Contact lookup field by using two fields (Concat_Id__c) in each object as a reference. The logic for this works, however as we have thousands of contact records, I am getting the error message: Non-selective query against large object type (more than 200000 rows)

I have read that using a @future class is a good workaround but have never come across them before.

Woud anyone be able to show me how to use this with my trigger?

Trigger:
trigger UpdateContact on Case (before update) {

for (Case createdCase : Trigger.New) {
            if(createdCase.SuppliedEmail!=null) {
            Case[] Cases = [Select Id,concat_ID__c,SuppliedEmail from Case where SuppliedEmail != Null];
           
                //look for a Contact that matches the email address
                Account[] AccountsMatched = [Select Id,concat_ID__c,PersonEmail, Name from Account where concat_ID__c =:createdCase.concat_ID__c  LIMIT 1];
                //if we found a match, use it
                if (AccountsMatched.size()>0) {
                    createdCase.Contactid = AccountsMatched[0].Id;
                
               }
               
          }
     }
  }

 
Hi,

I have a test class that we have been using for several months without any issues. Now however, when I run the test, it is passing the test, however the trigger remains on 0% code coverage. 

Is there something im missing?

Test Class
@isTest(SeeAllData=true)
public class AutomatedApprovalRequestMedia_Test{

public testmethod static void runTest(){  
 Purchase_Orders__c PO1 = new Purchase_Orders__c(
            Name = 'Test',
            Quantity__c = 4,            
            Price_Ex_VAT__c = 600.00,
            For_Department__c = 'Academy',
            Carriage__c = 400.00,
            Ordered_Date__c = Date.newInstance(2017 , 07 ,15),
            Approved__c = false,
            Ownerid = '005a000000BHKWs',
            recordTypeid = '012a0000001RWi2 );
        
         try
        {
            insert PO1;
                
            AutomatedApprovalRequest.submitApproval(po1.id);
        }
        catch(Exception ee)
      {
            
        }   
        
        }
        }

Trigger
trigger ApproveProcessAutomationMedia on Purchase_Orders__c (after insert, after update) {

 //Media
    if(ApproveProcessAutomationHandler.isFirstTime)
    {
        ApproveProcessAutomationHandler.isFirstTime =  false;
        Purchase_Orders__c PurchaseOrdersMedia = Trigger.new[0];
        //MEDIA
        if((PurchaseOrdersMedia.Ownerid == '005a000000BHKWs' || PurchaseOrdersMedia.Ownerid == '005a000000BGw6l') && PurchaseOrdersMedia.RecordTypeId == '012a0000001RWi2'  &&  PurchaseOrdersMedia.Total_Formula__c >= 250.00 && PurchaseOrdersMedia.Total_Formula__c <= 499.99 && PurchaseOrdersMedia.Approved__c == false)
        {
            //call approval method
            AutomatedApprovalRequest.submitApproval(PurchaseOrdersMedia.id);
        
        }
        //MEDIA
        Else if((PurchaseOrdersMedia.Ownerid == '005a000000BHKWs' || PurchaseOrdersMedia.Ownerid == '005a000000BGw6l') && PurchaseOrdersMedia.RecordTypeId == '012a0000001RWi2'  &&  PurchaseOrdersMedia.Total_Formula__c >= 500.00 && PurchaseOrdersMedia.Approved__c == false)
        {
            //call approval method
            AutomatedApprovalRequest.submitApproval(PurchaseOrdersMedia.id);
        
        }
        //MARKETING
        Else if((PurchaseOrdersMedia.Ownerid == '005a000000BrxOW' || PurchaseOrdersMedia.Ownerid == '005a000000BHKWs' || PurchaseOrdersMedia.Ownerid == '005a000000BryCM' || PurchaseOrdersMedia.Ownerid == '005a000000BrxOb' || PurchaseOrdersMedia.Ownerid == '00530000005jMHi' || PurchaseOrdersMedia.Ownerid == '005a000000BGw6l' || PurchaseOrdersMedia.Ownerid == '00530000004F3oe') && PurchaseOrdersMedia.RecordTypeId == '012a0000001RWi7' && PurchaseOrdersMedia.Total_Formula__c >= 500.00 && PurchaseOrdersMedia.Approved__c == false)
        {
            //call approval method
            AutomatedApprovalRequest.submitApproval(PurchaseOrdersMedia.id);
        
        }
        //PARTNERSHIPS
        Else if(( PurchaseOrdersMedia.Ownerid == '005a000000BGw6l' || PurchaseOrdersMedia.Ownerid == '00530000004F3oe' ) && PurchaseOrdersMedia.RecordTypeId == '012a0000001RX2D' && PurchaseOrdersMedia.Total_Formula__c >= 500.00 && PurchaseOrdersMedia.Approved__c == false)
        {
            //call approval method
            AutomatedApprovalRequest.submitApproval(PurchaseOrdersMedia.id);
        
        }
        
    }   
 
}

 
HI,

I am tryig to rerender differentfields int he same position depinging on a picklist value. This should be in the same page block section. I am having 2 issues with this:

1) The allignment and style is not correct. I have read you have to wrap the output label and input field in a PageBlockSectionItem which i have attempted, but am hving no luck.

2) I cannot rerender the fields to be in the same position as each other. One one of these field will be visiable at a time, so I would like the posisiton to stay the same for each. Whenever i attempt this, One field is in the correct posision and the other is over to the right.

The section on my code is as follows:
 
<apex:pageBlockSectionItem >
                <apex:outputLabel value="Category Detail" for="RegPickList" />  
   <apex:actionRegion >
               <apex:inputField value="{!case.Category_Detail_IT_Help_Desk__c}" required="true">
                       <apex:actionSupport event="onchange" reRender="rerenderLabelChange, RegPickList HardwareAsset, OtherSoftware" />  
                </apex:inputField> 
                  </apex:actionRegion>
                   </apex:pageBlockSectionItem> 
                 <apex:pageBlockSectionItem > 
  </apex:pageBlockSectionItem> 
 
<apex:outputPanel id="rerenderLabelChange" >
<apex:pageBlockSectionItem > 
  <apex:outputLabel value="Hardware Asset" for="HardwareAsset"  rendered="{!case.Category_Detail_IT_Help_Desk__c == 'Laptop'}" />
  <apex:inputField value="{!case.Hardware_Asset__c}" label="Hardware Asset"  id="HardwareAsset" rendered="{!Case.Category_Detail_IT_Help_Desk__c == 'Laptop'}"  /> 

 </apex:pageBlockSectionItem> 
 
 <apex:pageBlockSectionItem > 
  <apex:outputLabel value="Hardware Asset" for="OtherSoftware" rendered="{!case.Category_Detail_IT_Help_Desk__c == 'Other Software'}" />   
    <apex:inputField value="{!case.Other_Software__c}" label="Other Software"  id="OtherSoftware" rendered="{!Case.Category_Detail_IT_Help_Desk__c == 'Other Software'}"   /> 
 </apex:pageBlockSectionItem> 
               
</apex:outputPanel>

 
HI there,

I have a controlller that navigates a user to a specific visualforce page depending on what record type they select.

Does anyone have any examples of what the test class should be?

Thanks

Controller:
public class LeadNewController {

    public LeadNewController(ApexPages.StandardController controller) {
        this.controller = controller;
    }

    public PageReference getRedir() {

        PageReference newPage;

        if (ApexPages.currentPage().getParameters().get('RecordType') == '01230000000WIKN') {
            newPage = Page.PartnershipsLead;
            return newPage.setRedirect(true);
        } 
       else if (ApexPages.currentPage().getParameters().get('RecordType') == '01230000000WIKS') {
            newPage = Page.CorporateSalesLead;
            return newPage.setRedirect(true);
        } 
         else{
            return null;
        }

    }

    private final ApexPages.StandardController controller;
}

 
Hi,

I was wondering if its possible if its possible to rerender multiple page block sections? I would like a new page block section titled "Agent Information" to be displayed when Agency is selected from Lead Source.

Thanks

VF Page:
 
<apex:page standardController="lead">
    <apex:sectionHeader title="Lead Edit" subtitle="{!lead.Name}"/>
    <apex:form >
        <apex:pageBlock title="Lead Edit" mode="edit">

            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Save & New" action="{!save}" />
                <apex:commandButton value="Cancel" action="{!cancel}"/>
            </apex:pageBlockButtons>

 <apex:actionRegion > 
            <apex:pageBlockSection title="Lead Information" columns="2">
                <apex:inputField value="{!lead.Sponsorship_Sectors__c}" required="true"/>
                <apex:inputField value="{!lead.Status}" required="true"/>
                <apex:inputField value="{!lead.Rating}" required="false"/>
                
                <apex:inputField value="{!lead.leadsource}">
                <apex:actionSupport event="onchange" rerender="AgentInfo"/>
                 </apex:inputField>
                <apex:inputField value="{!lead.Sponsorship_Catergory__c}" required="false"/>
            </apex:pageBlockSection>
</apex:actionRegion>

 <apex:outputPanel id="AgentInfo">
 
  <apex:pageBlockSection id="theSection"  columns="1" rendered="{!lead.leadsource != 'Agency'}"> 

            <apex:pageBlockSection title="Lead Contact Information" columns="2">
                <apex:inputField value="{!lead.FirstName}" required="false"/>
                <apex:inputField value="{!lead.Email}" required="true"/>
                <apex:inputField value="{!lead.LastName}" required="true"/>
                <apex:inputField value="{!lead.Phone}" required="true"/>
                <apex:inputField value="{!lead.Company}" required="true"/>
                <apex:inputField value="{!lead.MobilePhone}" required="false"/>
                <apex:inputField value="{!lead.Job_Title__c}" required="false"/>
                <apex:inputField value="{!lead.Direct_Line__c}" required="false"/>
                <apex:inputField value="{!lead.Website}" required="false"/>
                <apex:inputField value="{!lead.LinkedIn_URL__c}" required="false"/>
            </apex:pageBlockSection>


            <apex:pageBlockSection title="Address Information" columns="1">
                <apex:inputField value="{!lead.Street}" required="false"/>
                <apex:inputField value="{!lead.City}" required="false"/>
                <apex:inputField value="{!lead.State}" required="false"/>
                <apex:inputField value="{!lead.PostalCode}" required="false"/>
                <apex:inputField value="{!lead.Country}" required="false"/>
            </apex:pageBlockSection>
            
 </apex:pageBlockSection>

 <apex:pageBlockSection id="theSection1" columns="1" rendered="{!lead.leadsource == 'Agency'}"> 
                
                <apex:pageBlockSection title="Lead Contact Information" columns="2">
                <apex:inputField value="{!lead.FirstName}" required="false"/>
                <apex:inputField value="{!lead.Email}" required="true"/>
                <apex:inputField value="{!lead.LastName}" required="true"/>
                <apex:inputField value="{!lead.Phone}" required="true"/>
                <apex:inputField value="{!lead.Company}" required="true"/>
                <apex:inputField value="{!lead.MobilePhone}" required="false"/>
                <apex:inputField value="{!lead.Job_Title__c}" required="false"/>
                <apex:inputField value="{!lead.Direct_Line__c}" required="false"/>
                <apex:inputField value="{!lead.Website}" required="false"/>
                <apex:inputField value="{!lead.LinkedIn_URL__c}" required="false"/>
            </apex:pageBlockSection>


            <apex:pageBlockSection title="Address Information" columns="1">
                <apex:inputField value="{!lead.Street}" required="false"/>
                <apex:inputField value="{!lead.City}" required="false"/>
                <apex:inputField value="{!lead.State}" required="false"/>
                <apex:inputField value="{!lead.PostalCode}" required="false"/>
                <apex:inputField value="{!lead.Country}" required="false"/>
            </apex:pageBlockSection>

 <apex:pageBlockSection title="Agent Information" columns="1">
                    <apex:inputField value="{!lead.Agency__c}" required="TRUE"/>
                    <apex:inputField value="{!lead.First_Name_Agent__c}" required="TRUE"/> 
                    <apex:inputField value="{!lead.Last_Name_Agent__c}" required="TRUE"/>   
                    <apex:inputField value="{!lead.Phone_Agent__c}" required="TRUE"/>
                    <apex:inputField value="{!lead.Email_Agent__c}" required="TRUE"/>                
                </apex:pageBlockSection>


            <apex:pageBlockSection title="System Information" columns="2">
                <apex:inputField value="{!lead.OwnerId}" required="false"/>
            </apex:pageBlockSection>
            </apex:pageBlockSection>
 </apex:outputPanel> 
        </apex:pageBlock>
    </apex:form>
</apex:page>

 
HI,

Im looking to reate a formula text field that will bring back either 'Yes' or 'No' depending on a date range. If the date falls between 25/15/2105 and 10/05/2016 then it should bring back Yes.

Thanks
Hi all,

I was wondering if its possible for a trigger to automatically create an opportunity product when an opportunity is closed won.

I have an Object related to the opportunity that has fields called Product_Name__c and Total_Price__c.

I would like the trigger to populate these fields into the corresponding fields on the Opportunity Products object.

Thanks
Hi all,


I have created a Salesforce Flow that has been designed for our customers to use on an ipad. Is there a way we can push the flow to be used either through Salesforce1 or pushed outside of salesforce so we can just give a URL? I have embedded my flow in a Visualforce page and created a Global Action but this is not the full screen of the ipad. 

Ideally we need this flow to be through a URL.

Thanks
Hi all,

I have attempted to place an analytics:reportchart into my visualforce page inside apex:tab. After some research i found that this is currently not possible (https://help.salesforce.com/apex/HTViewSolution?id=000212701&language=en_US)

In the resolution, it says to create a visualforce page, place the chart inside then call it with an iframe. 

The issue I have here is that I need to placea filter on the report chart with the AccountID.  The report needs to be dynamic and apply for whatever the account is currently on.


Is there a way to place a filter on the report and call with an iframe?

Thanks
Hi all,

Is it possible to add a requirement/validation on a record to make sure that an atttachment is uplodaed before it is saved?

Thanks
Hi all,

I have created a class and a trigger that calls the class, but now I am struggling to create test classes for these. I was wondering if anyone could help with creating  a test class for these.

Thanks

Class
public class AutomatedApprovalRequest {

    public static void submitApproval(Id id){
    
    //creates a new instance of Approval Process
    Approval.Processsubmitrequest procReq;
    
    //creates a ProcessSubmitRequest object to submit the record for Approval
    procReq = new Approval.Processsubmitrequest();
    
    procReq.setComments('Submitting site set for approval');
    
    //set the record id being submitted to approval
    procReq.setObjectID(id);
    
    //submit the record for approval
    Approval.Processresult result = Approval.process(procReq);
    
    }
    
  }
Trigger
trigger ApproveProcessAutomation on IT_Purchase_Orders__c (after insert, after update) {

  IT_Purchase_Orders__c PurchaseOrders = Trigger.new[0];
        if(PurchaseOrders.Total_Formula__c >= 500.00){
        
        //call approval method
        AutomatedApprovalRequest.submitApproval(PurchaseOrders.id);
               
       
       }
       

}


 
HI all,

I am trying to create a formula text field that will concatonate fileds only if all fields are not blank. At the minute my formula fields just puts them all together regardless of the field values.

Is this possible inside of Salesforce?

My current formula field
First_Name__c & "-" & Last_Name__c & "-" & City__c & "-" & State__c & "-" & Postal_Code__c & "-" & Address1__c & "-" & Mobile_Phone__c
Thanks
 
Hi all,

I was wondering if its possible for a trigger to automatically create an opportunity product when an opportunity is closed won.

I have an Object related to the opportunity that has fields called Product_Name__c and Total_Price__c.

I would like the trigger to populate these fields into the corresponding fields on the Opportunity Products object.

Thanks
Hi all,

is there a formula I can use to rearrange characters in a text value?

The current text value = 890412

The formaula should change to = 12/04/89

Thanks
Hi all,

I have created a trigger that has 75% code coverage. I am unsure how to set an .adderror from my trigger. Dones anyone have a code sample of how this can be achieved?

Thanks

Trigger:
trigger PicklistLimitTrigger on Software_Assets__c(before insert,before update){
Integer count =[select count() from Software_Assets__c where Software_Product__c='Windows 7'];
for(Software_Assets__c a:trigger.new){
if(count==3&&a.Software_Product__c=='Windows 7'){
a.addError('Please chose some other pick-list Values');
}
}
}

Test Class:
@isTest
private class PickListLimitTriggerTest {
    static testMethod void PickListLimitTrigger() {
 Software_Assets__c sa = new Software_Assets__c(Asset_First_Recorded__c = date.today(), Asset_Status__c = 'Operational', Vendor__c = 'Microsoft', Software_Product__c = 'Windows 7');
 
 insert sa;
 
 }
}

 
Hi,

I have a lightning web component that when a button is clicked, an apex method is performed to create a record.

After the record is created within apex, is it possible to get the record id of the new record back into the LWC to be used as part of the NavigationMixin?

Any example would be appreciated. 

Thanks
Hi,

I have an apex calss that has a list of records within a custom object. One of the fields within this object is Email_Address__c. There is also a lookup field to Account which is currently null.

Before I insert the custom object records, i need to find the corresponding account record based on email address. If there is an account with the same email address, i need to add the account id to the custom object list to populate the lookup field.

The example below has a list of records within the custom object and list of accounts - ive removed any duplicate accounts that have the same email address.

How would I join these two lists to add the account id to the custom object record?
 
List<Account> accList = [SELECT Id, Name, PersonEmail, CreatedDate, RecordTypeId FROM ACCOUNT];
List<Custom_Object__c> cusObjList = [SELECT Id, Account__c, Email_Address__c FROM Custom_Object__c]; 


Map<String,Account> mapStrByemail=new Map<String,Account>();

for(Account acc:accList){
    mapStrByemail.put(acc.PersonEmail,acc);//only bring back unique emails 
}



 
Hi,

Is there a way, either through apex/process builder, to create a case when a task record is created and populate the newly created case record in the related to field?

 
Hi,

I have created a lightning:datatable that uses the inline edit functionality.

For long text area fields, is it possible to edit the css to allow text on multiple lines?

User-added image
Hi,

I have a Lightning:RecordEditForm that creates a record after the form has been submitted. Once the form has been saved, I require the values on the form to be set back to null, as multiple responses are reuqired without the page refreshing.

I have currently tried giving the lightning:inputField an aura id the setting that value to null within the onSuccess method but the value remains.

I have also tried e.force:refreshView but again the submitted value is present.

Component:
<lightning:recordEditForm aura:id="incidentForm" onsubmit="{!c.onRecordSubmit}" onsuccess="{!c.afterSubmit}" onload="{!c.onLoad}" objectApiName="Case" recordTypeId="0120c000001FwVPAA0">

    <lightning:inputField fieldName="Subject" aura:id="input_Subject" />
    
    <div class="slds-m-top_medium">
        <lightning:button disabled="{!v.disabled}" variant="brand" type="submit" name="save" label="Add" />
    </div>
</lightning:recordEditForm>

Controller:
//Submit Incident
    onRecordSubmit: function(component, event, helper) {        
        event.preventDefault(); // stop form submission
        
        var eventFields = event.getParam("fields");
        component.find('incidentForm').submit(eventFields);
        helper.fireRefreshEvt(component); 
    },

//On Success - After Incident Added 
    afterSubmit : function (component, event, helper) {
        component.find("input_Subject").set("v.value", "");      
        helper.getIncidents(component);
    },

Helper:
fireRefreshEvt : function(component) {
        var refreshEvent = $A.get("e.force:refreshView");
        if(refreshEvent){
            refreshEvent.fire();
        }
    }


 
Hi,

I have a trigger that automatically puts a recod for approval. Once the recod has been approved, a field called 'Create Case' is checked and a case is then a case is automatically created.

When creating the test class, the trigger.isinsert has been completed. It is the Trigger.isUpdate that is not been checked by the current test class.

Im not sure if its becasue the recod hasnt been approved, and is currently locked? The test class does not seem to throw any errors however.

Trigger:
 
trigger PassforApproval on Match_Day_Pass__c (after insert, after update) {
  List <Case> caseToInsert = new List <Case>();
   String body = ''; 
        
   if(ApproveProcessAutomationHandler.isFirstTime) {
     ApproveProcessAutomationHandler.isFirstTime =  false;
    
      for (Match_Day_Pass__c MDP : Trigger.New)
        {
      
           if(MDP.Full_Name__c != Null )
            {
                if(Trigger.isInsert){
                                
                //call approval method
                AutomatedApprovalRequest.submitApproval(MDP.id);
               
            
            }

           if(Trigger.isUpdate){
              
           
            if (mdp.Create_Case__c == TRUE && mdp.Case_Created__c == FALSE) {     
  			
            Match_Day_Pass__c newMDP = new Match_Day_Pass__c();            
            newMDP = [SELECT Id FROM Match_Day_Pass__c WHERE Id =: mdp.Id];                
            newMDP.Case_Created__c = TRUE;
                
            Case c = new Case ();
                Contact[] AccountsMatched = [Select id, Name from Contact where Accountid = '001f000000q4IJC'  And Name =:mdp.Full_Name__c  LIMIT 1];
                    if (AccountsMatched.size()>0) {
                        c.contactid = AccountsMatched[0].id;
                   }
            c.recordtypeid = '012f00000000WiV';
            c.Assignee__c = 'Unassigined';
            c.Subject = 'Match Day Pass approved for ' + Trigger.new[0].Full_Name__c;
            c.Description = 'Match Day Pass to be created for: ;
            c.Category_IT_Help_Desk__c = 'Admin and Services';
            c.Category_Detail_IT_Help_Desk__c = 'Matchday Pass';
            c.Ownerid = '00Gf0000000qaDp';
            insert c;
            upsert newMDP;
            }
               
         }

Test Class:
@isTest(SeeAllData = True)
public class PassforApprovalTest {
     static testMethod void PassforApproval(){
        
        Account a = New Account();
         a.Name = 'Test';
          insert a;
         
        Match_Day_Pass__c mdp = new Match_Day_Pass__c();
         mdp.Full_Name__c = 'Test';
         mdp.Create_Case__c = FALSE;
         mdp.Case_Created__c = FALSE;
         mdp.Area__c = 'Other';
         mdp.Type__c = 'Game Specific';
         insert mdp;
       test.startTest();
       
         mdp.Create_Case__c = TRUE;
        mdp.Case_Created__c = FALSE;
         upsert mdp;
         
         Match_Day_Pass__c mdpTest = [SELECT Id, Create_Case__c, Case_Created__c FROM Match_Day_Pass__c WHERE Id=:mdp.Id];
        system.assertEquals(TRUE, mdpTest.Create_Case__c);
        system.assertEquals(FALSE, mdpTest.Case_Created__c);
       system.debug(mdp.Create_case__c);
         Test.stopTest();
         Update mdp;
         Case c = new Case();
          c.recordtypeid = '012f00000000WiV';
           c.Assignee__c = 'Unassigined';
         c.subject = 'Test subject';
          c.description = 'test description';
         c.Category_Detail_IT_Help_Desk__c = 'Test';
         c.Category_Detail_IT_Help_Desk__c = 'Test';
          Insert c;
   
    }
}

 
HI,

I have a trigger on Cases that populates the Contact lookup field by using two fields (Concat_Id__c) in each object as a reference. The logic for this works, however as we have thousands of contact records, I am getting the error message: Non-selective query against large object type (more than 200000 rows)

I have read that using a @future class is a good workaround but have never come across them before.

Woud anyone be able to show me how to use this with my trigger?

Trigger:
trigger UpdateContact on Case (before update) {

for (Case createdCase : Trigger.New) {
            if(createdCase.SuppliedEmail!=null) {
            Case[] Cases = [Select Id,concat_ID__c,SuppliedEmail from Case where SuppliedEmail != Null];
           
                //look for a Contact that matches the email address
                Account[] AccountsMatched = [Select Id,concat_ID__c,PersonEmail, Name from Account where concat_ID__c =:createdCase.concat_ID__c  LIMIT 1];
                //if we found a match, use it
                if (AccountsMatched.size()>0) {
                    createdCase.Contactid = AccountsMatched[0].Id;
                
               }
               
          }
     }
  }

 
HI,

I am tryig to rerender differentfields int he same position depinging on a picklist value. This should be in the same page block section. I am having 2 issues with this:

1) The allignment and style is not correct. I have read you have to wrap the output label and input field in a PageBlockSectionItem which i have attempted, but am hving no luck.

2) I cannot rerender the fields to be in the same position as each other. One one of these field will be visiable at a time, so I would like the posisiton to stay the same for each. Whenever i attempt this, One field is in the correct posision and the other is over to the right.

The section on my code is as follows:
 
<apex:pageBlockSectionItem >
                <apex:outputLabel value="Category Detail" for="RegPickList" />  
   <apex:actionRegion >
               <apex:inputField value="{!case.Category_Detail_IT_Help_Desk__c}" required="true">
                       <apex:actionSupport event="onchange" reRender="rerenderLabelChange, RegPickList HardwareAsset, OtherSoftware" />  
                </apex:inputField> 
                  </apex:actionRegion>
                   </apex:pageBlockSectionItem> 
                 <apex:pageBlockSectionItem > 
  </apex:pageBlockSectionItem> 
 
<apex:outputPanel id="rerenderLabelChange" >
<apex:pageBlockSectionItem > 
  <apex:outputLabel value="Hardware Asset" for="HardwareAsset"  rendered="{!case.Category_Detail_IT_Help_Desk__c == 'Laptop'}" />
  <apex:inputField value="{!case.Hardware_Asset__c}" label="Hardware Asset"  id="HardwareAsset" rendered="{!Case.Category_Detail_IT_Help_Desk__c == 'Laptop'}"  /> 

 </apex:pageBlockSectionItem> 
 
 <apex:pageBlockSectionItem > 
  <apex:outputLabel value="Hardware Asset" for="OtherSoftware" rendered="{!case.Category_Detail_IT_Help_Desk__c == 'Other Software'}" />   
    <apex:inputField value="{!case.Other_Software__c}" label="Other Software"  id="OtherSoftware" rendered="{!Case.Category_Detail_IT_Help_Desk__c == 'Other Software'}"   /> 
 </apex:pageBlockSectionItem> 
               
</apex:outputPanel>

 
Hi,

I was wondering if its possible if its possible to rerender multiple page block sections? I would like a new page block section titled "Agent Information" to be displayed when Agency is selected from Lead Source.

Thanks

VF Page:
 
<apex:page standardController="lead">
    <apex:sectionHeader title="Lead Edit" subtitle="{!lead.Name}"/>
    <apex:form >
        <apex:pageBlock title="Lead Edit" mode="edit">

            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Save & New" action="{!save}" />
                <apex:commandButton value="Cancel" action="{!cancel}"/>
            </apex:pageBlockButtons>

 <apex:actionRegion > 
            <apex:pageBlockSection title="Lead Information" columns="2">
                <apex:inputField value="{!lead.Sponsorship_Sectors__c}" required="true"/>
                <apex:inputField value="{!lead.Status}" required="true"/>
                <apex:inputField value="{!lead.Rating}" required="false"/>
                
                <apex:inputField value="{!lead.leadsource}">
                <apex:actionSupport event="onchange" rerender="AgentInfo"/>
                 </apex:inputField>
                <apex:inputField value="{!lead.Sponsorship_Catergory__c}" required="false"/>
            </apex:pageBlockSection>
</apex:actionRegion>

 <apex:outputPanel id="AgentInfo">
 
  <apex:pageBlockSection id="theSection"  columns="1" rendered="{!lead.leadsource != 'Agency'}"> 

            <apex:pageBlockSection title="Lead Contact Information" columns="2">
                <apex:inputField value="{!lead.FirstName}" required="false"/>
                <apex:inputField value="{!lead.Email}" required="true"/>
                <apex:inputField value="{!lead.LastName}" required="true"/>
                <apex:inputField value="{!lead.Phone}" required="true"/>
                <apex:inputField value="{!lead.Company}" required="true"/>
                <apex:inputField value="{!lead.MobilePhone}" required="false"/>
                <apex:inputField value="{!lead.Job_Title__c}" required="false"/>
                <apex:inputField value="{!lead.Direct_Line__c}" required="false"/>
                <apex:inputField value="{!lead.Website}" required="false"/>
                <apex:inputField value="{!lead.LinkedIn_URL__c}" required="false"/>
            </apex:pageBlockSection>


            <apex:pageBlockSection title="Address Information" columns="1">
                <apex:inputField value="{!lead.Street}" required="false"/>
                <apex:inputField value="{!lead.City}" required="false"/>
                <apex:inputField value="{!lead.State}" required="false"/>
                <apex:inputField value="{!lead.PostalCode}" required="false"/>
                <apex:inputField value="{!lead.Country}" required="false"/>
            </apex:pageBlockSection>
            
 </apex:pageBlockSection>

 <apex:pageBlockSection id="theSection1" columns="1" rendered="{!lead.leadsource == 'Agency'}"> 
                
                <apex:pageBlockSection title="Lead Contact Information" columns="2">
                <apex:inputField value="{!lead.FirstName}" required="false"/>
                <apex:inputField value="{!lead.Email}" required="true"/>
                <apex:inputField value="{!lead.LastName}" required="true"/>
                <apex:inputField value="{!lead.Phone}" required="true"/>
                <apex:inputField value="{!lead.Company}" required="true"/>
                <apex:inputField value="{!lead.MobilePhone}" required="false"/>
                <apex:inputField value="{!lead.Job_Title__c}" required="false"/>
                <apex:inputField value="{!lead.Direct_Line__c}" required="false"/>
                <apex:inputField value="{!lead.Website}" required="false"/>
                <apex:inputField value="{!lead.LinkedIn_URL__c}" required="false"/>
            </apex:pageBlockSection>


            <apex:pageBlockSection title="Address Information" columns="1">
                <apex:inputField value="{!lead.Street}" required="false"/>
                <apex:inputField value="{!lead.City}" required="false"/>
                <apex:inputField value="{!lead.State}" required="false"/>
                <apex:inputField value="{!lead.PostalCode}" required="false"/>
                <apex:inputField value="{!lead.Country}" required="false"/>
            </apex:pageBlockSection>

 <apex:pageBlockSection title="Agent Information" columns="1">
                    <apex:inputField value="{!lead.Agency__c}" required="TRUE"/>
                    <apex:inputField value="{!lead.First_Name_Agent__c}" required="TRUE"/> 
                    <apex:inputField value="{!lead.Last_Name_Agent__c}" required="TRUE"/>   
                    <apex:inputField value="{!lead.Phone_Agent__c}" required="TRUE"/>
                    <apex:inputField value="{!lead.Email_Agent__c}" required="TRUE"/>                
                </apex:pageBlockSection>


            <apex:pageBlockSection title="System Information" columns="2">
                <apex:inputField value="{!lead.OwnerId}" required="false"/>
            </apex:pageBlockSection>
            </apex:pageBlockSection>
 </apex:outputPanel> 
        </apex:pageBlock>
    </apex:form>
</apex:page>

 
Hi all,

I was wondering if its possible for a trigger to automatically create an opportunity product when an opportunity is closed won.

I have an Object related to the opportunity that has fields called Product_Name__c and Total_Price__c.

I would like the trigger to populate these fields into the corresponding fields on the Opportunity Products object.

Thanks
Hi all,


I have created a Salesforce Flow that has been designed for our customers to use on an ipad. Is there a way we can push the flow to be used either through Salesforce1 or pushed outside of salesforce so we can just give a URL? I have embedded my flow in a Visualforce page and created a Global Action but this is not the full screen of the ipad. 

Ideally we need this flow to be through a URL.

Thanks
Dear all,

When you click on an "Analytics:reportChart" component on a VF, it will take you to the filtered report, which is great. However, this is actually a problem if the VG page is inline on a record. I'd like to be able to modify the onclick behaviour, so that it takes the parent window to the filtered report. I'm coming across these issues:
  1. Adding an "actionsupport" component seems to make no difference to the behaviour, or break the report
  2. Trying to surround the component with an outputPanel and adding an onClick attribute to that component breaks the report
  3. I'm unsure how to pass in the variables, so the report that gets run will have the right filters applied
The error I'm getting is: "Error while running $A.run() : Cannot read property 'descriptor' of undefined"

Is what I'm trying to do even possible?