function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Steve Gilbert 13Steve Gilbert 13 

VF page to Receive Data From Chronicall

Working on getting this up and running but I ran into an error with the VF page. I have checked for hidden characters and formatting but just can’t seem to find why I am getting the errors below:
 
VF Page to be created:
 
<apex:page controller="ChronicallRecordingAPI" action="{!init}" showHeader="false" standardStylesheets="false">
 
    <flow:interview name="Chronicall_Recording_Link_API">
         <apex:param name="externallistenlink" value="{!externallistenlink}"/>
         <apex:param name="callid" value="{!callid}"/>
         <apex:param name="agent" value="{!agent}"/>
         <apex:param name="callDirection" value="{!callDirection}"/>
         <apex:param name="externalNumber" value="{!externalNumber}"/>
         <apex:param name="callgroup" value="{!callgroup}"/>
         <apex:param name="calltime" value="{!calltime}"/>
         <apex:param name="calltag" value="{!calltag}"/>
     </flow:interview>
</apex:page>
 
 
public class ChronicallRecordingAPI {
 
    public string externallistenlink {get; set;}
    public string callid{get; set;}
    public string agent{get; set;}
    public string callDirection{get; set;}
    public string externalNumber{get; set;}
    public string callgroup{get; set;}
    public string calltime{get; set;}
    public string calltag{get; set;}
 
    public PageReference init() {
    if ( ApexPages.currentPage().getParameters().get('externallistenlink') != null )
         externallistenlink = ApexPages.currentPage().getParameters().get('externallistenlink');
         
    if ( ApexPages.currentPage().getParameters().get('callid') != null )
         callid = ApexPages.currentPage().getParameters().get('callid');
 
    if ( ApexPages.currentPage().getParameters().get('agent') != null )
         agent = ApexPages.currentPage().getParameters().get('agent');
    
    if ( ApexPages.currentPage().getParameters().get('callDirection') != null )
         callDirection = ApexPages.currentPage().getParameters().get('callDirection');
        
    if ( ApexPages.currentPage().getParameters().get('externalNumber') != null )
         externalNumber = ApexPages.currentPage().getParameters().get('externalNumber');        
 
    if ( ApexPages.currentPage().getParameters().get('group') != null )
         callgroup = ApexPages.currentPage().getParameters().get('group');                                    
 
    if ( ApexPages.currentPage().getParameters().get('time') != null )
         calltime = ApexPages.currentPage().getParameters().get('time');
 
    if ( ApexPages.currentPage().getParameters().get('tag') != null )
         calltag = ApexPages.currentPage().getParameters().get('tag');
        
        return null;
    }
}
 
 
Errors that I am getting:
 

User-added image
 
I’ll be digging here as well but any help would be great.

Thanks
 
Best Answer chosen by Steve Gilbert 13
SidhantSidhant
@isTest
private class ChronicallRecordingAPI_Test{
    @isTest
    private static void externalLinkTest() {
        PageReference myVfPage = Page.ChronicallRecording; // replace ChronicallRecording with your current page name
        Test.setCurrentPageReference(myVfPage);
        ApexPages.currentPage().getParameters().put('externallistenlink','http://google.com');     
        ChronicallRecordingAPI controller = new ChronicallRecordingAPI();
        
        Test.startTest();
        controller.init();
        Test.stopTest();
    }
}


You need to update line 5 with your page name.

Since your logic has multiple if blocks, we need to cover all the if blocks.

You need to save this code into a new Apex Class.

All Answers

SidhantSidhant
You need to save the page, the code between"<apex:page> ... </apex:page>" tags and the Apex Class separately.
Steve Gilbert 13Steve Gilbert 13
Thanks, so 2 seperate VF pages?
SidhantSidhant

No, 1 Apex Class, 1 VF Page.

1. First, you'll have to save the controller/apex class:

This goes into New Apex Class, although this may give you some errors but try to save it, you can post the error here so we can fix it/hit me up sidhant.sa at gmail dot com:

public class ChronicallRecordingAPI {
 
    public string externallistenlink {get; set;}
    public string callid{get; set;}
    public string agent{get; set;}
    public string callDirection{get; set;}
    public string externalNumber{get; set;}
    public string callgroup{get; set;}
    public string calltime{get; set;}
    public string calltag{get; set;}
 
