• Patrick Mayer 4
  • NEWBIE
  • 50 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 1
    Likes Given
  • 16
    Questions
  • 7
    Replies
Why does this only save the value of a boolean back if I call an empty function? I have tried it with the alternative second line that I have commented out and this does not update the controller as I would like. Is there a better way to do this? My solution seems hacky.
 
public class DemoController {
	public boolean activated { get; set; }

	public DemoController() {
		activated = false;
	}

	public void doNothing() {}
}


<apex:page controller="DemoController">
    <apex:form id="form">
        <apex:inputCheckbox value="{!activated}" >
            <apex:actionSupport event="onclick" action="{!doNothing}"/>
            <!--<apex:actionSupport event="onclick" rerender="test"/>-->
        </apex:inputCheckbox>
    </apex:form>

    <apex:outputText id="test" value="test" rendered="{!activated}"/>
</apex:page>



 

This is a function that works in my other vf pages. When I am using it from an embedded vf page however, 
sforce.console.isInConsole() always goes false. Any ideas for a work-around.

 

function openSubtab(id) {
  // Check if user is in the Console, otherwise open as a regular URL
  if (sforce.console.isInConsole()) {
    sforce.console.getEnclosingPrimaryTabId(function(result) {
      sforce.console.openSubtab(result.id, '/' + id, true, '', null);
    });
  } else {
    window.open('/' + id);
  }
};
This is a function that works in my other vf pages. When I am using it from an embedded vf page however, 
sforce.console.isInConsole() always goes false. Any ideas for a work-around.



 
function openSubtab(id) {
  // Check if user is in the Console, otherwise open as a regular URL
  if (sforce.console.isInConsole()) {
    sforce.console.getEnclosingPrimaryTabId(function(result) {
        sforce.console.openSubtab(result.id, '/' + id, true, '', null);
    });
  } else {
    window.open('/' + id);
  }
};



This is a function that works in my other vf pages. When I am using it from an embedded vf page however, 
sforce.console.isInConsole() always goes false. Any ideas for a work-around.
 

 

function openSubtab(id) {
  // Check if user is in the Console, otherwise open as a regular URL
  if (sforce.console.isInConsole()) {
    sforce.console.getEnclosingPrimaryTabId(function(result) {
        sforce.console.openSubtab(result.id, '/' + id, true, '', null);
    });
  } else {
    window.open('/' + id);
  }
};
A red alert message comes up when I try to save my visualforce page. This is in sandbox. I have tried refreshing and just adding blank lines, but even that causes this saving error.
public with sharing class OrdersPageControllerExtension {
    public ApexPages.StandardController sc;
    public final Order__c order;

    public OrdersPageControllerExtension(ApexPages.StandardController stdController) {
        this.sc = stdController;
        if (!Test.isRunningTest()) { 
            stdController.addFields(new List<String>{'Products__c', 'Restaurant_ID__c', 'Gift_Card__c'});
        }
        if (order.Products__c != null) {
            .....
        }
    }
}


System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Order__c.Products__c 

Has anyone else seen this? Is it a bug?

<apex:page standardController="Order__c">
    <apex:relatedList list="Cases"/>
</apex:page>

This is in one of my sandbox orgs. I have System Admin permissions. Yet, I get an Insufficient Privileges error on page load. The Cases related list does work on the standard layout. I am not sure which permission I should change. Thanks!

I need to have lists refresh when a new record is added. I would think that the Choose How Lists Refresh option and Push Notifications handle this, but that does not seem to work. Please help!
I have a link to a VF page that displays a related list for a record. I would like to change this to link to the page that opens when you select 'Go to list (50+)' at the bottom of this. I am having trouble figuring out what I would use for the URL.
<apex:page id="page" tabStyle="Case">

    <apex:includeScript value="{!$Resource.cometd}"/>
    <apex:includeScript value="{!$Resource.jquery}"/>
    <apex:includeScript value="{!$Resource.json2}"/>
    <apex:includeScript value="{!$Resource.jquery_cometd}"/>
    
    <script type="text/javascript">
    
        var j$ = jQuery.noConflict();
        j$(document).ready(function() {
     
            j$.cometd.init({
                url: window.location.protocol+'//'+window.location.hostname+'/cometd/28.0/',
                requestHeaders: { Authorization: 'OAuth {!$Api.Session_ID}'}
            });
    
            j$.cometd.subscribe('/topic/CaseUpdates', function(message) {
                document.getElementById('{!$Component.page.PageBlock}').style.display = 'none';
                document.getElementById('{!$Component.page.PageBlock}').style.display = 'block';
            });
       });
       
   </script>

   <apex:pageBlock id="PageBlock">

   <apex:enhancedList type="Case" height="300" rowsPerPage="10" id="AccountList" />

   </apex:pageBlock>
   

</apex:page>

I am trying to use the streaming API to rerender this list when any case is changed. I am guessing I should use some different javascript. Has anyone done this?
I have checked workbench and am seeing the notifications. Also, a secondary minor question, is there any way to put a text output or something inside of the subscribe just as a sanity check that it gets hit?

