• gitguy
  • NEWBIE
  • 90 Points
  • Member since 2011
  • Sr. Director Application Development
  • HW Kaufman Financial Group, Inc.

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 33
    Replies

Hi Salesforce Gurus,

 

How to access custom settings? Custom settings data can then be used by formula fields, validation rules, Apex, and the Web services API only?? Can't we access custom settings in our Visualforce page? if we can, How to access it on our visual force page?

I have a single object deployed to two organizations.  One org supports multi-currency and the other doesn't.  When I serialize the object in the multi-currency org (source) and try deserializing it on the one that doesn't (destination) I get the error:

 

No such column 'CurrencyIsoCode' on sobject of type Feedback_Config__c

 

It is true, Feedback_Config__c in the destination org doesn't have the field, CurrencyIsoCode.  But according to the documentation it shouldn't need it.

 

"If the JSON content to parse contains attributes not present in the Apex type specified in the argument, such as a missing field or object, this method ignores these attributes and parses the rest of the JSON content. However, for Apex saved using Salesforce.com API version 24.0 or earlier, this method throws a run-time exception for missing attributes."

 

As my class is compiled api 27.0, the last part shouldn't be true.

 

Does anyone know if there's a reason Json.Deserialize(string, Feedback_Config__c.class) would fail when it shouldn't?  Is it something special about SObjects?

 

 

  • March 26, 2013
  • Like
  • 0

I need to create a javascript button that can be added to STANDARD salesforce pages.  I'm pretty sure that means no components, no controllers, and no Javascript Remoting.

 

The problem within the javascript is the rest service isn't accessible from the domain of the page, but using the correct domain isn't allowed because that would be a cross-site javascript blah blah blah error.

 

First, the Javascript behind the button.

xhr = new XMLHttpRequest();
xhr.open( "GET", "/services/apexrest/FeedbackRest?action=popup&config=Default", false);
xhr.setRequestHeader("Authorization", "Bearer " + "{!$Api.Session_Id}");
xhr.send();

 

I was getting "NETWORK_ERR: XmlHttpRequest Exception 101" errors so I thought I'd try it from curl.

 

Curl showed us the problem.

 

 

$ curl 'https://c.na12.visual.force.com/services/apexrest/FeedbackRest?action=popup&config=Default' -H 'Authorization : Bearer 00DU0000000JmJK!AQ8AQKbqpU8utH9Qktzhie.Rz4mYmz9fqWX9n4nZk4mvkRNAOpvT53ZVLgw1osUF3mdpLDdcS4Xa8xSxY3s4CxhVIcUbZ203' -v