    public PageReference init() {
    if ( ApexPages.currentPage().getParameters().get('externallistenlink') != null )
         externallistenlink = ApexPages.currentPage().getParameters().get('externallistenlink');
         
    if ( ApexPages.currentPage().getParameters().get('callid') != null )
         callid = ApexPages.currentPage().getParameters().get('callid');
 
    if ( ApexPages.currentPage().getParameters().get('agent') != null )
         agent = ApexPages.currentPage().getParameters().get('agent');
    
    if ( ApexPages.currentPage().getParameters().get('callDirection') != null )
         callDirection = ApexPages.currentPage().getParameters().get('callDirection');
        
    if ( ApexPages.currentPage().getParameters().get('externalNumber') != null )
         externalNumber = ApexPages.currentPage().getParameters().get('externalNumber');        
 
    if ( ApexPages.currentPage().getParameters().get('group') != null )
         callgroup = ApexPages.currentPage().getParameters().get('group');                                    
 
    if ( ApexPages.currentPage().getParameters().get('time') != null )
         calltime = ApexPages.currentPage().getParameters().get('time');
 
    if ( ApexPages.currentPage().getParameters().get('tag') != null )
         calltag = ApexPages.currentPage().getParameters().get('tag');
        
        return null;
    }
}

 

2. This goes into VF page, let's name it ChronicallRecording:

<apex:page controller="ChronicallRecordingAPI" action="{!init}" showHeader="false" standardStylesheets="false">
 
    <flow:interview name="Chronicall_Recording_Link_API">
         <apex:param name="externallistenlink" value="{!externallistenlink}"/>
         <apex:param name="callid" value="{!callid}"/>
         <apex:param name="agent" value="{!agent}"/>
         <apex:param name="callDirection" value="{!callDirection}"/>
         <apex:param name="externalNumber" value="{!externalNumber}"/>
         <apex:param name="callgroup" value="{!callgroup}"/>
         <apex:param name="calltime" value="{!calltime}"/>
         <apex:param name="calltag" value="{!calltag}"/>
     </flow:interview>
</apex:page>
 
 

Steve Gilbert 13Steve Gilbert 13
I went to the developer console and when I entered the 1st section I get the "can't alter metadata in an active org" error.. 
SidhantSidhant

That is because you are trying to make changes in production. You need to save all your code into Sandbox first.

Then, after saving you need to write a test class for the controller to make sure the coverage is above 75%.

Then you can push the Apex Class and VF Page into production using outbound ChangeSets.

Steve Gilbert 13Steve Gilbert 13
ok thanks.. it's been years since I have done anything like this.. thanks
Steve Gilbert 13Steve Gilbert 13
Thanks for the help. It seems that the only error I am seeing is on the VF page "Unknown method 'ChronicallRecordingAPI.init()'"
Steve Gilbert 13Steve Gilbert 13
OK, I have moved it to prod and am waiting for the apex test to finsih.. 
 
Steve Gilbert 13Steve Gilbert 13
Trying the deployment in prod and the only error I am getting is

System.AssertException: Assertion Failed: Expected: 0, Actual: 3 
Stack Trace: Class.DeleteBatchTest.attachmentsDeletionTest: line 33, column 1

 
SidhantSidhant

I can think of two possible paths forward at this moment:

1. Either you can fix this test class by refactoring and debugging, which is the best practice. Then, you need to create a new Outbound changeset having elements of the previous changeset and this test class and deploy.

2. Or, assuming you completed your test class with >75% coverage of Controller class, you can use "Run specified tests" options while deploying in the production environment. This option is given when you click on "Deploy" button on Inbound Change Set.

 

Steve Gilbert 13Steve Gilbert 13
ok. lets see what I can do
 
