• Marketing Marketing 27
  • NEWBIE
  • 20 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 16
    Questions
  • 8
    Replies
This is the 2nd post I've made about this issue with the ReRender Attribute.

My page is using the opportunity standard controller and has an extension with the below Save method I am calling from my commandButton
 
public PageReference Save(){

        try{
            insert TD2nd;
            TD1st.X504_Related_Opportunity__c = TD2nd.Id;
            update TD1st;
            return new Pagereference('https://company--sandboxname.sandbox.lightning.force.com/lightning/r/Opportunity/' + TD2nd.Id +'/view');           
        }
        catch(DmlException d){
            Apexpages.addMessages(d);
            return NULL;
        }
    }

my save button looks like the below:
<apex:pagemessages id="msgs2"/>
             
             <div align="center">
                 <apex:commandButton action="{!Cancel}" value="Cancel"/>
                 <apex:commandButton action="{!Save}" value="Save" reRender="msgs, msgs2"/>
             </div>
I put in the ReRender attribute so that if the user gets validation rules, they won't lost their work. However, when there are no validation rules and the save method executes, I get a grey page with a "Refused to Connect" error message. 

When I exit out of the page, I see that the new opportunity was inserted and everything worked fine, however, ever since I added the Rerender attribute, my save method can no longer navigate to the new opportunity without getting this error. 

What am I doing wrong??
 
I have a VF page that helps users make a specific type of opportunity. The values on the VF page are auto-filled with the values of the opportunity they clicked the button on. 

Some of these values they change and some they leave with their auto-filled value. However, if they click save and the page gets a validation error, then all the fields are reset to their auto-fill values. So the user loses all their work essentially.

How do I make it so that if they get a validation rule, the values don't reset?
I've just made a basic wizard composed of two Visualforce pages. On the second page, users create a new opportunity of a specific type. When they click Save, they are taken to the newly created opportunity.

I would like a basic success message to pop up on this page after they are taken to it.

how can I accomplish this? I will make a lightning web component if I have to but I would rather not :) 

below is my save method on my controller extension
public PageReference Save(){

        try{
            insert TD2nd;
            TD1st.X504_Related_Opportunity__c = TD2nd.Id;
            update TD1st;
            return new Pagereference('/' + TD2nd.Id);           
        }
        catch(DmlException d){
            Apexpages.addMessages(d);
            return NULL;
        }
    }

 
I have a lightning web component that helps users make a record of a custom object by dynamically autofilling a lot of the fields.

I want to override the New button so that they can make the record from the related list on the opportunity page however I know to do that I have to embed it in an Aura Component. 

The main problem with this is that I don't want the aura component to redirect them to a new page. I want it to keep opening up the new record window for the custom object ON the opportunity page.

How can I embed my LWC in an Aura component that will stay on the same page when it is triggered?
Building a lightning web component that allows users to make a new record of a custom object  with much of the field pre-filled.

I am using the NavigationMixin and the encodeDefaultFieldValues methods in my JS file. However I need a way to allow users to select the record type like they would normally do and then navigate to the new record page of that record type after.

how can I get the basic record type selector popup to be part of the lightning component and how can i put the selected record type into the page reference attributes below?
 
this[NavigationMixin.Navigate]({
            type: 'standard__objectPage',
            attributes: {
                objectApiName: 'Annual_Review__c',
                actionName: 'new'
            },
            state:{
                defaultFieldValues : defaultValues
            }
        });

 
I have made a connected app to allow an external vendor access to use one of our Rest Webservices.

I have set the OAuth Scope to Full Access. I only want the vendor to be able to use one Apex Rest Webservice method and he should only have access to edit one custom object. I can't find anywhere in Connected app settings where I can narrow this down like on a permision set or profile. 

How can I accomplish this? Do I need to use Custom Permissions and/or custom attributes?

Thanks.
I have  two classes I'm testing. The first is scheduleBatchJob which implements Schedulable interface. The second is modeSelector which implements Batchable interface.

ModeSelector looks at a bunch of related records for each of the accounts that are processed and updates a text field on each of them.

The debug statements on ModeSelector are showing that it is correctly updating the list of accounts with the correct values but the below test method always shows null for that same updated field every time even when I know it was update with a value. What have I done wrong.k
 