> GET /services/apexrest/FeedbackRest?action=popup&config=Default HTTP/1.1
> User-Agent: curl/7.26.0
> Host: c.na12.visual.force.com
> Accept: */*
> Authorization : Bearer 00DU0000000JmJK!AQ8AQKbqpU8utH9Qktzhie.Rz4mYmz9fqWX9n4nZk4mvkRNAOpvT53ZVLgw1osUF3mdpLDdcS4Xa8xSxY3s4CxhVIcUbZ203
>
< HTTP/1.1 302 Found
< Date: Sat, 23 Mar 2013 13:43:13 GMT
< Location: https://na12.salesforce.com/services/apexrest/FeedbackRest?action=popup&config=Default
< Content-Length: 0
<

So I changed the domain to the simpler na12.salesforce.com and everything worked.  It found the service.

 

Trying to use that domain in the Javascript causes two interesting problems.  First, the Authorization header doesn't seem to get set in either Chrome or Firefox.  When I look inside the JS debuggers neither shows the header set.

 

But both complain "Method not allowed."  

 

Does anyone know of a trick to make a REST call from inside a Javascript button without the help of controllers?

 

 

 

 

 

  • March 23, 2013
  • Like
  • 0

I've created a visualforce page using the Account standard controller inside the service console.

 

Under normal circumstances and normal embedded pages, the code below seems to work just fine.

 

currentPage = document.location.href;
if (window != window.top)
    currentPage = document.referrer;

 When window != window.top, then we're an iframe and document.referrer gives me the answer I want.

 

But, when I'm inside a service console layout, none of the attempts below seem to produce anything useable.

 

alert(document.location.href); 
alert(document.referrer); 
alert(window.top.location.href); 
alert(window.location.href); 

 And certainly, none of them fit inside a visualforce URL datatype field limited to 255 characters, but that's another complaint.

 

Does anyone have an idea how I'm supposed to get a usable URL from inside an iframe on a service console page layout?

  • January 30, 2013
  • Like
  • 0

I've created a publicly accessible REST service that has been working for a couple weeks.  I can GET its URI using Firefox, and POST its URI using curl -- both without authentication (as designed).

 

What has stopped working today is the ability to POST to it from another SF org using Salesforce.  The simple code below is timing-out.

 

Http http = new Http();
HttpRequest request = new HttpRequest();
request.setMethod('POST');
request.setEndpoint('https://mysite.secure.force.com/services/apexrest/FeedbackRest?ignore=true');
Httpresponse response = http.send(request);
system.debug(response.getBody());

 

To verify the destination is working, I've tested the following curl command and it works, and returns in less than a second.

 

time curl -v https://mysite.secure.force.com/services/apexrest/FeedbackRest -d ignore=true
> POST /services/apexrest/FeedbackRest HTTP/1.1
> User-Agent: curl/7.21.6 (i686-pc-linux-gnu) libcurl/7.21.6 OpenSSL/1.0.0e zlib/1.2.3.4 libidn/1.22 librtmp/2.3
> Host: mysite.secure.force.com
> Accept: */*
> Content-Length: 11
> Content-Type: application/x-www-form-urlencoded
> 
< HTTP/1.1 200 OK
< Server: 
< Content-Type: application/xml; charset=ISO-8859-1
< Date: Sat, 24 Nov 2012 18:53:36 GMT
< Transfer-Encoding: chunked
< 
* Connection #0 to host mysite.secure.force.com left intact
* Closing connection #0
* SSLv3, TLS alert, Client hello (1):
<?xml version="1.0"?><feedback version="1.0" type="Success" id="a0b60000005T4lMAAS"></feedback>
real	0m0.827s
user	0m0.008s
sys	0m0.020s

This had been working earlier in the week, but is suddenly not working today.  The remote sites are setup correctly else I would have gotten an invalid site error.  I have't exceeded a governor limit else I would have gotten a limit exception.

 

Is anyone else noticing this issue?

  • November 24, 2012
  • Like
  • 0

If a single email hander is used for multiple email services, and if the address can be either in the to, cc, or bcc, how can the handler tell which was the address that resulted in it receiving the message?

 

If two email address are both formatted '.....@salesforce.com' that may not be enough to know which *mine* is.

 

Is there a field in the inbound object that identifies which address is mine?

 

Why am I interested?

 

Our system can create an outbound email and we want to record that it was a) successfully sent and more importantly that b) it was delivered.  We want to chatter the reception, but need to communication which ID to post to.

 

We thought we could use the "info <an-email-address>" format.  We can find this information in the email headers, but want to be more discriminating and make sure we pick-out the right one.  If we knew our email address (which changes on every org) then we could find the right inbound.header and extract the target id from it.

  • October 23, 2012
  • Like
  • 0

I'd like to include some documentation with a managed package, but I'm uncertain how such a thing would be done.  A VF page doesn't seem like the right place (how would they find it?) and I don't want to use any standard objects that require special licensing beyond a platform.

  • October 11, 2012
  • Like
  • 0

How do I test upgrading packages if I can't upgrade a beta package?

 

If an organization creates some valuable data using a beta package and subsequently wants to install the full version, why must they lose all their data in the process?

  • October 11, 2012
  • Like
  • 0

My client's application is /mostly/ callouts.  In one case, we actually do have a SF object we'd like to post chatter to.

 

I don't want the chatter message (another callout) slowing-down response time so I tried prefixing @future (callout=true).  You'll see in the code below it's a straightforward class.

 

Without @future, the post works fine but response time is impacted.  If I add @future I get the response, [{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}], followed by that obnoxious "You have uncommitted..." nonsense (there is no DML in the debug log and only one SOQL execute).

 

