• Dave Dudek
  • NEWBIE
  • 20 Points
  • Member since 2014
  • IT Specialist
  • Jobs for the Future


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 6
    Replies
i've created a lightning app with an embedded lightning component that works for our internal users except for the read only user. the read only user has access to the apex class and the various fields referenced by the lightning component. i'm not sure why i'm getting this error and salesforce supprot says it's a limitation of Aura.

An internal server error has occurred
An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience. 

Thank you again for your patience and assistance. And thanks for using salesforce.com! 

Error ID: 260643338-555165 (1078880847)



 
I'm trying to write a test class to validate a VF page and apex class that only performs a SOQL query to find all accounts matching a city or state. However, I can't figure out what i'm testing for and where i'm testing despite all of the documentation i am reading because it's not just creating a record to test a deletion on but rather just querying a bunch of records.


Here's the original code that you nice folks helped me with but I never put a test class in so it's failing code coverage now...

I have a `Place__c` record called "Massachusetts" with a `State_Code__c` field (e.g. "MA"). I'm trying to embed a `Visualforce Page`  on the `Place__c` Page Layout to show all `Account` records that have a `BillingState` that matches the `State_Code__c` field value of the current record (in this case, "MA"), and have it preferably look like a `Related List` in LEX.

**There is no relationship between place and account.** We just want to be able to look at all accounts that have a match to the State Code.


----------

**VF Page AccountsinPlaces**

 

    <apex:page standardController="Place__c" extensions="AccountsinPlacesExt">    

    <apex:stylesheet value="{!URLFOR($Resource.SLDS0122, 'assets/styles/salesforce-lightning-design-system-vf.css')}" />

        <!-- Rest of your page -->



    <script> 
    function navSObject(reciord) 
    { 
        sforce.one.navigateToSObject(reciord,"detail"); 
    };
    </script>

    <div class="slds" style=".slds-scrollable--x">

    <h1>Accounts with Services located in {!Place__c.Name}, and the contacts for those Accounts.</h1>  
    <br />NOTE: The specific contacts might not actually be affiliated with the Service shown, this is a list of all contacts associated with the Account.<br />
    <apex:dataTable value="{!inPlaceAccounts}" var="account" id="theTable" rowClasses="odd,even" styleClass="slds-table slds-table--bordered">
    <apex:Column >
     <apex:facet name="header" >Account Name</apex:facet>
     <apex:outputLink onclick="navSObject('{!Account.Id}')">{!Account.name}</apex:outputLink>
    </apex:Column>
    <apex:Column >
     <apex:facet name="header">Account JFF Role Name</apex:facet>
    <apex:repeat value="{!account.Our_Role_Service_Affiliation_for_Account__r}" var="junction">
    <apex:outputLink onclick="navSObject('{!junction.id}')">
           {!junction.Our_Role__r.name}</apex:outputLink><br />
    </apex:repeat>
    </apex:Column>
    <apex:Column >
    <apex:facet name="header">Service Name</apex:facet>
    <apex:repeat value="{!account.Our_Role_Service_Affiliation_for_Account__r}" var="junction">
       <apex:outputLink onclick="navSObject('{!junction.Service__r.id}')">
           {!junction.Service__r.name}</apex:outputLink><br />
    </apex:repeat>
    </apex:Column>

    <apex:Column >
     <apex:facet name="header">Contact Name</apex:facet>
    <apex:repeat value="{!account.Contacts}" var="contact"><apex:outputLink onclick="navSObject('{!contact.id}')">{!contact.name}</apex:outputLink><br /></apex:repeat>
    </apex:Column>
    </apex:dataTable>
    </div>
    </apex:page> 
    
   

----------


**Apex Class AccountsinPlacesExt**

    public with sharing class AccountsinPlacesExt {
    @AuraEnabled

    public Place__c place { get; private set; }
    public List<Account> inPlaceAccounts { get; private set; }
    public AccountsinPlacesExt(ApexPages.StandardController controller)
    {
        // add the Place__c field that tells you which state
        List<String> neededFields = new List<String> { 'City__c','State_Code__c' };
        if (!Test.isRunningTest()) controller.addFields(neededFields);
        place = (Place__c)controller.getRecord();

       if (place.City__c != null) {
       // search for city and state match
            inPlaceAccounts = [
                SELECT Id,Name,BillingState,(SELECT Name FROM Contacts),(SELECT Id,Service__r.Name,Our_Role__r.Name FROM Our_Role_Service_Affiliation_for_Account__r) FROM Account WHERE Id IN (SELECT Account__c FROM Our_Role_Service_Affiliation_for_Account__c WHERE Our_Role__r.Name != 'Outreach') AND Our_Role_Count__c > 0 AND BillingCity = :place.City__c AND BillingState = :place.State_Code__c
            ];
       } else {
       //search for only state match
            inPlaceAccounts = [
                SELECT Id,Name,BillingState,(SELECT Name FROM Contacts),(SELECT Id,Service__r.Name,Our_Role__r.Name FROM Our_Role_Service_Affiliation_for_Account__r) FROM Account WHERE Id IN (SELECT Account__c FROM Our_Role_Service_Affiliation_for_Account__c WHERE Our_Role__r.Name != 'Outreach') AND Our_Role_Count__c > 0 AND BillingState = :place.State_Code__c
            ];
       }
       // end else
        }

    }

