• Praenei
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 4
    Replies
Hi.

This shouldn't be difficult but not found a way to solve it.

The user requirement is for a quick action button to appear on one of our custom objects.  If user clicks it then a csv file will be generated containing the email addresses of contacts linked to the custom object.  The problem I have is that after the user clicks the quick action button the csv file is generated but the VFP (blank screen) stays open. I ideally want this to disappear.

Controller (ExportCaseReportEmailsCtrl)
public with sharing class ExportCaseReportEmailsCtrl {
    
    public List<case_contact__c> contactDetails {get; set;}
    
    public ExportCaseReportEmailsCtrl(ApexPages.StandardController controller) {
        getContactDetails();
    }
    
    public PageReference getContactDetails(){
        
        contactDetails = [select id, contact__r.name, contact__r.account.name, contact__r.email 
                                 from case_contact__c 
                                 where Case_Number__c in 
                                 (select case_number__c 
                                  from case_report_Code__c 
                                  where report_code__r.id = :ApexPages.currentPage().getParameters().get('id')
                                 )
                                 and contact__r.email != null];
        return new PageReference('');
    }
    
}
VFP :-
<apex:page standardController="report_code__c" extensions="ExportCaseReportEmailsCtrl" cache="true" contentType="text/csv#reportCodeEmails.csv;charset=utf8" language="en-US">"Name2","Client","Email"
<apex:repeat value="{!contactDetails}" var="a">
"{!a.contact__r.name}","{!a.contact__r.account.name}","{!a.contact__r.email}"
</apex:repeat>
</apex:page>
Screenshot of VFP remaining open
Screenshot of VFPThanks
 
Hi all & thanks for taking the time to read this.

I'm working on a project which requires a rest api call to an external site.  As the external company haven't completed their work yet I thought I'd get ahead of the curve & write a simulation of their code on one of our sanboxes so I can test my code which is running in another sandbox.  However I get a [Status=Bad Request, StatusCode=400] response when requesting an authorisation code before I even get to the point of the real request.  I can boil down this request down to (where the client_id etc. obviously have the correct values):-
 
HttpRequest req = new HttpRequest();
Http http = new Http();
String authUrl = 'https://test.salesforce.com/services/oauth2/token?grant_type=refresh_token' +
                            '&client_id=' + 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXX' +
                            '&client_secret=' + 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYY' +
                            '&refresh_token=' + 'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ';

string reqBody = 'sss';

req.setHeader('Content-Type', 'application/json;charset=UTF-8');

req.setMethod('POST');
req.setEndpoint(authUrl);
system.debug(authUrl);


HTTPResponse resp = http.send(req);
system.debug(resp);
Bizarrelyif I log in to workbench using the sandbox that is sending the request & go to the Rest Explorer & use the value in the variable authUrl without the https://test.salesforce.com (so starting /services/oauth2/token?grant_type=refresh_token...) it works fine.

Any suggestions as this is driving me crazy?  

Thanks for any help you can offer.

Praenei
 
Hi.

This shouldn't be difficult but not found a way to solve it.

The user requirement is for a quick action button to appear on one of our custom objects.  If user clicks it then a csv file will be generated containing the email addresses of contacts linked to the custom object.  The problem I have is that after the user clicks the quick action button the csv file is generated but the VFP (blank screen) stays open. I ideally want this to disappear.

Controller (ExportCaseReportEmailsCtrl)
public with sharing class ExportCaseReportEmailsCtrl {
    
    public List<case_contact__c> contactDetails {get; set;}
    
    public ExportCaseReportEmailsCtrl(ApexPages.StandardController controller) {
        getContactDetails();
    }
    
    public PageReference getContactDetails(){
        
        contactDetails = [select id, contact__r.name, contact__r.account.name, contact__r.email 
                                 from case_contact__c 
                                 where Case_Number__c in 
                                 (select case_number__c 
                                  from case_report_Code__c 
                                  where report_code__r.id = :ApexPages.currentPage().getParameters().get('id')
                                 )
                                 and contact__r.email != null];
        return new PageReference('');
    }
    
}
VFP :-
<apex:page standardController="report_code__c" extensions="ExportCaseReportEmailsCtrl" cache="true" contentType="text/csv#reportCodeEmails.csv;charset=utf8" language="en-US">"Name2","Client","Email"
<apex:repeat value="{!contactDetails}" var="a">
"{!a.contact__r.name}","{!a.contact__r.account.name}","{!a.contact__r.email}"
</apex:repeat>
</apex:page>
Screenshot of VFP remaining open
Screenshot of VFPThanks
 
Hi all & thanks for taking the time to read this.

I'm working on a project which requires a rest api call to an external site.  As the external company haven't completed their work yet I thought I'd get ahead of the curve & write a simulation of their code on one of our sanboxes so I can test my code which is running in another sandbox.  However I get a [Status=Bad Request, StatusCode=400] response when requesting an authorisation code before I even get to the point of the real request.  I can boil down this request down to (where the client_id etc. obviously have the correct values):-
 
HttpRequest req = new HttpRequest();
Http http = new Http();
String authUrl = 'https://test.salesforce.com/services/oauth2/token?grant_type=refresh_token' +
                            '&client_id=' + 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXX' +
                            '&client_secret=' + 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYY' +
                            '&refresh_token=' + 'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ';

string reqBody = 'sss';

req.setHeader('Content-Type', 'application/json;charset=UTF-8');

req.setMethod('POST');
req.setEndpoint(authUrl);
system.debug(authUrl);


