• Binayak
  • NEWBIE
  • 25 Points
  • Member since 2012

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 17
    Replies

Hi,

 

Currently I am working on Web services. I want to display specifc details of account record like Name, Phone, Fax, Description using APEX web services. Everthing is going cool.. but the problem is I have a custom field named as logo (data type=Rich Text Area). I want to display this field on client side when I am invoking the method..But when I am trying this it's not showing image unless I have logged in salesforce.com account. because the image url is like this

https://c.ap1.content.force.com/servlet/rtaImage?eid=0019000000NR7gE&feoid=00N90000004woLD&refid=0EM900000004YsG

 

how to display image on client side.

 

any suggestions !!!!!!!!!!!!!!!!!!!1

 

Thanks,

kiran

 Is it possible in Salesforce to compress the size of image uploaded (say from 4-5 mb to 1mb) with the help of javascripts/jquery libs or any other approach?It has to be done in bulk.

We have a scenerio where we have to send some data(in json) from XYZ system and save it in Contact object via Apex REST. Now the size of the file is >3 mb.So we have decided to split it into 2 files and send it.But the problem is that Contact have a lookup to contact itself(related_to_contact__c).Some of the related to contacts are in the other file while sending a file.So its creating exception.Any possible workaround?

How to access the domain name of the salesforce org from the sites page(i.e. if org is https://cs7.salesforce.com,then accessing it from sites page). System.URL.getSalesforceBaseUrl().getHost() didnot provide the proper result.Still we can substring it to get the results.But from sites page,it fails.Donot want to store it in a label and then access it from the controller of the site page.Any idea for retrieving the value dynamically....

When i am trying to insert 2 contacts at 1 go using the external id field(extfld__c)..like

Contact c1 = new Contact(FirstName = 'F1',LastName='L1',extfld__c='e1');
Contact c2 = new Contact(FirstName = 'F2',LastName='L2',extfld__c='e2',ReportsTo=new Contact(extfld__c='e1'));
List<Contact> l = new List<Contact>();
l.add(c1);
l.add(c2);
try{
    upsert l;
}
catch(Exception e)
{
    System.debug('Exception::'+e.getMessage());
}

Its throwing exception:

First exception on row 1; first error: INVALID_FIELD, Foreign key external ID: e1 not found for field extfld__c in entity Contact: []
07:47:23.388 (388572000)|SYSTEM_METHOD_EXIT|[11]|System.debug(ANY)


But when trying with the Account and contact like:

Account a = new Account(name='Test Con',extfldAcc__c='1234TestAcc');
Contact c2 = new Contact(FirstName = 'F2',LastName='L2',extfld__c='e2',Account = new Account(extfldAcc__c='1234TestAcc'));
insert new List<Sobject>{a, c2};

its inserting(while extfldAcc__c is the external id field for Account).

Can any one help me for overcoming the exception while inserting 2 contacts at the same go.

I have a small piece of code:

 


Map<List<String>,String> mapLstStr =  new Map<List<String>,String>();
List<String> lst1 = new List<String>();
List<String> lst2 = new List<String>();

lst1.add('A');
lst1.add('B');

lst2.add('A');
lst2.add('C');

mapLstStr.put(lst1,'ABCD');
mapLstStr.put(lst2,'ABCDE');

System.debug('****'+mapLstStr);

 

 

When i execute it in developer console,its showing 'Internal System Error: 1311241958-36767 (-1213750749)'.Can anybody please help me to debug this piece.

'

Can we query secrete question from User object's records?


From SalesForce ,we have to make some REST callouts to a different server(say SERVER A).But while making the callouts,we are facing an exception of

System.CalloutException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target.

Now,Server A is certified by a CA (self-signed certificate) which does not fall under the list of CAs supported be Salesforce.We cannot ask the server owners to upgrade their CA.Is there any possible work around for overcoming this sort of exception?

  • September 05, 2012
  • Like
  • 0

I have a requirement to search data immediately  from around 16 salesforce orgs. Since connecting and getting data from a single org needs  two callouts, i easily hit the callout limit. Could anyone suggest me a work-around..

@future wont help as I need the result immediately

Hi Everyone,

I created the class and exposed has. WSDL and I am able to get the session id and and the result,

I need to send as JSON response for third party Application.

 

How do parse the JSON and how to send the response?

 

global class AccountServices
{
    webService static String hello(String Name,String Phone,String Website)
    {
    
      Account accounts = [SELECT id, name,phone,website FROM Account LIMIT 1];
      return 'Hello '+accounts.name+' '+accounts.Phone+' '+accounts.Website+' ! :D';
   
    }
}

  • September 25, 2013
  • Like
  • 0

Greetings!

 

I have an extremely simple Salesforce app I've created for a non-profit.  For one of my custom objects, called Donation, I created a custom button called 'Receipt' that runs Visual Force code to create a PDF that renders in a separate window.   This VF code runs perfectly fine in my development account (a DE).  However, when I create a package of my app and install it on another DE, that the non-profit will be using, this VF code for this button does not work.  Instead, I get the following error message:

 

Visualforce Error


common.apex.runtime.impl.ExecutionException: SObject row was retrieved via SOQL without querying the requested field: srdforce__Donation__c.srdforce__Check_No__c

 

Here is the VF code for button 'Receipt':

 

<apex:page standardController="srdforce__Donation__c" showHeader="FALSE" standardStylesheets="false" renderas="pdf">

{! IF(ISBLANK(Donation__c.Check_No__c), "PLEASE ENTER Check Number BEFORE PRINTING RECEIPT", "")}

<center>
<hr style="color: 'black'; height: '1'; text-align: 'center'; width: '50%'"/>
Indo-American Cultural &amp; Religious Foundation<br/>
P.O. Box 35275 &nbsp;&nbsp;&nbsp; Phoenix AZ 85069<br/>
Tax ID: 86-0620445 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; A non-profit organization - IRS Section 501(c)(3)<br/><br/>
<strong style="font-size:20px">IACRF Donation Receipt</strong>
<hr style="color: 'black'; height: '1'; text-align: 'center'; width: '50%'"/>

<strong>Receipt No:</strong> {!Donation__c.Receipt_Number__c} &nbsp;&nbsp;&nbsp;&nbsp;
<strong>Donation Amount:</strong>&nbsp;&nbsp;<apex:outputField value="{!srdforce__Donation__c.srdforce__Donation_Amount__c}"/> &nbsp;&nbsp;&nbsp;&nbsp;
<strong>Check No:</strong>&nbsp;&nbsp;{!Donation__c.Check_No__c}&nbsp;&nbsp;&nbsp;&nbsp;
<strong>Date:</strong>&nbsp;&nbsp;<apex:outputText value="{!MONTH(TODAY())}"/>/<apex:outputText value="{!DAY(TODAY())}"/>/<apex:outputText value="{!YEAR(TODAY())}"/>
</center>

<br/>

<!-- Show Mailing Address -->
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
{!Donation__c.Donor__r.First_Name__c} {!Donation__c.Donor__r.Last_Name__c}<br/>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
{!Donation__c.Donor__r.Address__c}<br/>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
{!Donation__c.Donor__r.City__c}, {!Donation__c.Donor__r.State__c}  {!Donation__c.Donor__r.Postal_Code__c}<br/>

<br/><br/><br/><br/><br/>
Received above donation on &nbsp;&nbsp; <strong><apex:outputField value="{!srdforce__Donation__c.srdforce__Date__c}"/></strong><br/><br/>

The Foundation and Bharatiya EKTA Mandir appreciate your loyalty and support, and gratefully acknowledge your generous donation.<br/><br/><br/>
Thank you,

<br/><br/><br/><br/><br/><br/>

Lalit Patel <br/>
Treasurer <br/>
IACRF/Bharatiya EKTA Mandir

<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>

<center>
No goods or services were provided as a part your donation.<br/>
NOTE: Your contribution is tax deductible to the extent permitted by the IRS.<br/>
Please consult your tax advisor.
</center>
</apex:page>

 

 

Any help or suggestion for debugging this is welcome!

 

Regards,

Sangita

  • September 24, 2013
  • Like
  • 0

Hi Everybody,

I am trying to integrate salesforce with facebook , and the following is the request i am doing

 

HttpRequest req = new HttpRequest();
req.setEndpoint('https://graph.facebook.com/'+Facebookuserid+'/feed');
req.setHeader('access_token',token);
req.setBody('message='+statusupdate);
req.setMethod('POST');
HttpResponse res = h.send(req);

 

I am getting the error message as "This API call requires a valid app_id."

 

Help me how to make the post request.

 

Thanks in Advance,

Ranjith

 

Hi,

 

I am trying to integrate salesforce via my web app. I am able to do that by defining Remote Access Application via salesforce developers login to get the consumer key and consumer secret id and than login using the salesforce id.

Is there any way for me to avoid defining Remote Access Application and still allow the users to access their salesforce account via my app only by using the username/password in a protective way ?

 

Any pointers on this regard will be of great help.

Thanks in advance

 

 

Hi,

 

Currently I am working on Web services. I want to display specifc details of account record like Name, Phone, Fax, Description using APEX web services. Everthing is going cool.. but the problem is I have a custom field named as logo (data type=Rich Text Area). I want to display this field on client side when I am invoking the method..But when I am trying this it's not showing image unless I have logged in salesforce.com account. because the image url is like this

https://c.ap1.content.force.com/servlet/rtaImage?eid=0019000000NR7gE&feoid=00N90000004woLD&refid=0EM900000004YsG

 

how to display image on client side.

 

any suggestions !!!!!!!!!!!!!!!!!!!1

 

Thanks,

kiran

Hi,

 

Using http GET method, is it possible to ask list of articles through REST API?

 

E.g. call: https://emea.salesforce.com/services/data/v27.0/knowledgeManagement/articles with correct access token.

 

Response:

article=/services/data/v27.0/knowledgeManagement/articles/<ArticleID>

articleVersions=/services/data/v27.0/knowledgeManagement/articleVersions

knowledgeManagement=/services/data/v27.0/knowledgeManagement

 

Or if I want to get specific Article, from where I do get the Article Id?

 

/Roope

  • April 02, 2013
  • Like
  • 0

I have to make callout to an external REST service from salesforce. Service provider has shared an 'HTTPS' endpoint with me.

I am able to access the service by simply pasting service endpoint in browser, and it returns a JSON response. But when I try to invoke same endpoint from Salesforce it does not work and gives below error:

sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

I contacted my service provider and they mentioned that the service is working in browser because the browser trusts my service provider's certificate and similarly Salesforce should also trust the certificate.

I downloaded the certificate from the browser and tried to add it to callout as in Approach-1 and Approach-2 below. And also tried to add a salesforce self-signed certificate as in Approach-3 below. But every time I get the same error.

HttpRequest request = new HttpRequest();
String endpoint = 'https://serviceprovider.com/querystring';
request.setEndPoint(endpoint);

///Approach-1////
//String cert1 = 'certificate details';
//request.setClientCertificate(cert1,'password');

///Approach-2////
//String cert1 = 'certificate details';
//String cert2 = EncodingUtil.base64Encode(Blob.valueOf(cert1));
//request.setClientCertificate(cert2,'password');

///Approach-3////
request.setClientCertificateName('Testing');

request.setMethod('GET');
HttpResponse response = httpProtocol.send(request);
System.debug('######'+response.getBody());

Any help to resolve the issue will be appriciated.
Thanks in advance.

Hi all

I have create the following Restfull  Http webservice in Apex

 

RestResource(urlMapping='/sfdcWebservice/*')

global class RESTCaseController {

@HttpPost 
global static String GetXml() 
{
try 
{
RestRequest req = RestContext.request;
RestResponse res = Restcontext.response;

blob Body = req.requestbody;
string str=body.toString(); 
}
catch(Exception E)
{
system.debug('ERROR :' +e.getMessage());
}

return null;
}
}

 

End Url :https://ap1.salesforce.com/services/apexrest/sfdcWebservice

 

But this url is not working.

 

I searched and found that some authentication is required.

 

what changes i have to make in the code and to my account 

so that external server will be able to post xml to my End url.

 

Pls help me

 

Hello,

 

I am currently bulding an integration application which allows Salesforece object to sync data with a SharePoint list.

We need a way to create and add a custom button to object's layout through dynamically.

 

Is it possible to create and add a custom button via API?

 

FYI, the custom button will execute the following Javascript

 

window.open('/apex/Redirect?control=workplan&object=MyApp__Project__c&id={!MyApp__Project__c.Id}', 'Work Planner', 'height = 600, width = 1000');

 

We need to add the button dynamically because the value for the controlobject and title (Work Planner) parameters will be determined at the time user maps the object in Salesforce to a list in SharePoint from the UI provided by SharePoint.

 

Thanks a lot for looking into this.

  • March 06, 2013
  • Like
  • 0

I have an application that accesses a few SalesForce objects via the REST API, however, I don't seem to be able to retrieve or set any fields that are lookup fields.  For example, I have a Form__c object that has a Campaign lookup field as well as a Record Type field.  If I run the following query via REST:

 

SELECT Id, Campaign__c FROM Form__c

 

I receive an error stating that there is no column called Campaign__c.

 

Likewise if I try creating a new Form__c object and I set the RecordTypeId field to a specific record type ID, that value is never actually saved in SalesForce.

 

Is this a limitation of the REST API?  Is it unable to work with lookup fields?  Or am I doing something wrong?

Any help is highly appreciated.

When i am trying to insert 2 contacts at 1 go using the external id field(extfld__c)..like

Contact c1 = new Contact(FirstName = 'F1',LastName='L1',extfld__c='e1');
Contact c2 = new Contact(FirstName = 'F2',LastName='L2',extfld__c='e2',ReportsTo=new Contact(extfld__c='e1'));
List<Contact> l = new List<Contact>();
l.add(c1);
l.add(c2);
try{
    upsert l;
}
catch(Exception e)
{
    System.debug('Exception::'+e.getMessage());
}

Its throwing exception:

First exception on row 1; first error: INVALID_FIELD, Foreign key external ID: e1 not found for field extfld__c in entity Contact: []
07:47:23.388 (388572000)|SYSTEM_METHOD_EXIT|[11]|System.debug(ANY)


But when trying with the Account and contact like:

Account a = new Account(name='Test Con',extfldAcc__c='1234TestAcc');
Contact c2 = new Contact(FirstName = 'F2',LastName='L2',extfld__c='e2',Account = new Account(extfldAcc__c='1234TestAcc'));
insert new List<Sobject>{a, c2};

its inserting(while extfldAcc__c is the external id field for Account).

Can any one help me for overcoming the exception while inserting 2 contacts at the same go.

I have a small piece of code:

 


Map<List<String>,String> mapLstStr =  new Map<List<String>,String>();
List<String> lst1 = new List<String>();
List<String> lst2 = new List<String>();

lst1.add('A');
lst1.add('B');

lst2.add('A');
lst2.add('C');

mapLstStr.put(lst1,'ABCD');
mapLstStr.put(lst2,'ABCDE');

System.debug('****'+mapLstStr);

 

 

When i execute it in developer console,its showing 'Internal System Error: 1311241958-36767 (-1213750749)'.Can anybody please help me to debug this piece.

'

Hi,

 

I've been searching around the possibility in Salesforce to use self-sign certificate from a webserver, to make a https web request call.

My scenario was, Salesforce send a request to connect with server X, authenticated with username, password and self-sign certificate from server X.

With a HttpRequest class, set the endpoint url and set the username and password in Authorization Header, I've got an error message 

System.CalloutException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

The Web server, I need to connect to, has a self-signed certificate which should be included in the call-outs for the Authentification. Since I didn't see any possibility for me to upload the self-sign certificate from a third party and set it up in the HttpRequest class.

 

 

How can I solve this problem?

 

I red an article that in Java we can set the request manually to ignored self-signed certificates request, but I don't know if it is possible to implement in Apex Code.

 

Thanks!

 

 

  • September 24, 2012
  • Like
  • 0

Hi,

 

All I want to do is login to org1 and press a button that adds an Account to org2 (all I need in response is the Id of the record that was created). I am basically lost with all the different information on the web. I'm currently using user+pass for authentication in my HttpRequest POST call and it's giving me back an invalid session id error. Here are some of the resources that I have read through:

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_restful_http_httprequest.htm

http://www.salesforce.com/us/developer/docs/api_rest/api_rest.pdf

http://boards.developerforce.com/t5/REST-API-Integration/error-quot-message-quot-quot-Session-expired-or-invalid-quot/td-p/409979

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_rest_intro.htm

http://boards.developerforce.com/t5/REST-API-Integration/Calling-Apex-Rest-custom-web-service-from-Apex-code/td-p/327715/page/3

http://boards.developerforce.com/t5/REST-API-Integration/Apex-REST-Integration-Http-POST-Issue/m-p/425445#M1580

 

There's all these talks about tokens, OAuth, session id, remote access services, etc. which have completely lost me.

 

Here's my method:

    public String sendToOrg(String j, String url, String user, String pass)
    {
        HttpRequest req = new HttpRequest();
        req.setMethod('POST');
        req.setEndpoint(url);
        req.setBody(j);
        Blob headerValue = Blob.valueOf(user + ':' + pass);
        String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
        req.setHeader('Authorization', authorizationHeader);
        
        Http http = new Http();
        HTTPResponse resp = http.send(req);
        system.debug('**** Response: ' + resp.getBody() );
        if (resp != null && resp.getBody() != null) return resp.getBody();   
        else return null;
    }

 with url being: https://na4.salesforce.com/services/data/v24.0/sobjects/Account/

 

I'd really appreciate a straight-forward, Apex oriented guidance!

I have a requirement to search data immediately  from around 16 salesforce orgs. Since connecting and getting data from a single org needs  two callouts, i easily hit the callout limit. Could anyone suggest me a work-around..

@future wont help as I need the result immediately

I want to create account or oppty from one salesforce account to another using apex class.

 

Pls help me.