• Ryan Avent 10
  • NEWBIE
  • 15 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 3
    Replies
Im hitting an issue calling a rest endpoint hosted internaly (but can be accessed externamly tested using postman), when preforming a callout from Salesforce apex i get the following error:

salesforce Unable to tunnel through proxy. Proxy returns HTTP/1.1 403 Forbidden

I have tested the endpoint using a variaty of aplications e.g. browsers, postman, java (camel routes) and encounter no issues, so the issue seems to be confined to Salesforce / setup.

The endpoint structure i am hitting is: https:/example.com:444/int/rest/users
 
private static HttpResponse callEndpont(String url, String method, String body, Integer timeout, Map<String,String> headers) {
        Http http = new Http();
        HttpRequest req = new HttpRequest();
        if (body != '') {
            req.setBody(body);
        }
        url = url.replace(' ', '%20');
        req.setEndpoint(url);
        req.setMethod(method);
        if (timeout != null) {
            req.setTimeout(timeout);
        }
        for (String key : headers.keySet()) {
            req.setHeader(key, headers.get(key));
        }
        
        HttpResponse resp;
        try {
            resp = http.send(req);
        }
        catch (Exception e) {
            throw new callException(e.getMessage());
        }
        
        return resp;
    }

Can anyone help me identify the problem here?

Thank you.

Hello i have toast messages that display to users based on diffrent rules, i need this test to be translatable / as well as allow overridable by system admins when the managed package is deployed.

I beleave Custom Metadata fields in conjunction with translation workbench will allow this but i have not idea how to retrieve the data in SOQL, could somone give me an example?

when i try the below all i get is an empty entry.

SELECT Label, ExampleNamespace__Ex_example_field__c FROM ExampleNamespace__Ex_example__mdt

 

I have an app that contains various toast messages based on the user selecting different options on the form, currently the messages are all hard coded and in the base language (English) however i would like to give admins the ability to modify the base text of the message as well as translate it for users in different countries. 


Is there a 'best practices' way of doing this?  

I have a LWC Combobox whos options are pulled from a List of custom objects, and this LWC Combobox is on the Opportunity page. 

The issue is that a new value can be added to the list List of custom objects via another LWC and my Combobox options are not being rereshed.

Combobox Template 
<template>
        <div class="slds-theme_default">

    <lightning-combobox
            name="defaultOption"
            label="Default Option"
            options={options}
            value={value}
            placeholder="Select Default Option"
            onchange={handleChange} >
    </lightning-combobox>

    </div>
</template>

Combobox JS
 
import { LightningElement,  api, wire, track, } from 'lwc';
import updateOpportunityDefault from '@salesforce/apex/CustomDefaultOperations.updateOpportunityDefault';
import getDefaultOptions from '@salesforce/apex/CustomDefaultOperations.getDefaultOptions';
import getDefaultSelected from '@salesforce/apex/CustomDefaultOperations.getDefaultSelected';

import {getSObjectValue} from '@salesforce/apex';


import Id from '@salesforce/schema/Custom_Object_Opp_Default__Options__c.Id';
import custom__Possible__Option__c from '@salesforce/schema/Custom_Object_Opp_Default__Options__c.custom__Possible__Option__c';
import custom__Default__Option__c from '@salesforce/schema/Opportunity.custom__Default__Option__c';


import {ShowToastEvent} from 'lightning/platformShowToastEvent';


export default class opportunityDefaultOptionLWC extends LightningElement {
    
    @track value;
    @track options; 
    @track LastDefaultSelected; // stores the last option selected sucessfuly the combobox options
    @track defaultOptionsKeyValuePair = []; // this is the list of options created by the apex call

    @api sfOppId; // Salesforce Opportunity Id

	// on init get the current default option chosen form opportunity 
    connectedCallback() {
		// call apex that querys the opportuinity and returns an opportunity list (limit 1) to get the current default value form field
        getDefaultSelected({"sfOppId":this.sfOppId})
        .then( result => {
            try{
                console.log(result);
                console.log("getDefaultSelected = " + result);
                result.forEach(element => {
                   this.LastDefaultSelected = getSObjectValue(element, custom__Default__Option__c);
                   console.log("getDefaultSelected: LastDefaultSelected = " + this.LastDefaultSelected);
                });
            }catch (err){
                console.log(err);
                console.log("getDefaultSelected: getDefaultSelected is empty, error \n" + err);
            }
        })
        .catch(error =>{
            this.error = error;
            console.log(this.error);
            console.log("getDefaultSelected: getDefaultSelected, error \n" + this.error);
        })
    }

	// on render get the list of avalible options for default.
    renderedCallback(){
        console.log("renderedCallback: LastDefaultSelected: = "+ this.LastDefaultSelected);
		// call apex that querys a custom object returns a list of all valid options for this opportunity to populat the combobox options
        getDefaultOptions({"sfOppId":this.sfOppId})
        .then( result => {
            try{
                console.log("getDefaultOptions: result from apex below -");
                console.log(result);
				
                result.forEach(element => {
                        var id = getSObjectValue(element, Id);
                        var optionValue = getSObjectValue(element, custom__Possible__Option__c);
                        this.defaultOptionsKeyValuePair.push({ value: id, label: optionValue});
                    });
                    console.log("getDefaultOptions: Options List below -");

					// log list of options generated by apex call
                    console.log(this.defaultOptionsKeyValuePair);
					
					// set combobox options to list generated
                    this.options =  this.defaultOptionsKeyValuePair;
 
            }catch (err){
                console.log(err);
                console.log("getDefaultOptions: getDefaultOptions is empty, error \n" + err);
            }
        })
        .catch(error =>{

            this.error = error;
            console.log(this.error);
            console.log("getDefaultOptions: getDefaultOptions, error \n" + this.error);
        })
        
        this.value = this.LastDefaultSelected;

    }