Steve Gilbert 13Steve Gilbert 13
OK lets see what I can do.. i Steve Gilbert ATI Salesforce Administrator Office: 301-575-9131 sgilbert@autotraining.net
Steve Gilbert 13Steve Gilbert 13
I am rather new at this so I will have lots of questions... in the sandbox when I ran all the test I am showing that for the public class ChronicallRecordingAPI { there is a "Code Coverage: None" should that be the case?
 
Steve Gilbert 13Steve Gilbert 13
Back in the sandbox dev console the total code coverage for the public class ChronicallRecordingAPI { is showing “None” Steve Gilbert ATI Salesforce Administrator Office: 301-575-9131 sgilbert@autotraining.net
SidhantSidhant

No problem, we are all learners.

I suspect you have not created a test class for controller class:

public class ChronicallRecordingAPI {
 
    public string externallistenlink {get; set;}
    public string callid{get; set;}
    public string agent{get; set;}
    public string callDirection{get; set;}
    public string externalNumber{get; set;}
    public string callgroup{get; set;}
    public string calltime{get; set;}
    public string calltag{get; set;}
 
    public PageReference init() {
    if ( ApexPages.currentPage().getParameters().get('externallistenlink') != null )
         externallistenlink = ApexPages.currentPage().getParameters().get('externallistenlink');
         
    if ( ApexPages.currentPage().getParameters().get('callid') != null )
         callid = ApexPages.currentPage().getParameters().get('callid');
 
    if ( ApexPages.currentPage().getParameters().get('agent') != null )
         agent = ApexPages.currentPage().getParameters().get('agent');
    
    if ( ApexPages.currentPage().getParameters().get('callDirection') != null )
         callDirection = ApexPages.currentPage().getParameters().get('callDirection');
        
    if ( ApexPages.currentPage().getParameters().get('externalNumber') != null )
         externalNumber = ApexPages.currentPage().getParameters().get('externalNumber');        
 
    if ( ApexPages.currentPage().getParameters().get('group') != null )
         callgroup = ApexPages.currentPage().getParameters().get('group');                                    
 
    if ( ApexPages.currentPage().getParameters().get('time') != null )
         calltime = ApexPages.currentPage().getParameters().get('time');
 
    if ( ApexPages.currentPage().getParameters().get('tag') != null )
         calltag = ApexPages.currentPage().getParameters().get('tag');
        
        return null;
    }
}

You may want to refer this example provided by Salesforce: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_error_handling.htm

 

Steve Gilbert 13Steve Gilbert 13
ok well I get to learn how to write a controller tonight
Steve Gilbert 13Steve Gilbert 13
Well then I get to try to write my first test class tonight then.. Steve Gilbert ATI Salesforce Administrator Office: 301-575-9131 sgilbert@autotraining.net
SidhantSidhant

Haha! Nice, message me if you are stuck! I'm in Mountain Time.

Best,

Sid

Steve Gilbert 13Steve Gilbert 13
Thanks and for some reason I cannot answer in the group. Goes to an Under construction screen… I was finally able to pull up the test class that you provided.. thanks Steve Gilbert ATI Salesforce Administrator Office: 301-575-9131 sgilbert@autotraining.net
Steve Gilbert 13Steve Gilbert 13
So far I have not gotten one to save so going back to the drawing board..
 
Steve Gilbert 13Steve Gilbert 13
public class ChronicallRecordingAPI {
 
    public string externallistenlink {get; set;}
    public string callid{get; set;}
    public string agent{get; set;}
    public string callDirection{get; set;}
    public string externalNumber{get; set;}
    public string callgroup{get; set;}
    public string calltime{get; set;}
    public string calltag{get; set;}
 
    public PageReference init() {
    if ( ApexPages.currentPage().getParameters().get('externallistenlink') != null )
         externallistenlink = ApexPages.currentPage().getParameters().get('externallistenlink');
         
    if ( ApexPages.currentPage().getParameters().get('callid') != null )
         callid = ApexPages.currentPage().getParameters().get('callid');
 
    IF ( ApexPages.currentPage().getParameters().get('agent') != null )
         agent = ApexPages.currentPage().getParameters().get('agent');
    
    if ( ApexPages.currentPage().getParameters().get('callDirection') != null )
         callDirection = ApexPages.currentPage().getParameters().get('callDirection');
        
    if ( ApexPages.currentPage().getParameters().get('externalNumber') != null )
         externalNumber = ApexPages.currentPage().getParameters().get('externalNumber');        
 
    if ( ApexPages.currentPage().getParameters().get('group') != null )
         callgroup = ApexPages.currentPage().getParameters().get('group');                                    
 
    if ( ApexPages.currentPage().getParameters().get('time') != null )
         calltime = ApexPages.currentPage().getParameters().get('time');
 
    if ( ApexPages.currentPage().getParameters().get('tag') != null )
         calltag = ApexPages.currentPage().getParameters().get('tag');
        
        return null;
    }
}
SidhantSidhant
@isTest
private class ChronicallRecordingAPI_Test{
    @isTest
    private static void externalLinkTest() {
        PageReference myVfPage = Page.ChronicallRecording; // replace ChronicallRecording with your current page name
        Test.setCurrentPageReference(myVfPage);
        ApexPages.currentPage().getParameters().put('externallistenlink','http://google.com');     
        ChronicallRecordingAPI controller = new ChronicallRecordingAPI();
        
        Test.startTest();
        controller.init();
        Test.stopTest();
    }
}


You need to update line 5 with your page name.

Since your logic has multiple if blocks, we need to cover all the if blocks.

You need to save this code into a new Apex Class.

This was selected as the best answer
Steve Gilbert 13Steve Gilbert 13
I can't thank you enough. I ran the test to success. Should the Code Coverage still show None?
SidhantSidhant

No worries. This should add some coverage to the class ~45%

Steve Gilbert 13Steve Gilbert 13
Just awesome in the help that I was provided thanks
Steve Gilbert 13Steve Gilbert 13
sorry to come back to this but we had to update the version and now I need to pull the URL's for these pages. I thought I had them only to get an error. any ideas.. thanks
SidhantSidhant

That's okay!

Can you provide more info, sorry, I didn't get the context.

What URL are we talking about?

Steve Gilbert 13Steve Gilbert 13
may have it so I will let you know... thanks