• Christopher D. Emerson
  • NEWBIE
  • 25 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 5
    Likes Given
  • 0
    Questions
  • 17
    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?

I have followed instructions in this knowledge article for sending email templates in recipient's language: 
https://help.salesforce.com/articleView?id=000120154&language=en_US&type=1

I have the language set in the messaging:emailTemplate tag based on recipient's LanguageLocaleKey:
<messaging:emailTemplate subject="Subject" recipientType="User" relatedToType="Object__c" language="{!recipient.LanguageLocaleKey}" >
Component reference for emailTemplate, 'language' attribute: "The language used to display the email template. Valid values: Salesforce.com-supported language keys, for example, "en" or "en-US". Accepts merge fields from recipientType and relatedToType."

.. and included custom labels into the template: {!$Label.test}

There is a translation for the language I'm changing to in my settings that I'm testing for. I've also tried with apex:outputText, apex:outputLabel, etc... and still I keep getting the custom label value in English (default language).

Any ideas what I'm missing?
Greetings, I am working on the Prevent XSS in Force.Com Applications Trailhead, so far I've gotten most of the sections cleared. However, I seem to be stuck with this one. I've attempted many ways to assign JSENCODE, HTMLENCODE and JSINHTMLENCODE where needed but seem to stuck, are there any steps I should take here. My code's below. Hope it helps!
 
<apex:page controller="XSS_Mitigations_Challenge" sidebar="false" tabStyle="XSS_Mitigations_Challenge__tab">
<apex:sectionHeader title="XSS Mitigations Challenge" />
<apex:form >
    <apex:pageBlock >
        <apex:pageMessages />      
        <apex:pageBlockSection title="Demo" columns="1" id="tableBlock">
            <c:codeLink type="Visualforce" namespace="" edit="true" name="XSS_Mitigations_Challenge" description="Edit this Visualforce page to perform the challenge."/>
            
            
            <apex:outputText value="{!JSENCODE(sampleMergeField1)}"/>


            <apex:outputText value="{!HTMLENCODE(sampleMergeField2)}" escape="false"/>


            <apex:outputText >
                {!sampleMergeField3}
            </apex:outputText>
       
       
            <script>
                document.write('{!JSENCODE(sampleMergeField4)}');
            </script>
             
            
            {!sampleMergeField5}
            
            
            <script>
                var x = '{!JSENCODE(sampleMergeField6)}';
            </script>
            
            
            <apex:outputLabel value="{!sampleMergeField7}" escape="false"/>
                     

        </apex:pageBlockSection>
        <apex:pageBlockSection title="Code links" columns="1">
            <apex:outputPanel >
                <ul>
                    <li><c:codeLink type="Visualforce" namespace="" name="XSS_Mitigations_Challenge" description="Visualforce Page"/></li>            
                    <li><c:codeLink type="Apex" namespace="" name="XSS_Mitigations_Challenge" description="Apex Controller"/></li>
                </ul>
            </apex:outputPanel>        
        </apex:pageBlockSection>        
    </apex:pageBlock>          
</apex:form>              
</apex:page>

 
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

 

I want to include a Custom Setting in a package **and** two instances (records) of the Custom Settings Object. Is that possible?

I can schedule a job via Apex code:

 

System.schedule('test', '0 0 0 * * ?', new SchedulableClass());

 

The CronTrigger job doesn't have a "Name" field, so I can't query for the Job I just created.  This means I can't check to see if my job already exists calling System.schedule(); instead I just have to call "schedule()" and silently eat the exception it throws if the job already exists.

 

The only way you can figure out which CronTrigger is yours is to cache the return value of System.schedule(), which (it so happens) is the ID of the CronTrigger that is created.  However, you can't delete them from Apex:

 

 

Id jobid = System.schedule('test', '0 0 0 * * ?', new SchedulableClass());
delete new CronTrigger(Id = jobid);

// 'delete' throws 'DML not allowed on CronTrigger'

 

 

So the current state of Scheduled Jobs is:

 

You can create them from Apex Code, but not from the UI

You can delete them from the UI, but not from Apex Code

 

I guess that just seems odd to me.  Why did Salesforce create this whole new API (System.schedule()), with a seemingly random assortment of ways to manipulate it, instead of just exposing the CronTrigger table directly to the full range of DML operations?

 

Placing new functionality into new core objects, rather than new APIs, seems easier on everyone (the whole describe/global describe suite of API calls are an example of something that seems a natural fit for a set of read-only custom objects).

  • April 22, 2010
  • Like
  • 0
I have created a trigger which is calling an external web service to synchronize the leads creation/deletion process. When i delete/create leads the web service is working fine but when i mass upload it(mass import process..) or mass delete process (when it reaches its max limit..i.e. 250) it throws an exception and an error mail is generated with this error "System.CalloutException: IO Exception: Read timed out" error. I have also added the timeout_x property in my code to the max value(60000). But still its throwing the same error. Kindly help. Thanks in advance. Shaveta
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?