	//when user selects new combobox value
    handleChange(event) { 
	
        console.log("handleChange: primaryQuoteChange");	
        // log out the orignal default and user selected
		var orignalDefaultOption =  this.value;
        var userSelectedDefaultOption = event.detail.value;
        console.log("handleChange: orignal value = " + orignalDefaultOption);
        console.log("handleChange: Selected value = " + userSelectedDefaultOption);

       try{
            console.log("handleChange: opportunityId = " + this.sfOppId + " userSelectedDefaultOption = " + userSelectedDefaultOption)
            
			// call an apex class that validates the option selected is valid for default selection
			updateOpportunityDefault({"opportunityId":this.sfOppId, "userSelectedDefaultOption":userSelectedDefaultOption})
                .then(() => {
                        console.log("handleChange: default updated.");

                        this.LastDefaultSelected = userSelectedDefaultOption;
                        console.log("handleChange: response success LastDefaultSelected = " + this.LastDefaultSelected);
                        const showsuccess = new ShowToastEvent({
                            title: 'Default Option Updated',
                            message: 'The Opprtunity Default Option has been updated to ' + userSelectedDefaultOption ,
                            variant: 'success'
                        });
                        this.dispatchEvent(showsuccess);
                    })
                    .catch(error => {
                        console.log("handleChange: Default Option update failed.");
                        this.LastDefaultSelected = orignalDefaultOption;

                        console.log("handleChange: response error LastDefaultSelected = " + this.LastDefaultSelected);
                        this.value = this.LastDefaultSelected;

                        console.log(error.body);
                    

                        var message = 'Error message: ' + error.body.message;
                        

                        const showerror = new ShowToastEvent({
                            title: 'Default Option Update Failed',
                            message: message,
                            variant: 'error',
                            mode: 'sticky'
                        });
                        this.dispatchEvent(showerror);
                    });


            }catch (err){
                console.log("handleChange: handleChange, error \n" + err);
                this.LastDefaultSelected = orignalDefaultOption;
                console.log("handleChange: Error LastDefaultSelected = " + this.LastDefaultSelected);
                this.value = this.LastDefaultSelected;

            }

        }
}

How can i make the renderedCallback() retrigger or the options list regenerate when a new record is added the the Salesforce Custom Object.  

I am currently trying to complete the trailhead 'Create a Hello World Lightning Web Component' section where you deploy the lightning web component from VSCode to your org, and im hitting the below error.

Starting SFDX: Deploy Source to Org

18:12:03.382 sfdx force:source:deploy --sourcepath c:\Users\ravent\Documents\SFDX Projects\HelloWorldLightningWebComponent\force-app\main\default --json --loglevel fatal
18:12:07.153 sfdx force:source:deploy --sourcepath c:\Users\ravent\Documents\SFDX Projects\HelloWorldLightningWebComponent\force-app\main\default --json --loglevel fatal ended with exit code 1

sf:UNSUPPORTED_API_VERSION: UNSUPPORTED_API_VERSION: Invalid Api version specified on URL

 

helloWorld error

As far as i can see i have followed the instructions to the letter, and cant seem to correct the error.

Any suggestions would be greatly appreachiated.

Im hitting an issue calling a rest endpoint hosted internaly (but can be accessed externamly tested using postman), when preforming a callout from Salesforce apex i get the following error:

salesforce Unable to tunnel through proxy. Proxy returns HTTP/1.1 403 Forbidden

I have tested the endpoint using a variaty of aplications e.g. browsers, postman, java (camel routes) and encounter no issues, so the issue seems to be confined to Salesforce / setup.

The endpoint structure i am hitting is: https:/example.com:444/int/rest/users
 
private static HttpResponse callEndpont(String url, String method, String body, Integer timeout, Map<String,String> headers) {
        Http http = new Http();
        HttpRequest req = new HttpRequest();
        if (body != '') {
            req.setBody(body);
        }
        url = url.replace(' ', '%20');
        req.setEndpoint(url);
        req.setMethod(method);
        if (timeout != null) {
            req.setTimeout(timeout);
        }
        for (String key : headers.keySet()) {
            req.setHeader(key, headers.get(key));
        }
        
        HttpResponse resp;
        try {
            resp = http.send(req);
        }
        catch (Exception e) {
            throw new callException(e.getMessage());
        }
        
        return resp;
    }

Can anyone help me identify the problem here?

Thank you.

Hello i have toast messages that display to users based on diffrent rules, i need this test to be translatable / as well as allow overridable by system admins when the managed package is deployed.

I beleave Custom Metadata fields in conjunction with translation workbench will allow this but i have not idea how to retrieve the data in SOQL, could somone give me an example?

when i try the below all i get is an empty entry.

SELECT Label, ExampleNamespace__Ex_example_field__c FROM ExampleNamespace__Ex_example__mdt

 

I am currently trying to complete the trailhead 'Create a Hello World Lightning Web Component' section where you deploy the lightning web component from VSCode to your org, and im hitting the below error.

Starting SFDX: Deploy Source to Org

18:12:03.382 sfdx force:source:deploy --sourcepath c:\Users\ravent\Documents\SFDX Projects\HelloWorldLightningWebComponent\force-app\main\default --json --loglevel fatal
18:12:07.153 sfdx force:source:deploy --sourcepath c:\Users\ravent\Documents\SFDX Projects\HelloWorldLightningWebComponent\force-app\main\default --json --loglevel fatal ended with exit code 1

sf:UNSUPPORTED_API_VERSION: UNSUPPORTED_API_VERSION: Invalid Api version specified on URL

 

helloWorld error

As far as i can see i have followed the instructions to the letter, and cant seem to correct the error.

Any suggestions would be greatly appreachiated.