Is there a simple solution to this?

 

public class Cheep {
    @future (callout=true) public static void PostMessage(string anId, string message)
    {
        message = message.replaceAll('\n', '\\\\n');
        
        PostMessageTo(
            URL.GetSalesforceBaseURL().toExternalForm() + '/services/data/v23.0/chatter/feeds/record/' + anId + '/feed-items', 
            message
        );    
    }    
    
    static void PostMessageTo(string location, string message)
    {
        HttpRequest req = new HttpRequest();
        Http http = new Http();
        req.setEndpoint(location);    
        req.setMethod('POST');
        req.setHeader('Authorization', 'OAuth ' + userInfo.getSessionId());
        req.setHeader('Content-Type', 'application/json');
        req.setBody('{ "body" : { "messageSegments" : [{"type": "Text","text" : "' + message + '"}]}}');

        try {         
            system.debug(req.getBody()); 
            HTTPResponse resp = http.send(req);            
            
            if (resp.getStatusCode() == 302)
                PostMessageTo(resp.getHeader('Location'), message);            
            else    
                system.debug(resp.getBody());
        }
        catch (Exception ex)
        {
            system.debug('Exception thrown : ' + ex.getMessage());
        }
    }    
}

 

 

  • August 09, 2012
  • Like
  • 0

I have a single object deployed to two organizations.  One org supports multi-currency and the other doesn't.  When I serialize the object in the multi-currency org (source) and try deserializing it on the one that doesn't (destination) I get the error:

 

No such column 'CurrencyIsoCode' on sobject of type Feedback_Config__c

 

It is true, Feedback_Config__c in the destination org doesn't have the field, CurrencyIsoCode.  But according to the documentation it shouldn't need it.

 

"If the JSON content to parse contains attributes not present in the Apex type specified in the argument, such as a missing field or object, this method ignores these attributes and parses the rest of the JSON content. However, for Apex saved using Salesforce.com API version 24.0 or earlier, this method throws a run-time exception for missing attributes."

 

As my class is compiled api 27.0, the last part shouldn't be true.

 

Does anyone know if there's a reason Json.Deserialize(string, Feedback_Config__c.class) would fail when it shouldn't?  Is it something special about SObjects?

 

 

  • March 26, 2013
  • Like
  • 0

I need to create a javascript button that can be added to STANDARD salesforce pages.  I'm pretty sure that means no components, no controllers, and no Javascript Remoting.

 

The problem within the javascript is the rest service isn't accessible from the domain of the page, but using the correct domain isn't allowed because that would be a cross-site javascript blah blah blah error.

 

First, the Javascript behind the button.

xhr = new XMLHttpRequest();
xhr.open( "GET", "/services/apexrest/FeedbackRest?action=popup&config=Default", false);
xhr.setRequestHeader("Authorization", "Bearer " + "{!$Api.Session_Id}");
xhr.send();

 

I was getting "NETWORK_ERR: XmlHttpRequest Exception 101" errors so I thought I'd try it from curl.

 

Curl showed us the problem.

 

 

$ curl 'https://c.na12.visual.force.com/services/apexrest/FeedbackRest?action=popup&config=Default' -H 'Authorization : Bearer 00DU0000000JmJK!AQ8AQKbqpU8utH9Qktzhie.Rz4mYmz9fqWX9n4nZk4mvkRNAOpvT53ZVLgw1osUF3mdpLDdcS4Xa8xSxY3s4CxhVIcUbZ203' -v