I am having an extremely difficult time coming up with a test class for this. 

I am using a multimock for mock data, but I cannot figure out how to set cookies for that.

Http httpProtocol1 = new Http();
		Http httpProtocol2 = new Http();
		// Create HTTP request to send.
		HttpRequest request1 = new HttpRequest();
		HttpRequest request2 = new HttpRequest();
		// Set the endpoint URL.
		String endpoint1 = 'https://web.com/Login.json?user=user%40web.com&pass=secr';
		String endpoint2 = 'https://web.com/info.json';
		request1.setEndPoint(endpoint1);
		request2.setEndPoint(endpoint2);
		// Set the HTTP verbs
		request1.setMethod('POST');
		request2.setMethod('GET');
		// Send the HTTP requests and get the responses
		HttpResponse response1 = httpProtocol1.send(request1);
		String cookie = response1.getHeader('Set-Cookie');
		request2.setHeader('cookie', cookie);
		HttpResponse response2 = httpProtocol2.send(request2);
		String jsonStr = response2.getBody();


Http httpProtocol1 = new Http();
Http httpProtocol2 = new Http();
// Create HTTP request to send.
HttpRequest request1 = new HttpRequest();
HttpRequest request2 = new HttpRequest();
// Set the endpoint URL.
String endpoint1 = 'https://website.com/Login.json?user=patrick@website.com&pass=Secret';
String endpoint2 = 'https://website.com/LoginRequiredInfo.json';
request1.setEndPoint(endpoint1);
request2.setEndPoint(endpoint2);
// Set the HTTP verb to GET.
request1.setMethod('GET');
request2.setMethod('GET');
// Send the HTTP request and get the response.
// The response is in JSON format.
HttpResponse response1 = httpProtocol1.send(request1);
HttpResponse response2 = httpProtocol2.send(request2);
System.debug(response2.getBody());


Code is included for clarification, but essentially I am trying use the first json that creates a cookie that gives admin status to the second so that the info can be read. It works if I enter the 2 URLs in succession into a browser.

I am wondering if anyone has done anything like this and gotten it to work.

Account acct = new Account(RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Person Account').getRecordTypeId());
        acct.Phone = o.Customers_Phone__c;
        acct.PersonEmail = o.Customers_Email__c; 
        acct.FirstName = o.Customers_First_Name__c;
        acct.LastName = o.Customers_Last_Name__c;
        acct.Customer_Id__c = o.EatStreet_Customer_ID__c.toPlainString();
        insert acct;
        system.debug(acct.IsPersonAccount);
        temp.Customer__c = acct.PersonContactId;

Here is a relevant code snippet. I am most concerned with why the system.debug line returns false. Any insights would be great.
User-added image

I have been trying to deploy an entirely unrelated class and keep running into this error. When I hit run test on Production these triggers get 90% and 100% respectively. I do not understand this error in this circumstance.
I've been researching this for awhile and having trouble figuring out where to start. I think I want to use a REST API and understand that I will need to expose my data, but I'm not sure how to make SaleForce automatically check this. Any pointers welcome.
Line 16 where I insert c1 I am getting a "System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []" error. This is blocking all other deploys
@isTest (seeAllData=true)
public class IdleCaseTriggerTest{
    
	static testMethod void test() {
        Group genCaseQueue = new Group();
        genCaseQueue.Name = 'General Case Queue';
        insert genCaseQueue;
       	Group[] queues = [select Id, Name 
              	          from Group 
             			  where Name = 'General Case Queue'];
   		String geq = queues[0].Id;
		Case c1 = new Case();
        Case c2 = new Case();
        c1.Idle_Case_Hidden__c = true;
        c1.OwnerId = genCaseQueue.Id;
        insert c1;
        insert c2;
        CronTrigger[] ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime
         			      FROM CronTrigger];
        System.debug(ct[0]);
        
        
        testCasePopup();
        testPopupPageController();
    }
    
    static testMethod void testCasePopUp() {
        CasePopup cpu = new CasePopup();
        System.assertEquals(false, cpu.ignoreOn);
        cpu.show();
        System.assertEquals(true, cpu.displayPopup);
        cpu.hide();
        System.assertEquals(false, cpu.displayPopup);
        cpu.ignoreToggle();
        System.assertEquals(true, cpu.ignoreOn);
        //System.assertEquals('Ignore Popups: On', cpu.getIgnoreText());
        cpu.ignoreToggle();
        System.assertEquals(false, cpu.ignoreOn);
        System.assertEquals('Ignore Popups: Off', cpu.getIgnoreText());
        
        cpu.checkCases();
    }
    
    static testMethod void testPopupPageController() {
        Group[] queues = [select Id, Name 
              	          from Group 
             			  where Name = 'General Case Queue'];
   		String geq = queues[0].Id;
		Case c = new Case();
        c.Idle_Case_Hidden__c = true;
        c.OwnerId = geq;
        insert c;
        PopupPageController ppc = new PopupPageController();
        List<Case> cl = ppc.getCases();
        //System.assertEquals(c.Id, cl[0].Id);
        //ppc.claim();
    }
        
}