@isTest
    public static void allActiveNoTie(){
        
        Account act = TestDataFactory.getClientAccount('Account');
        TestDataFactory.createBulkDRecords(act.Id, 3, 'Active', 'John M', 500.00);
        TestDataFactory.createBulkLRecords(act.Id, 1, 'Active', 'Bill K', 300.00);
        
        test.startTest();
        
        scheduleBatchJob sj = new scheduleBatchJob();
        String chron = '0 0 13 * * ?';        
        String jobId = system.schedule('Test Sched', chron, sj);        
        CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime
        				  FROM CronTrigger WHERE id = :jobId];
        
        test.stopTest();
        
        system.debug('times fired '+ct.TimesTriggered);
        System.assertEquals(chron, ct.CronExpression);
        Account act2 = [SELECT Id, Name, Fiserv_Resp_Code__c FROM Account 
                                  WHERE Id =: act.Id];
        System.debug('act2 '+act2.Resp_Code__c);
        System.assertEquals(act2.Resp_Code__c, 'John M');

 
I am writing a class that schedules a batchable job and therefor it needs to implement Schedulable and Database.Batchable<Account>

How do I implement more than one interface in a single class? Is this possible, and if so, how is it done?
Just started using VS code and SFDX for development work and am trying to use it to update classes I had previously written in the developer console.

My question is, how can I import just a few select classes into the VS code project without pulling all of them? I know that you can right click on Package XML and click Retrieve Source in Manifest from Org, but that brings in everyting, and I don't want that.

Is there a terminal command that can solve for this?

Thanks
I am making an After Insert Trigger on Campaign Member. A certain method on the Trigger Handler class should fire if the Campaign Name of the Campaign Member is on a list of about 4 different Campaign Names.

When I execute the below method, it is telling me that Cmp.Campaign.Name is NULL. But when I query all Campaign Members in Query Editor, Campaign.Name comes through fine. Why is it doing this and how can I get the name?
 