> GET /services/apexrest/FeedbackRest?action=popup&config=Default HTTP/1.1
> User-Agent: curl/7.26.0
> Host: c.na12.visual.force.com
> Accept: */*
> Authorization : Bearer 00DU0000000JmJK!AQ8AQKbqpU8utH9Qktzhie.Rz4mYmz9fqWX9n4nZk4mvkRNAOpvT53ZVLgw1osUF3mdpLDdcS4Xa8xSxY3s4CxhVIcUbZ203
>
< HTTP/1.1 302 Found
< Date: Sat, 23 Mar 2013 13:43:13 GMT
< Location: https://na12.salesforce.com/services/apexrest/FeedbackRest?action=popup&config=Default
< Content-Length: 0
<

So I changed the domain to the simpler na12.salesforce.com and everything worked.  It found the service.

 

Trying to use that domain in the Javascript causes two interesting problems.  First, the Authorization header doesn't seem to get set in either Chrome or Firefox.  When I look inside the JS debuggers neither shows the header set.

 

But both complain "Method not allowed."  

 

Does anyone know of a trick to make a REST call from inside a Javascript button without the help of controllers?

 

 

 

 

 

  • March 23, 2013
  • Like
  • 0

I've created a visualforce page using the Account standard controller inside the service console.

 

Under normal circumstances and normal embedded pages, the code below seems to work just fine.

 

currentPage = document.location.href;
if (window != window.top)
    currentPage = document.referrer;

 When window != window.top, then we're an iframe and document.referrer gives me the answer I want.

 

But, when I'm inside a service console layout, none of the attempts below seem to produce anything useable.

 

alert(document.location.href); 
alert(document.referrer); 
alert(window.top.location.href); 
alert(window.location.href); 

 And certainly, none of them fit inside a visualforce URL datatype field limited to 255 characters, but that's another complaint.

 

Does anyone have an idea how I'm supposed to get a usable URL from inside an iframe on a service console page layout?

  • January 30, 2013
  • Like
  • 0

I've created a publicly accessible REST service that has been working for a couple weeks.  I can GET its URI using Firefox, and POST its URI using curl -- both without authentication (as designed).

 

What has stopped working today is the ability to POST to it from another SF org using Salesforce.  The simple code below is timing-out.

 

Http http = new Http();
HttpRequest request = new HttpRequest();
request.setMethod('POST');
request.setEndpoint('https://mysite.secure.force.com/services/apexrest/FeedbackRest?ignore=true');
Httpresponse response = http.send(request);
system.debug(response.getBody());

 

To verify the destination is working, I've tested the following curl command and it works, and returns in less than a second.

 

time curl -v https://mysite.secure.force.com/services/apexrest/FeedbackRest -d ignore=true
> POST /services/apexrest/FeedbackRest HTTP/1.1
> User-Agent: curl/7.21.6 (i686-pc-linux-gnu) libcurl/7.21.6 OpenSSL/1.0.0e zlib/1.2.3.4 libidn/1.22 librtmp/2.3
> Host: mysite.secure.force.com
> Accept: */*
> Content-Length: 11
> Content-Type: application/x-www-form-urlencoded
> 
< HTTP/1.1 200 OK
< Server: 
< Content-Type: application/xml; charset=ISO-8859-1
< Date: Sat, 24 Nov 2012 18:53:36 GMT
< Transfer-Encoding: chunked
< 
* Connection #0 to host mysite.secure.force.com left intact
* Closing connection #0
* SSLv3, TLS alert, Client hello (1):
<?xml version="1.0"?><feedback version="1.0" type="Success" id="a0b60000005T4lMAAS"></feedback>
real	0m0.827s
user	0m0.008s
sys	0m0.020s

This had been working earlier in the week, but is suddenly not working today.  The remote sites are setup correctly else I would have gotten an invalid site error.  I have't exceeded a governor limit else I would have gotten a limit exception.

 

Is anyone else noticing this issue?

  • November 24, 2012
  • Like
  • 0

Hiii.....how to write a SOQL query where we don't know the value of "WHERE" condition..

  Thank you

Hi Salesforce Gurus,

 

How to access custom settings? Custom settings data can then be used by formula fields, validation rules, Apex, and the Web services API only?? Can't we access custom settings in our Visualforce page? if we can, How to access it on our visual force page?

Can anyone tell me how to deploy App Permissions section of the profile (checkboxes like Edit Self-Service Users, Edit Case Comments etc) with Migration Tool?

Hello All-

Can someone help me understand this error...

