• Douglas Molina
  • NEWBIE
  • 35 Points
  • Member since 2017
  • Salesforce Developer


  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 1
    Likes Given
  • 6
    Questions
  • 6
    Replies
Hi! 
I'm trying to implement the REST callout of this superbadge, but I'm receiving the error 400 "Bad Request. Your JSON does not contain the correct case-sensitive keys. Please reference the sample JSON."
I've already checked each of the keys case, even copied the exact same sample from trailhead, but this message keeps coming. Does anyone have a clue of what could be the problem here?

Here's what I'm trying: (the same behavior happens on both Apex/Postman)


Request/Response:
User-added image

Headers:
User-added image

Auth:User-added image

Thank you!
Hi. In my Salesforce Org I have a custom object with some fields, including a RichText field (“Icone__c”), where I store a single image inside.
I'm trying to retrieve some records from this object to my website (out from Salesforce), using the PHP toolkit 20.0 (soapclient).
I'm able to connect, query and get these records with PHP, but, the problem: I cannot see the image from Richtext field, because a CORS error.
The RichText content comes, but the image resource doesn’t load, so it generate kind of a broken src.
Even if a copy and paste the image link in a new tab, it goes to the login page, instead showing it.
The interesting thing is, IF I'm already logged in on Salesforce, the images appear normally.

Follow some more details:
 - My user (with I use to log in with PHP) has system administrator profile, with all privileges on
 - The object is checked to be accessed by the api
 - The object standard access is public to internal and partners users
 - The richtext field is available to read/write to all users
 - The WSDL file was generated after all object customizations
 - I'm using the enterprise WSDL version
 - The website uses a SSL connection (https)
 - The website domain is add to the Salesforce CORS whitelist (with "https")

Follow the PHP code:
<?php
    ini_set("soap.wsdl_cache_enabled", "1");
    require_once("./soapclient/SforceEnterpriseClient.php");
    require_once("./soapclient/SforceHeaderOptions.php");
 
    $wsdl = './soapclient/enterprise.wsdl.xml';
    $userName = "MyUser@Company.com";
    $password = "MyPassworkAndMyToken";
 
    $mySforceConnection = new SforceEnterpriseClient();
    $mySoapClient = $mySforceConnection->createConnection($wsdl);
    $mylogin = $mySforceConnection->login($userName, $password);
     
    $query = "
        SELECT   Id, Name, Icone__c
        FROM     MktMarca__c
        ORDER BY Name ASC
    ";
    $response = $mySforceConnection->query($query);
     
    foreach ($response->records as $record){
        print_r($record->Icone__c);
        print_r("<br>");
    }
?>
A comparation image:
The left side: When I Log in Salesforce before run the above PHP code, it works.
The right side: When I execute a new/clean browse instance, ignoring any previous Log in. 
User-added image
The browser console error:
Cross-Origin Read Blocking (CORB) blocked cross-origin response <URL> with MIME type text/html. See <URL> for more details.
getRecord.php:1 Cross-Origin Read Blocking (CORB) blocked cross-origin response https://Company.my.salesforce.com/content/session?url=https%3A%2F%2FCompany--c.na49.content.force.com%2Fservlet%2FrtaImage%3Feid%3Da1S5A00000xFQCc%26feoid%3D00N5A00000HMLrN%26refid%3D0EM5A000000x2Dy with MIME type text/html. See https://www.chromestatus.com/feature/5629709824032768 for more details.
The resource Status-Code:
302 Moved Temporarily
What could be wrong?

Thanks!

Hi

I have in my Org a custom object called Documento__c, where I only fill some fields and attach a file on its records.
I have a partner community too, where the community users shoud see these Documento__c records, and all the attachments.

The problem is, the portal users cannot see the attachments, unless the user be the attachment owner.

I know there are two kinds os "Attachments" that can be used in these "Notes and Attachments" related lists:
 - Attachment: That is directly related with the parent record, and nothing else.
 - File: That is a user file, witch is shared with the record at the moment it's uploaded. In this case I can see this file in the "Files" tab, and share with other records, groups and libraries too.
In both cases, they apear in the "Notes and Attachments" related lists.

With "Attachment" Attachs, everyone can see them, but everytime someone upload a file in these Attachments lists, it goes as a "File" instead "Attachment"
I know there is a option in the Org settings that changes this behavor, but it seems just works with non lightning layouts, which is not my case, and furthermore there are lots of "files" alread attached at this lists that wont be affected with this change.

