• EM3R50N
  • NEWBIE
  • 5 Points
  • Member since 2017


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 5
    Likes Given
  • 0
    Questions
  • 13
    Replies
Hello,

I'm doing a 'Visualforce Basics' module and I'm stuck at 'Use Standard Controllers' Unit (link here).
I created a page with the following code:
 
<apex:page>
    <apex:pageBlock title="Account Summary">
        <apex:pageBlockSection>

        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>

Then I opened a page via the "Preview" button in a Developer Console and opened a JavaScript console in Chrome where I typed:

$A.get("e.force:navigateToURL").setParams({"url": "/apex/AccSum"}).fire();
And I got the following error:
Uncaught ReferenceError: $A is not defined at <anonymous>:1:1
 

Both the snippets are copied from the Unit's sections, I didn't change anything except the page's name - 'AccSum'. I tried all of the above in a Firefox which also did not work.

Does anyone know what's going on?

When I try to authenticate to SalesForce in order to get access to the data I get this message: "retry your request".
The authentication was successful till this morning. I know that for unsuccessful authentication you should receive different error (authentication failure).

How to overcome this issue?

This is my code:
 string securityToken = ConfigurationManager.AppSettings["SecurityToken"];
            string ConsumerKey = ConfigurationManager.AppSettings["ConsumerKey"];
            string ConsumerSecret = ConfigurationManager.AppSettings["ConsumerSecret"];
            string Username = ConfigurationManager.AppSettings["Username"];
            string Password = ConfigurationManager.AppSettings["Password"] + securityToken;
            string IsSandboxUser = ConfigurationManager.AppSettings["IsSandboxUser"];

            var url = IsSandboxUser.Equals("true", StringComparison.CurrentCultureIgnoreCase)
                ? "https://test.salesforce.com/services/oauth2/token"
                : "https://login.salesforce.com/services/oauth2/token";

            var auth = new AuthenticationClient(new HttpClient());
            try
            {
                await auth.UsernamePasswordAsync(ConsumerKey, ConsumerSecret, Username, Password, url);
            }
            catch (Exception ex)
            {
                throw;
            }
Hi All,

I've been stuck with this error for 2 days already.

I've been trying to test a fairly simple REST code in my workbench. But for some weird reason(s), it always show this error (attached)

Here's my code:
@RestResource(urlMapping='/v1/accounts/*')
global with sharing class SampleREST{
  
    @HttpGet
    global static AccountWrapper doGet() {
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        
        AccountWrapper response = new AccountWrapper();
        
        response.acctList = [SELECT Id, Name FROM Account];
        response.status = 'Success';
        
        return response;
    }
    
    global class AccountWrapper{
        public List<Account> acctList;
        public String status;
        public String message;
        
        public AccountWrapper(){
            acctList = new List<Account>();
        }
    }
}

Of all the articles I've checked, they all point me into 1 direction and it hasn't worked either.

So I was thinking that it might be something that I setup or forget to setup before I had my class created?

Appreciate your help on this.User-added image
 
I've completed the challenge, it has 100% coverage. I've checked all the method names. The URL is valid. I've used Work Bench and curl to test and even tested with multiple Accounts with and without contacts.

I know on other challenges, punctionation was important.  What about the defination of the return? Are there expected names?

I built a class to hold Account ID & Name along with a List of Contact names and IDs. Is this my issue?  Anyone else have a challenge with this challenge?


Any help or hints will be appreciated.

Here are snippets of my code:

@RestResource(urlMapping='/Accounts/*/contacts')
global with sharing class AccountManager {

....

global class APIAccount {
        public ID Id;
        public String Name;
        List<APIContact> Contacts;

...

@HttpGet
    global static APIAccount getAccount() {
        RestRequest request = RestContext.request;
...
 
Hello,

I have below error message,

I have no web service calll from the class
 
Methods defined as TestMethod do not support Web service callouts null

 
The WSDL generated for an Apex Class method using the webservice keyword may be missing required complex types.

Take the example:
global class RetrieveOpportunity {
  webservice static Opportunity retrieveOpportunity(Id opportunityId) {
    return new Opportunity();
  }
}

This will generate a WSDL with elements like:
 
<xsd:element name="BillingAddress" minOccurs="0" type="tns:address" nillable="true"/>

The issue is that there is no address complex type in the WSDL tns namespace (http://soap.sforce.com/schemas/class/DFB/RetrieveOpportunity in this case).

This results in errors like:
Error: type 'address@http://soap.sforce.com/schemas/class/RetrieveOpportunity' not found.
Source - WSDL generated from apex can't import to SoapUI (http://salesforce.stackexchange.com/q/56005/102)
and
Error 1 Unable to import binding 'getLeadInfoBinding' from namespace 'http://soap.sforce.com/schemas/class/getLeadInfo'. App_WebReferences/WebReference/

Source - Issue with Adding reference Webservice WSDL to VS2010 (http://salesforce.stackexchange.com/q/53329/102)

The currently solution is to manually add the missing complex types to the xsd:schema with the required targetNamespace.
 
<!-- Compound datatype: Address -->
        <complexType name="address">
            <complexContent>
                <extension base="tns:location">
                    <sequence>
                        <element name="city" type="xsd:string"  nillable="true" />
                        <element name="country" type="xsd:string"  nillable="true" />
                        <element name="countryCode" type="xsd:string"  nillable="true" />
                        <element name="postalCode" type="xsd:string"  nillable="true" />
                        <element name="state" type="xsd:string"  nillable="true" />
                        <element name="stateCode" type="xsd:string"  nillable="true" />
                        <element name="street" type="xsd:string"  nillable="true" />
                    </sequence>
                </extension>
            </complexContent>
        </complexType>

<!-- Compound datatype: Location -->
        <complexType name="location">
            <sequence>
                <element name="latitude" type="xsd:double"  nillable="true" />
                <element name="longitude" type="xsd:double"  nillable="true" />
            </sequence>
        </complexType>

Can this be raised as an Apex API bug?
Hello,

I'm doing a 'Visualforce Basics' module and I'm stuck at 'Use Standard Controllers' Unit (link here).
I created a page with the following code:
 
<apex:page>
    <apex:pageBlock title="Account Summary">
        <apex:pageBlockSection>

        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>

Then I opened a page via the "Preview" button in a Developer Console and opened a JavaScript console in Chrome where I typed:

$A.get("e.force:navigateToURL").setParams({"url": "/apex/AccSum"}).fire();
And I got the following error:
Uncaught ReferenceError: $A is not defined at <anonymous>:1:1
 

Both the snippets are copied from the Unit's sections, I didn't change anything except the page's name - 'AccSum'. I tried all of the above in a Firefox which also did not work.

Does anyone know what's going on?

got this when following trailhead use standard controller instructions (working through section: find a record ID

any help fixing this?

Invalid 'X-Frame-Options' header encountered when loading 'https://na35.salesforce.com/apexpages/devmode/devConsoleViewStateMetadataReceiver.apexp?sfdcIFrameOrigin=https%3A%2F%2Fc.na35.visual.force.com': 'ALLOW-FROM https://c.na35.visual.force.com' is not a recognized directive. The header will be ignored.
The WSDL generated for an Apex Class method using the webservice keyword may be missing required complex types.

Take the example:
global class RetrieveOpportunity {
  webservice static Opportunity retrieveOpportunity(Id opportunityId) {
    return new Opportunity();
  }
}

This will generate a WSDL with elements like:
 
<xsd:element name="BillingAddress" minOccurs="0" type="tns:address" nillable="true"/>

The issue is that there is no address complex type in the WSDL tns namespace (http://soap.sforce.com/schemas/class/DFB/RetrieveOpportunity in this case).

This results in errors like:
Error: type 'address@http://soap.sforce.com/schemas/class/RetrieveOpportunity' not found.
Source - WSDL generated from apex can't import to SoapUI (http://salesforce.stackexchange.com/q/56005/102)
and
Error 1 Unable to import binding 'getLeadInfoBinding' from namespace 'http://soap.sforce.com/schemas/class/getLeadInfo'. App_WebReferences/WebReference/

Source - Issue with Adding reference Webservice WSDL to VS2010 (http://salesforce.stackexchange.com/q/53329/102)

The currently solution is to manually add the missing complex types to the xsd:schema with the required targetNamespace.
 
<!-- Compound datatype: Address -->
        <complexType name="address">
            <complexContent>
                <extension base="tns:location">
                    <sequence>
                        <element name="city" type="xsd:string"  nillable="true" />
                        <element name="country" type="xsd:string"  nillable="true" />
                        <element name="countryCode" type="xsd:string"  nillable="true" />
                        <element name="postalCode" type="xsd:string"  nillable="true" />
                        <element name="state" type="xsd:string"  nillable="true" />
                        <element name="stateCode" type="xsd:string"  nillable="true" />
                        <element name="street" type="xsd:string"  nillable="true" />
                    </sequence>
                </extension>
            </complexContent>
        </complexType>

<!-- Compound datatype: Location -->
        <complexType name="location">
            <sequence>
                <element name="latitude" type="xsd:double"  nillable="true" />
                <element name="longitude" type="xsd:double"  nillable="true" />
            </sequence>
        </complexType>

Can this be raised as an Apex API bug?
How can I delete all the records of a custom object in Developer Edition?

If you have a SOQL statement with ORDER BY and a LIMIT 100 clause, which executes first?  Does it order all records and then take the first 100 records or does it do the LIMIT first and then ORDER BY?