I've tried writing a test class but i'm getting an unexpected token '=' and i'm also lost at the assertions I need to write.

@isTest
public with sharing class AccountsinPlacesExtTest {

public Place__c placeObj = new Place__c();
public Str placeObj.City__c = 'Boston';
public string placeObj.State_Code__c = 'MA';
//add other relevant attributes
insert placeObj;

//create Account and other records with matching entries
public Account acct = new Account();
string acct.name = 'test1';
string acct.BillingState = 'MA';
insert acct;

PageReference pageRef = Page.yourVisualforcePage;

Test.startTest();
Test.setCurrentPage(pageRef);

ApexPages.StandardController std = new Apexpages.StandardController(placeObj);    
AccountsinPlacesExt  controller = new AccountsinPlacesExt (std);                    

//assert suitable results.
System.assertEquals(....);
Test.stopTest();

}
I'm trying to view contacts of accounts that are related to a custom object we have called Our_Role_Service_Affiliation_for_Account__c. I'm able to see the account name, service name and role name but I can't seem to delve into the accounts.

Here's my two SELECT queries I've tried:

1) 
SELECT Id,Name,(SELECT Name FROM Contacts),(SELECT Id,Service__r.Name,Our_Role__r.Name FROM Our_Role_Service_Affiliation_for_Account__r) FROM Account WHERE Id IN (SELECT Account__r.Id FROM Our_Role_Service_Affiliation_for_Account__c WHERE Our_Role__r != 'Outreach')

ERROR at Row:1:Column:171
The inner select field 'Account__r.Id' cannot have more than one level of relationships


2)
SELECT Name,Account__r.Name,Service__r.Name,Our_Role__r.Name FROM Our_Role_Service_Affiliation_for_Account__c WHERE Our_Role__r.Name != 'Outreach' AND Account__r.BillingState = :place.State_Code__c

Works but doesn't show contacts

 
I'm trying to create a SOQL query with a subquery to show contacts and accounts located within a state that have a certain custom object relationship:

Here is my code:

SELECT Id,Name FROM Account WHERE Our_Role_Count__c > 0 AND BillingState = 'NH' AND Id IN (SELECT Account__r.Id,Account__r.Name,Account__r.BillingState, Our_Role__r.Name FROM Our_Role_Service_Affiliation_for_Account__c WHERE Our_Role__r.Name != 'Outreach')

However I get an error: The inner select field 'Account__r.Id' cannot have more than one level of relationships
i've created a lightning app with an embedded lightning component that works for our internal users except for the read only user. the read only user has access to the apex class and the various fields referenced by the lightning component. i'm not sure why i'm getting this error and salesforce supprot says it's a limitation of Aura.

An internal server error has occurred
An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience. 

Thank you again for your patience and assistance. And thanks for using salesforce.com! 

Error ID: 260643338-555165 (1078880847)



 
I'm trying to view contacts of accounts that are related to a custom object we have called Our_Role_Service_Affiliation_for_Account__c. I'm able to see the account name, service name and role name but I can't seem to delve into the accounts.

Here's my two SELECT queries I've tried:

1) 
SELECT Id,Name,(SELECT Name FROM Contacts),(SELECT Id,Service__r.Name,Our_Role__r.Name FROM Our_Role_Service_Affiliation_for_Account__r) FROM Account WHERE Id IN (SELECT Account__r.Id FROM Our_Role_Service_Affiliation_for_Account__c WHERE Our_Role__r != 'Outreach')

ERROR at Row:1:Column:171
The inner select field 'Account__r.Id' cannot have more than one level of relationships


2)
SELECT Name,Account__r.Name,Service__r.Name,Our_Role__r.Name FROM Our_Role_Service_Affiliation_for_Account__c WHERE Our_Role__r.Name != 'Outreach' AND Account__r.BillingState = :place.State_Code__c

Works but doesn't show contacts

 
I'm trying to create a SOQL query with a subquery to show contacts and accounts located within a state that have a certain custom object relationship:

Here is my code:

SELECT Id,Name FROM Account WHERE Our_Role_Count__c > 0 AND BillingState = 'NH' AND Id IN (SELECT Account__r.Id,Account__r.Name,Account__r.BillingState, Our_Role__r.Name FROM Our_Role_Service_Affiliation_for_Account__c WHERE Our_Role__r.Name != 'Outreach')

However I get an error: The inner select field 'Account__r.Id' cannot have more than one level of relationships