HTTPResponse resp = http.send(req);
system.debug(resp);
Bizarrelyif I log in to workbench using the sandbox that is sending the request & go to the Rest Explorer & use the value in the variable authUrl without the https://test.salesforce.com (so starting /services/oauth2/token?grant_type=refresh_token...) it works fine.

Any suggestions as this is driving me crazy?  

Thanks for any help you can offer.

Praenei
 
I have created a simple Validation rule that states if Record Name = "RecordX" and Custom Setting Can Edit All Records != TRUE then you cannot edit the record. 

I have one test that is not working with the validation rule. I have put in the debug logs the current user and it is running with my user which it should. I can edit the record through the UI but the test validation rule is in place with the test.

Test Method:
@istest
public with sharing class OomasyncpageeExtension_test{
    testmethod static void OSPETmethod(){
        //create data
        
        User U = [SELECT Id FROM User WHERE Profile.Name='System Administrator' and isActive=true LIMIT 1];
        system.debug('User U::--::'+U);
        
        Ooma__c OCS_one = new Ooma__c (Name = 'Change Info', End_Point_URL__c = 'http://site.com' );
        insert OCS_one;
        
        ooma__c OCS_two = new Ooma__c (Name = 'Change or Cancel', End_Point_URL__c = 'site.com');
        insert OCS_two;
        
        id OSRT = Schema.SObjectType.service__c.getRecordTypeInfosByName().get('Voice Service').getRecordTypeId();
        id OOrt = Schema.SObjectType.opportunity.getRecordTypeInfosByName().get('Voice: New Sale').getRecordTypeId();
        
        Account acct = new Account(Name = 'First last');
        insert acct;
        
        Contact con = new Contact(AccountId = acct.Id, FirstName = 'first', LastName = 'last', EMail = 'someone@somewhere.com');
        insert con;
        
        Zuora__CustomerAccount__c bAcc=new Zuora__CustomerAccount__c();
        bAcc.Name='Test Bill';
        bAcc.Zuora__Account__c=acct.Id; 
        bAcc.Zuora__BillCycleDay__c = '1st of the month';
        bAcc.Zuora__BillToAddress1__c = '125 fake street';
        bAcc.Zuora__BillToAddress2__c = '';
        bAcc.Zuora__BillToState__c = 'UT';
        bAcc.Zuora__BillToPostalCode__c = '84058';
        bAcc.Zuora__BillToCity__c = 'Provo';
        bAcc.Zuora__BillToCountry__c = 'US';
        bAcc.Send_to_Collections__c = false;
        bAcc.Cancel_Billing_Account__c = false;
        Insert bAcc;
        
         Vivint_Employee__C VE = new Vivint_Employee__C (Name = 'Testname', Employee_ID__c ='999990');
        insert VE;
        system.debug('Inserted VE');
        
        opportunity oppty = new opportunity();
        Oppty.AccountId = acct.id;
        oppty.Billing_Address_Same_As_Service__c = true;
        oppty.Sales_Credit__c = VE.id;
        oppty.CloseDate = date.today();
        oppty.stageName = 'Submit For Enrollment';
        oppty.Billing_Account__c = bAcc.id;
        oppty.Contract_Signer__c = con.id;
        oppty.Service_Address_1__c = '125 fake street';
        oppty.Service_Address_2__c = '';
        oppty.Service_Address_City__c = 'Fake City';
        oppty.Service_Address_Postal_Code__c = '55555';
        oppty.Service_Address_State__c = 'CA';
        oppty.Service_Address_Country__c = 'US';
        oppty.Service_Level__c = 'Standard';
        oppty.RecordTypeId = oort;
        oppty.Name = 'Test Oppty';
        insert oppty;
        
        service__c OS = new Service__c (Account__c = acct.id, Initial_Opportunity__c = oppty.Id , Billing_Account__c = bAcc.id, Status__c = 'Active',  VOIP_Hardware_Serial_Number__c = 'Hardware serial 1', VOIP_Hardware_Serial_Number2__c= 'Hardware serial 2', RecordTypeId = OSRT, VOIP_internal_ID__c = '1234', VOIP_E911_State__c = 'CA', VOIP_E911_Postal_Code__c = '55555', VOIP_E911_Country_Code__c = 'US' ,VOIP_E911_City__c = 'test city', VOIP_E911_Address__c = 'test address', Service_level__c = 'Basic');
        OS.Contract_Signer__c = con.id;
        System.debug('Debug::: Service Record: ' + OS);
        System.debug('Current User: ' + UserInfo.getUserName());
        System.debug('Current Profile: ' + UserInfo.getProfileId());
        insert OS; 
        
        PageReference PG = Page.oomaSyncPage;
        Test.setCurrentPage(PG);
        ApexPages.currentPage().getParameters().put('id', string.valueOf(OS.id));
        Apexpages.standardcontroller stdcontroller = new Apexpages.standardcontroller(OS);
        OOmaSyncPageExtension a = new OOmaSyncPageExtension(stdcontroller);
        
        Test.startTest(); 
        Test.setMock(HttpCalloutMock.class, new OOmasyncpageextMHRG());
        
        a.oomacontactsync();
        a.nosync();
        Test.Stoptest();
    }//closing testmethod
}// closing class

Validation Rule:
AND( RecordType.DeveloperName = 'Voice_Record_Type',  !$Setup.Can_Modify_All_Services__c.Bypass_Service_Validation_Rules__c )

As mentioned before the Debug log says the Current User is me and the Profile Id is the Sys Admin Id.