CALLOUT_REQUEST|[122]|System.HttpRequest[Endpoint=https://153.289.105.42/SMSSend, Method=POST]

EXCEPTION_THROWN|[122]|System.CalloutException: java.security.cert.CertificateException: No subject alternative names present
But when I use the Endpoint as https://sample.com/SMSSend it works fine... Do I need to do anything to get rid of this error???

Thanks.

  • May 08, 2012
  • Like
  • 0

Hi All,

 

I want to get all fieldnames of a object in apex. How can I do this?

 

For example for User object I want to get all its field names like AboutMe, AccountId , Email etc.

 

Any help on this really appreciated.

 

Regards,

Naren

  • January 18, 2012
  • Like
  • 0

Hello,

 

Does anybody know how to post a chatter FeedItem object from a Site as Guest user? Guest user doesn't have write access to Chatter object and there is no configuration in Salesforce to allow it. Is there any design pattern / solution / workaround to this problem? The easiest way would be to use some kind of System.runAs() method to run my code as system admin, but unfortunately Saleforce supports that only in test methods :-/

 

Thanks in advance for any advice ,

Jan

  • September 22, 2011
  • Like
  • 0

I have had the audit fields (created by, created dates, last modified by, etc) opened by sfdc, and need to see if there is a way to populate these via an update rather than an insert. Through the data loader, they are only available via insert. Is this a data loader limitation or a salesforce limitation? We also have DB Amp, and do not have access on an update either. Anyway around this?

How to use two standard controller in one visualforce page?

plz send examples.

While the API docs have a lot of great examples using cURL, I don't see an example of how to actually obtain the access token. I tried the following with no joy:

 

 

curl grant_type=authorization_code \
  client_id=MY-CONSUMER-KEY \
  client_secret=MY-CONSUMER-SECRET \
  https://na5.salesforce.com/services/oath2/token

 

 

Thanks

 

Jeff Douglas

Appirio, Inc.

http://blog.jeffdouglas.com

 

Author: The Salesforce Handbook

Hi all,

 

How can I tell my Visualforce page is accessed from customer portal?
Is there a profile, permission or system flag that i can check?

 

Thanks,

John

Hi,

 

I know there have been some posts about this but none seem to suggest a working answer.

 

I'd like to be able to write a documents body directly to the browser and set the content type so that the contents are treated correctly by the browser.

 

So far I have for an image:-

apex: public string theBody {get; set;} public const(){ Document d = [select body from document limit 1]; theBody = d.EncodingUtil.base64encode(d.body); VF: ... <img src="data:image/jpeg:base64, {!theBody}"/>

...

 

 

Which works ok.

 

For a document e.g. application/msword this approach won't work.

 

I have tried writing out the body directly and body.toString() but none work (even with setting the contentType correctly). If the contentType is set then word just decides to open the data as text inside the document.

 

Has anybody managed this? Is it possible?

 

Thanks for any help.

 

R.

Hello Friends,

 

My requirement is that, i need to generate an XML out of my VF page. For this, i specified the "ContentType="application/xml" on my page header and then included the DOCTYPE tags to generate a standard XML out of it.

 

But somehow, i am not able to get the XML styling in the generated page and it shows me the shole page elements intead of just showing me the data.

 

Can you please let me know where i am going wrong or is this possible in VF? Pasting my VF page code below:

 

 

<apex:page cache="true" Controller="TestController" contentType="application/xml" showHeader="false">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/html" xml:lang="en" lang="en">
<body>
<apex:form >
<apex:pageblock id="exportDocs">
<apex:pageBlockTable value="{!exportValues}" var="actual">
<apex:column headerValue="Id" value="{!actual.Id}"/>
<apex:column headerValue="Act Name" value="{!actual.Name}"/>
<apex:column headerValue="MType" value="{!actual.A_Type__c}"/>
<apex:column headerValue="Country" value="{!actual.Country__c}"/>
<apex:column headerValue="B" value="{!actual.B__c}"/>
<apex:column headerValue="Actual C" value="{!actual.C__c}"/>
<apex:column headerValue="Actual G" value="{!actual.G__c}"/>
<apex:column headerValue="Actual I" value="{!actual.I__c}"/>
</apex:pageBlockTable>
</apex:pageblock>
</apex:form>
</body>
</html>
</apex:page>

 

Any help/guidance would be highly appreciated!!

 

Many Thanks,

Cool_D