User-added image

I already tried to create a libary, to add the portal users on it, then to attach the "file" and share the attached file with the libary.
When a do it, the portal users can see the file only at the "Files" tab, inside the libary.. but the "Notes and Attachments" related lists continue not showing the attachment file.

Follows an example, to better undertanding..

A internal user named "Desenvolvimento" attached 2 files:
 - "teste" was uploaded as a "File"
 - "teste 2" was uploaded as a "Attachment"

User-added image

Then the user created a libary called "Comunidade"(1), added the partner users (2), and shared the "test" file with it:

User-added image

The patner user logged in the community, opens the "File" tab and sees the file there:

User-added image

But in the record related list, it does not apear.. only the "Attachment" apears.

User-added image

Some sugestion how can this Files be displayed in the Attachments related lists to the partner community users?

Thanks!

Hi,

I have in my Org the WorkOrder and WorkOrderLineItens Objects.
I want to display the result of a very specific SOQL query in a Visualforce page.
The point is, in my Apex SOQL query, I bring fields from both objects, and others related... so, how can I declare a single List to receive this SOQL result, with all the returned fields, from all objects?

I'm following this article, but It only uses fields fron a single object, so the List is declared based on that object..
https://help.salesforce.com/articleView?id=000205631&type=1

My SOQL looks like this:
select  	id, LineItemNumber, 
			PricebookEntry.Product2.Name,
			WorkOrder.WorkOrderNumber, WorkOrder.Tipo_de_Servi_o__c
FROM		WorkOrderLineItem
WHERE		UnitPrice = 0	AND 	
			WorkOrder.CreatedDate >= 2017-05-15T00:00:00.000+0000
ORDER BY	LineItemNumber ASC

In developer console, it runs fine:
User-added image

Some sugestion, or other reference that could help me on it?
Thanks.
Hi!