public static void afterInsert(List<CampaignMember> cmpMembers){
        for(CampaignMember cmp : cmpMembers){
            if(eventList.contains(cmp.Campaign.Name)){

 
Hi, this is my third time trying to get an answer to this question. I am using HTTP Post method to send XML to an external system. 

I know there are many diffferent options for SENDING messages to external systems. Rest, Soap, platform events, etc.

However, I really need to build something for RECEIVING XML messages from the exteranl system I'm sending to.

Can anyone explain how i go about buildind an XML listener for an external system? I'm finding tons of articles about how to send to external systems but basically nothing about how to listen for responses.

Thanks.
Hi, this is my second trying to get an answer to this question. I am using HTTP Post method to send XML to an external system. 

I know there are many diffferent options for SENDING messages to external systems. Rest, Soap, platform events, etc.

However, I really need to build something for RECEIVING XML messages from the exteranl system I'm sending to.

Can anyone explain how i go about buildind an XML listener for an external system? I'm finding tons of articles about how to send to external systems but basically nothing about how to listen for responses.

Thanks.
Hello all,

I am a Junior SF Dev and I have been tasked with integrating with an external system of one of our vendors. I am supposed to send XML strings to their system and receive XML responses from it.

I know how to use Apex to take SF data and convert it to XML, but how do I send and recevie it with their system??

I know it has something to do with the Rest API but I have never connected with an external system and have no idea how to do it in this use case. Can anybody please provide some general guidance on this?

Thanks.
I have a custom VF page that helps users make a certain type of opportunity. It is triggered by a button on the opportunity record page.

I have the <apex:pagemessages /> tag on the custom page and the below try catch block in my controller extension. However, when I intentionally leave fields out to try and trip the validation rule, it doesn't show it. it just redirects me to the original opportunity when I click save.

can someone please tell me what I'm doing wrong?
 
public PageReference Save(){
        
        try{
            insert TD2nd;
            
        }
        catch(System.DmlException e){
            String error = e.getMessage();
            Integer numDML = e.getNumDml();
            system.debug('num dml exceptions: '+numDML);
            ApexPages.addMessages(new ApexPages.message(ApexPages.Severity.ERROR, error));
        }
        
        TD1st.X504_Related_Opportunity__c = TD2nd.Id;
        TD1st.X504_Combined_Amount__c = getCombinedAmount();
        update TD1st;
        PageReference originalOpp = new ApexPages.StandardController(TD2nd).view();
        Return originalOpp;
    }

 
I have a visual force page with two buttons in my Opportunity Page Layout. The buttons are linked to a controller that runs a multipage wizard.

When clicking the button, it should open a new tab with Page 1 of the wizard, but instead it opens in on the opportunity page itself which I don't want.

here is the page:
 
<apex:page standardController="Opportunity" Extensions="create504Controller" tabStyle="Opportunity" sidebar="false"
 lightningStylesheets="true">
  
  <!-- make sure to add syling attributes to the text on this page -->
  
  <h2><Strong>To Create a 504 2nd Trust Deed, Click Here</Strong></h2><br/>
  <apex:form >
      <apex:commandButton action="{!step1}" value="Create 504 2nd TD"/>
      <apex:commandButton action="{!save}" value="Edit 504 2nd TD Details"/>
  </apex:form>
  
  
</apex:page>

Here is the top part of the controller. 
public class create504Controller {

    Opportunity TD1st;
    Opportunity TD2nd;
    String OppId;
    
    public create504Controller(ApexPages.StandardController controller) {
		OppId = controller.getId();
        
        this.TD1st = Database.query(getQueryStatement(1));
    }

    public Opportunity getTD1st(){
        if(TD1st == NULL) TD1st = new Opportunity();
        
        this.TD2nd = Database.query(getQueryStatement(2));
        
        return this.TD1st;
    }
    
    public Opportunity getTD2nd(){
        if(TD2nd == NULL) TD2nd = new Opportunity();
        return this.TD2nd;
    }
    
    public PageReference step1(){
        ApexPages.StandardController sc = new ApexPages.StandardController(this.TD1st);
        return Page.create504pg1;
    }
    
    public PageReference step2(){
        return Page.create504pg2;
    }
    
    public PageReference Finish(){
        
        insert TD2nd;
        update TD1st;
        
        PageReference originalOpp = new PageReference('lightning/r/Opportunity/' + this.TD1st.Id + '/view');
        Return originalOpp;
    }
    
    public PageReference Cancel(){
        
        PageReference originalOpp = new PageReference('lightning/r/Opportunity/' + this.TD1st.Id + '/view');
        Return originalOpp;
    }
    
    public PageReference Edit5042nd(){
        
        PageReference OppTD2nd = new PageReference('lightning/r/Opportunity/' + this.TD2nd.Id + '/view');
        Return OppTD2nd;
    }
    
    
    public static String getQueryStatement(Integer option){
        
        String selectStatement = 'SELECT name, AccountId, Amount'
            		  +'FROM Opportunity ';
       
		
        String whereStatement1st = ' WHERE Id =: OppId LIMIT 1 ';
        String whereStatement2nd = ' WHERE X504_Related_Opportunity__c =: OppId LIMIT 1 ';
        String queryStatement;
        
        If(option == 1){ 
            queryStatement = (selectStatement + whereStatement1st);
        } else if (option == 2){ 
            queryStatement = (selectStatement + whereStatement2nd);
                               }
        System.debug('statement '+queryStatement);
        return queryStatement;
		        
    }
}

What am I doing wrong?
I am Deploying a simple custom object into my production org. When I select "Run Local Tests" I get a bunch of errors for various apex classes that say:

line -1, column -1: Dependent class is invalid and needs recompilation: Class ConfirmProductConversionController : Method does not exist or incorrect signature: void getAccount() from the type UnitTestHelper
Stack Trace: null

This Class UnitTestHelper was recently updated and it is used by a lot of the classes mentioned in these errors. But there are a couple test classes that don't even utilize UnitTestHelper, but they are also getting this error.

There are 14 of these errors all related to To different test classes. How do I fix this, especially with the erros coming from classes that don't even use this method?? Please help.
This is the 2nd post I've made about this issue with the ReRender Attribute.

My page is using the opportunity standard controller and has an extension with the below Save method I am calling from my commandButton
 
public PageReference Save(){

        try{
            insert TD2nd;
            TD1st.X504_Related_Opportunity__c = TD2nd.Id;
            update TD1st;
            return new Pagereference('https://company--sandboxname.sandbox.lightning.force.com/lightning/r/Opportunity/' + TD2nd.Id +'/view');           
        }
        catch(DmlException d){
            Apexpages.addMessages(d);
            return NULL;
        }
    }

my save button looks like the below:
<apex:pagemessages id="msgs2"/>
             
             <div align="center">
                 <apex:commandButton action="{!Cancel}" value="Cancel"/>
                 <apex:commandButton action="{!Save}" value="Save" reRender="msgs, msgs2"/>
             </div>
I put in the ReRender attribute so that if the user gets validation rules, they won't lost their work. However, when there are no validation rules and the save method executes, I get a grey page with a "Refused to Connect" error message. 

When I exit out of the page, I see that the new opportunity was inserted and everything worked fine, however, ever since I added the Rerender attribute, my save method can no longer navigate to the new opportunity without getting this error. 

What am I doing wrong??
 
I have  two classes I'm testing. The first is scheduleBatchJob which implements Schedulable interface. The second is modeSelector which implements Batchable interface.

ModeSelector looks at a bunch of related records for each of the accounts that are processed and updates a text field on each of them.

The debug statements on ModeSelector are showing that it is correctly updating the list of accounts with the correct values but the below test method always shows null for that same updated field every time even when I know it was update with a value. What have I done wrong.k
 
@isTest
    public static void allActiveNoTie(){
        
        Account act = TestDataFactory.getClientAccount('Account');
        TestDataFactory.createBulkDRecords(act.Id, 3, 'Active', 'John M', 500.00);
        TestDataFactory.createBulkLRecords(act.Id, 1, 'Active', 'Bill K', 300.00);
        
        test.startTest();
        
        scheduleBatchJob sj = new scheduleBatchJob();
        String chron = '0 0 13 * * ?';        
        String jobId = system.schedule('Test Sched', chron, sj);        
        CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime
        				  FROM CronTrigger WHERE id = :jobId];
        
        test.stopTest();
        
        system.debug('times fired '+ct.TimesTriggered);
        System.assertEquals(chron, ct.CronExpression);
        Account act2 = [SELECT Id, Name, Fiserv_Resp_Code__c FROM Account 
                                  WHERE Id =: act.Id];
        System.debug('act2 '+act2.Resp_Code__c);
        System.assertEquals(act2.Resp_Code__c, 'John M');

 
Just started using VS code and SFDX for development work and am trying to use it to update classes I had previously written in the developer console.

My question is, how can I import just a few select classes into the VS code project without pulling all of them? I know that you can right click on Package XML and click Retrieve Source in Manifest from Org, but that brings in everyting, and I don't want that.

Is there a terminal command that can solve for this?

Thanks
I am making an After Insert Trigger on Campaign Member. A certain method on the Trigger Handler class should fire if the Campaign Name of the Campaign Member is on a list of about 4 different Campaign Names.

When I execute the below method, it is telling me that Cmp.Campaign.Name is NULL. But when I query all Campaign Members in Query Editor, Campaign.Name comes through fine. Why is it doing this and how can I get the name?
 
public static void afterInsert(List<CampaignMember> cmpMembers){
        for(CampaignMember cmp : cmpMembers){
            if(eventList.contains(cmp.Campaign.Name)){

 
I have a custom VF page that helps users make a certain type of opportunity. It is triggered by a button on the opportunity record page.

I have the <apex:pagemessages /> tag on the custom page and the below try catch block in my controller extension. However, when I intentionally leave fields out to try and trip the validation rule, it doesn't show it. it just redirects me to the original opportunity when I click save.

can someone please tell me what I'm doing wrong?
 
public PageReference Save(){
        
        try{
            insert TD2nd;
            
        }
        catch(System.DmlException e){
            String error = e.getMessage();
            Integer numDML = e.getNumDml();
            system.debug('num dml exceptions: '+numDML);
            ApexPages.addMessages(new ApexPages.message(ApexPages.Severity.ERROR, error));
        }
        
        TD1st.X504_Related_Opportunity__c = TD2nd.Id;
        TD1st.X504_Combined_Amount__c = getCombinedAmount();
        update TD1st;
        PageReference originalOpp = new ApexPages.StandardController(TD2nd).view();
        Return originalOpp;
    }