public with sharing class OrdersPageControllerExtension {
    public ApexPages.StandardController sc;
    public final Order__c order;

    public OrdersPageControllerExtension(ApexPages.StandardController stdController) {
        this.sc = stdController;
        if (!Test.isRunningTest()) { 
            stdController.addFields(new List<String>{'Products__c', 'Restaurant_ID__c', 'Gift_Card__c'});
        }
        if (order.Products__c != null) {
            .....
        }
    }
}


System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Order__c.Products__c 

Has anyone else seen this? Is it a bug?

public with sharing class OrdersPageControllerExtension {
    public ApexPages.StandardController sc;
    public final Order__c order;

    public OrdersPageControllerExtension(ApexPages.StandardController stdController) {
        this.sc = stdController;
        if (!Test.isRunningTest()) { 
            stdController.addFields(new List<String>{'Products__c', 'Restaurant_ID__c', 'Gift_Card__c'});
        }
        if (order.Products__c != null) {
            .....
        }
    }
}


System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Order__c.Products__c 

Has anyone else seen this? Is it a bug?

<apex:page standardController="Order__c">
    <apex:relatedList list="Cases"/>
</apex:page>

This is in one of my sandbox orgs. I have System Admin permissions. Yet, I get an Insufficient Privileges error on page load. The Cases related list does work on the standard layout. I am not sure which permission I should change. Thanks!

I need to have lists refresh when a new record is added. I would think that the Choose How Lists Refresh option and Push Notifications handle this, but that does not seem to work. Please help!
<apex:page id="page" tabStyle="Case">

    <apex:includeScript value="{!$Resource.cometd}"/>
    <apex:includeScript value="{!$Resource.jquery}"/>
    <apex:includeScript value="{!$Resource.json2}"/>
    <apex:includeScript value="{!$Resource.jquery_cometd}"/>
    
    <script type="text/javascript">
    
        var j$ = jQuery.noConflict();
        j$(document).ready(function() {
     
            j$.cometd.init({
                url: window.location.protocol+'//'+window.location.hostname+'/cometd/28.0/',
                requestHeaders: { Authorization: 'OAuth {!$Api.Session_ID}'}
            });
    
            j$.cometd.subscribe('/topic/CaseUpdates', function(message) {
                document.getElementById('{!$Component.page.PageBlock}').style.display = 'none';
                document.getElementById('{!$Component.page.PageBlock}').style.display = 'block';
            });
       });
       
   </script>

   <apex:pageBlock id="PageBlock">

   <apex:enhancedList type="Case" height="300" rowsPerPage="10" id="AccountList" />

   </apex:pageBlock>
   

</apex:page>

I am trying to use the streaming API to rerender this list when any case is changed. I am guessing I should use some different javascript. Has anyone done this?
I have checked workbench and am seeing the notifications. Also, a secondary minor question, is there any way to put a text output or something inside of the subscribe just as a sanity check that it gets hit?
Http httpProtocol1 = new Http();
Http httpProtocol2 = new Http();
// Create HTTP request to send.
HttpRequest request1 = new HttpRequest();
HttpRequest request2 = new HttpRequest();
// Set the endpoint URL.
String endpoint1 = 'https://website.com/Login.json?user=patrick@website.com&pass=Secret';
String endpoint2 = 'https://website.com/LoginRequiredInfo.json';
request1.setEndPoint(endpoint1);
request2.setEndPoint(endpoint2);
// Set the HTTP verb to GET.
request1.setMethod('GET');
request2.setMethod('GET');
// Send the HTTP request and get the response.
// The response is in JSON format.
HttpResponse response1 = httpProtocol1.send(request1);
HttpResponse response2 = httpProtocol2.send(request2);
System.debug(response2.getBody());


Code is included for clarification, but essentially I am trying use the first json that creates a cookie that gives admin status to the second so that the info can be read. It works if I enter the 2 URLs in succession into a browser.

I am wondering if anyone has done anything like this and gotten it to work.

I have been struggling with this problem for several days now with tech support and getting nowhere. As tech support suggested, I installed Eclipse 3.6, Force.com IDE 27, and JRE 1.6. I am downloading the specific class I want to delete. I am trying to change the status of the accompanying XML file to Deleted. I do that and save. I get no error messages. However, the status of the file returns back to Active. I can't get it to stay on Deleted. The tech claims they can make the change just fine, and it has to be on my end. I have tried performing this operation on two different operating systems on two completely different networks. Same results.

I have been struggling with this problem for several days now with tech support and getting nowhere. As tech support suggested, I installed Eclipse 3.6, Force.com IDE 27, and JRE 1.6. I am downloading the specific class I want to delete. I am trying to change the status of the accompanying XML file to Deleted. I do that and save. I get no error messages. However, the status of the file returns back to Active. I can't get it to stay on Deleted. The tech claims they can make the change just fine, and it has to be on my end. I have tried performing this operation on two different operating systems on two completely different networks. Same results.