In my org, I have the Opportunity object, that has a related list from a custom object named Proposta__c.
Proposta__c stores some Opportunity fields values, and a custom PDF as attachment, that contains other Opportunity informations.
Proposta__c records are generated only by a button, embedded in the Opportunity layout, as a Visualforce page commandButton (not a object's custom buttom).
So, in the Opportunity, the user clicks on this button, it calls a Apex extension class that I wrote, that creates a Proposta__c record with its fields, and generates/attach the PDF on this record.
Until here, everything is working as expected.

But, after create a Proposta__c record, I need open It, so I decided to use the onComplete commandButton property to do It.
The onComplete works fine to open the new Proposta__c record, but, when I use onComplete, the PDF attachment is generated as a blank page.
Even if I include the onComplete with no actions on it, the PDF still generate as a blank page.
If I remove only the onComplete property, the PDF is generated perfectly, with all its contents.

The point is: How can I generate correctly the regs and PDF, and then open it? maybe with a onComplete alternative..

Bellow are some tests fragments codes, to make it clearer:

proposta_pdf: The Apex extension class, that generates the Proposta__c record and its PDF attachment:
public class proposta_pdf{
    
    public     Opportunity     opp_temp, opp_reg;
    public     Id              prop_reg_id {get;set;}
    public     String          url_base {get;set;}
 
    // constructor ==============================
    public proposta_pdf(ApexPages.StandardController controller) {
        
        // Get base URL (+prefix, if community)
        this.url_base = URL.getSalesforceBaseUrl().toExternalForm() + Site.getPathPrefix();
        
        // Get other values
        this.opp_temp = (Opportunity)controller.getRecord();
        this.opp_reg = [
            SELECT     Id, Name, Amount, Prop_Versao__c
            FROM     Opportunity 
            WHERE     Id =: this.opp_temp.Id
        ];
    }
       
    // geenerate PDF bin ========================
    public Blob gera_prop_blob(){
        PageReference prop_pag = Page.Proposta_Mestre;
        prop_pag.getParameters().put('id',opp_reg.Id);
        
        Blob prop_blob;
        if(!Test.isRunningTest())
            prop_blob = prop_pag.getContentAsPDF();
        else
            prop_blob = Blob.valueOf('Este e um teste.');

        return prop_blob;
    }

    // create Proposta__c reg + PDF attachment ======
    public void salva_proposta_registro(){

        // validation
        if(this.opp_reg.Prop_Versao__c == NULL)
            this.opp_reg.Prop_Versao__c = 0;
        else
            this.opp_reg.Prop_Versao__c++;
        
        // create/save Proposta__c reg
        Proposta__c prop_reg = new Proposta__c(
            Oportunidade__c     = this.opp_reg.Id,
            Name                = this.opp_reg.Name + ' Ver:' + this.opp_reg.Prop_Versao__c,
            Versao__c             = this.opp_reg.Prop_Versao__c,
            Valor__c            = this.opp_reg.Amount
        );
        insert prop_reg;
                
        // update Proposta__c version stored in a Opportunity field
        update this.opp_reg;
                
        // create/save/attach PDF in Proposta__c reg
        Attachment prop_anex = new Attachment(
            ParentId             = prop_reg.Id,
            Body                 = gera_prop_blob(),
            Name                 = this.opp_reg.Name + ' Ver:' + this.opp_reg.Prop_Versao__c + '.pdf'
        );
        insert prop_anex;
        
        // retur ID to open new reg
        prop_reg_id = prop_reg.Id;
    }

}

Proposta_Mestre: The Visualforce page, rendered as PDF. The Proposta__c attachment:
<apex:page standardController="Opportunity" renderAs="pdf" applyHtmlTag="false" showHeader="false">
	
	Testing Opportunity My PDF
	<br/>ID: {!Opportunity.Id}
	<br/>Name: {!Opportunity.Name}
	<br/>
	<br/>End.
	
</apex:page>

proposta_botoes: The visualforce page that contains the button, embedded in Opportunity layout:
<apex:page standardController="Opportunity" extensions="proposta_pdf">
    <apex:form>
        <apex:inputHidden value="{!Opportunity.Id}"/>          
        <apex:commandButton 
            value="Save" 
            action="{!salva_proposta_registro}" 
            onComplete="window.top.location.replace('{!url_base}/{!prop_reg_id}');"
        />
    </apex:form>
</apex:page>

This is what the Opportunity detail page looks like:
User-added image

And the Proposta__c record, created by the button:
User-added image

When I do NOT use the onComplete in the button, the PDF is generated in the right way:
User-added image

And finally, if I add the onComplete in the commandButton, only a blank page is generated:
User-added image

Additionally, I already tried:
 - Add the extensions="proposta_pdf" in the Visualforce PDF page
 - Use the controller.addFields() method to pass the required fields
With no sucess.

I'm preety new in Apex development, so this can be just a detail that I didn't notice, or some mistake.. but after days searching a solution, I'm still not able to figure out how to fix it.

I'd apreciate some sugestions..
And sorry for my bad english, I'm still beginner :)
Thanks.
Hi,

I'm beginner as Salesforce developer/admin, so this may be a easy question to solve.

My Org has the "WorkOrderLineItens" related list, inserted inside the "WorkOrder" layout.

When I'm going to insert a new Item in the WorkOrder, when I chose the Product (PriceBookEntry), I just see 3 columns about to the Product, in the pop-up search layout: "Product Name", "Price List" and "Product Code".

My problem is, I need to see other key fields (standard and custom) at this search pop-up layout, but I'm not knowing how to place they there.
I already tried to change Search Layouts of "Products", "Assets", "PriceBookEntry" and others, but none of them change anything in this specific search layout.

Can anyone give-me a hint, or even tell me if it is really possible to do?

Thanks, and sorry for my very poor english.

Hi

I have in my Org a custom object called Documento__c, where I only fill some fields and attach a file on its records.
I have a partner community too, where the community users shoud see these Documento__c records, and all the attachments.

The problem is, the portal users cannot see the attachments, unless the user be the attachment owner.

I know there are two kinds os "Attachments" that can be used in these "Notes and Attachments" related lists:
 - Attachment: That is directly related with the parent record, and nothing else.
 - File: That is a user file, witch is shared with the record at the moment it's uploaded. In this case I can see this file in the "Files" tab, and share with other records, groups and libraries too.
In both cases, they apear in the "Notes and Attachments" related lists.

With "Attachment" Attachs, everyone can see them, but everytime someone upload a file in these Attachments lists, it goes as a "File" instead "Attachment"
I know there is a option in the Org settings that changes this behavor, but it seems just works with non lightning layouts, which is not my case, and furthermore there are lots of "files" alread attached at this lists that wont be affected with this change.

User-added image

I already tried to create a libary, to add the portal users on it, then to attach the "file" and share the attached file with the libary.
When a do it, the portal users can see the file only at the "Files" tab, inside the libary.. but the "Notes and Attachments" related lists continue not showing the attachment file.

Follows an example, to better undertanding..

A internal user named "Desenvolvimento" attached 2 files:
 - "teste" was uploaded as a "File"
 - "teste 2" was uploaded as a "Attachment"

User-added image

Then the user created a libary called "Comunidade"(1), added the partner users (2), and shared the "test" file with it:

User-added image

The patner user logged in the community, opens the "File" tab and sees the file there:

User-added image

But in the record related list, it does not apear.. only the "Attachment" apears.

User-added image

Some sugestion how can this Files be displayed in the Attachments related lists to the partner community users?

Thanks!

Hi! 
I'm trying to implement the REST callout of this superbadge, but I'm receiving the error 400 "Bad Request. Your JSON does not contain the correct case-sensitive keys. Please reference the sample JSON."
I've already checked each of the keys case, even copied the exact same sample from trailhead, but this message keeps coming. Does anyone have a clue of what could be the problem here?

Here's what I'm trying: (the same behavior happens on both Apex/Postman)


Request/Response:
User-added image

Headers:
User-added image

Auth:User-added image

Thank you!
Hi,

I have in my Org the WorkOrder and WorkOrderLineItens Objects.
I want to display the result of a very specific SOQL query in a Visualforce page.
The point is, in my Apex SOQL query, I bring fields from both objects, and others related... so, how can I declare a single List to receive this SOQL result, with all the returned fields, from all objects?

I'm following this article, but It only uses fields fron a single object, so the List is declared based on that object..
https://help.salesforce.com/articleView?id=000205631&type=1

My SOQL looks like this:
select  	id, LineItemNumber, 
			PricebookEntry.Product2.Name,
			WorkOrder.WorkOrderNumber, WorkOrder.Tipo_de_Servi_o__c
FROM		WorkOrderLineItem
WHERE		UnitPrice = 0	AND 	
			WorkOrder.CreatedDate >= 2017-05-15T00:00:00.000+0000
ORDER BY	LineItemNumber ASC

In developer console, it runs fine:
User-added image

Some sugestion, or other reference that could help me on it?
Thanks.
Hi!

In my org, I have the Opportunity object, that has a related list from a custom object named Proposta__c.
Proposta__c stores some Opportunity fields values, and a custom PDF as attachment, that contains other Opportunity informations.
Proposta__c records are generated only by a button, embedded in the Opportunity layout, as a Visualforce page commandButton (not a object's custom buttom).
So, in the Opportunity, the user clicks on this button, it calls a Apex extension class that I wrote, that creates a Proposta__c record with its fields, and generates/attach the PDF on this record.
Until here, everything is working as expected.

But, after create a Proposta__c record, I need open It, so I decided to use the onComplete commandButton property to do It.
The onComplete works fine to open the new Proposta__c record, but, when I use onComplete, the PDF attachment is generated as a blank page.
Even if I include the onComplete with no actions on it, the PDF still generate as a blank page.
If I remove only the onComplete property, the PDF is generated perfectly, with all its contents.

The point is: How can I generate correctly the regs and PDF, and then open it? maybe with a onComplete alternative..

Bellow are some tests fragments codes, to make it clearer:

proposta_pdf: The Apex extension class, that generates the Proposta__c record and its PDF attachment:
public class proposta_pdf{
    
    public     Opportunity     opp_temp, opp_reg;
    public     Id              prop_reg_id {get;set;}
    public     String          url_base {get;set;}
 
    // constructor ==============================
    public proposta_pdf(ApexPages.StandardController controller) {
        
        // Get base URL (+prefix, if community)
        this.url_base = URL.getSalesforceBaseUrl().toExternalForm() + Site.getPathPrefix();
        
        // Get other values
        this.opp_temp = (Opportunity)controller.getRecord();
        this.opp_reg = [
            SELECT     Id, Name, Amount, Prop_Versao__c
            FROM     Opportunity 
            WHERE     Id =: this.opp_temp.Id
        ];
    }
       
    // geenerate PDF bin ========================
    public Blob gera_prop_blob(){
        PageReference prop_pag = Page.Proposta_Mestre;
        prop_pag.getParameters().put('id',opp_reg.Id);
        
        Blob prop_blob;
        if(!Test.isRunningTest())
            prop_blob = prop_pag.getContentAsPDF();
        else
            prop_blob = Blob.valueOf('Este e um teste.');

        return prop_blob;
    }

    // create Proposta__c reg + PDF attachment ======
    public void salva_proposta_registro(){

        // validation
        if(this.opp_reg.Prop_Versao__c == NULL)
            this.opp_reg.Prop_Versao__c = 0;
        else
            this.opp_reg.Prop_Versao__c++;
        
        // create/save Proposta__c reg
        Proposta__c prop_reg = new Proposta__c(
            Oportunidade__c     = this.opp_reg.Id,
            Name                = this.opp_reg.Name + ' Ver:' + this.opp_reg.Prop_Versao__c,
            Versao__c             = this.opp_reg.Prop_Versao__c,
            Valor__c            = this.opp_reg.Amount
        );
        insert prop_reg;
                
        // update Proposta__c version stored in a Opportunity field
        update this.opp_reg;
                
        // create/save/attach PDF in Proposta__c reg
        Attachment prop_anex = new Attachment(
            ParentId             = prop_reg.Id,
            Body                 = gera_prop_blob(),
            Name                 = this.opp_reg.Name + ' Ver:' + this.opp_reg.Prop_Versao__c + '.pdf'
        );
        insert prop_anex;
        
        // retur ID to open new reg
        prop_reg_id = prop_reg.Id;
    }

}

Proposta_Mestre: The Visualforce page, rendered as PDF. The Proposta__c attachment:
<apex:page standardController="Opportunity" renderAs="pdf" applyHtmlTag="false" showHeader="false">
	
	Testing Opportunity My PDF
	<br/>ID: {!Opportunity.Id}
	<br/>Name: {!Opportunity.Name}
	<br/>
	<br/>End.
	
</apex:page>

proposta_botoes: The visualforce page that contains the button, embedded in Opportunity layout:
<apex:page standardController="Opportunity" extensions="proposta_pdf">
    <apex:form>
        <apex:inputHidden value="{!Opportunity.Id}"/>          
        <apex:commandButton 
            value="Save" 
            action="{!salva_proposta_registro}" 
            onComplete="window.top.location.replace('{!url_base}/{!prop_reg_id}');"
        />
    </apex:form>
</apex:page>

This is what the Opportunity detail page looks like:
User-added image

And the Proposta__c record, created by the button:
User-added image

When I do NOT use the onComplete in the button, the PDF is generated in the right way:
User-added image

And finally, if I add the onComplete in the commandButton, only a blank page is generated:
User-added image

Additionally, I already tried:
 - Add the extensions="proposta_pdf" in the Visualforce PDF page
 - Use the controller.addFields() method to pass the required fields
With no sucess.

I'm preety new in Apex development, so this can be just a detail that I didn't notice, or some mistake.. but after days searching a solution, I'm still not able to figure out how to fix it.

I'd apreciate some sugestions..
And sorry for my bad english, I'm still beginner :)
Thanks.
Hi,

I'm beginner as Salesforce developer/admin, so this may be a easy question to solve.

My Org has the "WorkOrderLineItens" related list, inserted inside the "WorkOrder" layout.

When I'm going to insert a new Item in the WorkOrder, when I chose the Product (PriceBookEntry), I just see 3 columns about to the Product, in the pop-up search layout: "Product Name", "Price List" and "Product Code".

My problem is, I need to see other key fields (standard and custom) at this search pop-up layout, but I'm not knowing how to place they there.
I already tried to change Search Layouts of "Products", "Assets", "PriceBookEntry" and others, but none of them change anything in this specific search layout.

Can anyone give-me a hint, or even tell me if it is really possible to do?

Thanks, and sorry for my very poor english.

I am having the enterprise.wsdl file and i am trying to create a jar file using command 

 

java -classpath wsc-20.jar com.sforce.ws.tools.wsdlc enterprise.wsdl enterprise.jar

 

but getting an error "Error: Unable to find compiler. Make sure that tools.jar is in your classpath:

java.lang.ClassNotFoundException: com/sun/tools/javac/Main.class"

 

can anyone help me..............

 

thank you.......................

knowledge is not in any of my trailhead playgrounds. how do i get it to do trails?