Solved

Salesforce integration with External system using the HTTP POST method

Posted on 2007-11-21
26
4,003 Views
Last Modified: 2013-11-24
Hi there,

How can I send the data from Sales force to an external system?

I believe it can be done through a S-Control which can be attached to the custom button (URL type) that will trigger to send the data using HTTP POST method.

Has anyone ever done anything like this and could you share the details with me.?

Thanks
0
Comment
Question by:SUMA ANAND
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 15
  • 8
  • 2
26 Comments
 

Author Comment

by:SUMA ANAND
ID: 20351273
hi guys,

please respond , I am desperately looking for some answers here.

thanks
0
 
LVL 11

Accepted Solution

by:
techhealth earned 250 total points
ID: 20385417
S-control is the hardest route to go.  :-)  Can you tell me a bit more about the task on hand?  SF has other easier ways for specific integration tasks.
1
 

Author Comment

by:SUMA ANAND
ID: 20385959
So based on the requirements I have here are the details:-

1.> From Salesforce, under Opportunity user clicks on the Fulfillment custom button which will send out the details to an external system.

This custom button will capture the field details from the Opportunity and Account object. The following fields will have to be captured from the Opportunity object:-
      a) Opportunity ID
      b) Opportunity Owner
      c) Owner ID
The following fields will be captured from the Account object :-
      a) Account Name
      b) Account ID
      c) Billing Address
      d) Phone
      e) Fax
      f) Website
These details will be sent out to the external system called - BPM, using the HTTP POST method which can be accomplished through the S-Control embedded in a custom button.


0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Comment

by:SUMA ANAND
ID: 20386077
the SOQL Query for the above is following:-

Select o.AccountId, o.Account.BillingCity, o.Account.BillingCountry, o.Account.BillingPostalCode, o.Account.BillingState, o.Account.BillingStreet, o.Account.Fax, o.Account.Id, o.Account.Name, o.Account.Phone, o.Account.Website, o.Id, o.Name, o.OwnerId, o.Owner.Name from Opportunity o where o.Id = '{!MERGE FIELD}

 
NOTE:-
-------
How the CRITERIA is designed, where Opportunity.ID = Opportunity.AccountID


0
 
LVL 11

Expert Comment

by:techhealth
ID: 20386619
OK.  That does sound like something that requires a fair amount of manual coding...  So your BPM takes simple POST parameters instead of Web services calls?  That may or may not be a good thing.
0
 
LVL 11

Expert Comment

by:techhealth
ID: 20386817
SF can do an outbound SOAP message via workflow triggers, which is much easier to set up than custom S-Control actions.
0
 

Author Comment

by:SUMA ANAND
ID: 20392907
so what do you suggest is best approach to do this.

any example? any starting point to do this?
0
 
LVL 11

Expert Comment

by:techhealth
ID: 20395356
Well, my question really is, how your BPM take in information?  Is it good old way like http://bpmsystem.com/input.cgi?para1=company¶2=name, or does it work like a Web services endpoint that takes a SOAP message for input?
0
 
LVL 22

Expert Comment

by:Bill-Hanson
ID: 20396060
The easiest way is to pass minimal info to your remote server via URL parameters.

(1) Create a simple link that includes as parameters, the OpportunityId, the current SessionId, and the ServerUrl.
(2) In your server side code, use the Web Services API to validate the SessionId against the ServerURL, then do whatever you need to the Opportunity.
0
 

Author Comment

by:SUMA ANAND
ID: 20397553
Thanks Guys!

I still have not received all the user requirements regarding this project. From the verbal discussion it seems, that a custom button will be placed on Oppurtunity tab and from there when the user clicks on this button, the field values will be sent over to the BPM System. I have not received the URL yet or on how this information will be received at the other end. I will find out by the end of the day.


0
 

Author Comment

by:SUMA ANAND
ID: 20397590
As a starting point, I wrote this S-Control:-
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

<html>
<head>
<script src="/soap/ajax/9.0/connection.js" type="text/javascript"></script>

<script>
function setupPage() {
//function contains all code to execute after page is rendered

var state = { //state that you need when the callback is called
output : document.getElementById("output"),
startTime : new Date().getTime()};

var callback = {
//call layoutResult if the request is successful
onSuccess: layoutResults,

//call queryFailed if the api request fails
onFailure: queryFailed,
source: state};

alert("start");

sforce.connection.query(
"Select o.AccountId, o.Name,o.ID from Opportunity o WHERE o.id='{Opportunity.AccountID}' ",callback);

alert("end query");

}

function queryFailed(error, source)
{
alert("QueryFailed...");
source.output.innerHTML = "An error has occurred - query: " + error;
}

/**
* This method will be called when the toolkit receives a successful
* response from the server.
* @queryResult - result that server returned
* @source - state passed into the query method call.
*/
function layoutResults(queryResult, source)
{
var output = "";

if (queryResult.size > 0)
{
//get the records array
var records = queryResult.getArray('records');

//loop through the records and construct html string
for (var i = 0; i < records.length; i++)
{
var Opportunity= records[i];
output += Opportunity.AccountId + " " + Opportunity.Name + " " + Opportunity.ID + " <br>";
}

}

// output += "ID - Status<br>";
//render the generated html string
source.output.innerHTML = output;
}
</script>
</head>

<body onload="setupPage()">
<div id="output"> </div>
</body>
</html>

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


Here is what is happeneing here:-


1.> This S-Control is placed on the custom button called "Start the BPM" which is on Oppurtunity tab.
2.> Notice the SOQL Query, which is capturing the data from the fields.
3.> It will display the data in a seperate window.

4.> This is a starting point, and as I get more details this code will be edited.



0
 
LVL 22

Assisted Solution

by:Bill-Hanson
Bill-Hanson earned 250 total points
ID: 20397723
This will get the data you need, but since you're just passing the data to another system, there is a much faster way.  Since you are just passing data from the current record, you don't need an sControl at all.  No SOQL either.  All you really need is a custom link that uses merge fields.

For example, to pass all of the fields you listed above to some external system, you can just create a URL to the external system like this:

https://your_server/your_agent?id={!Opportunity.Id}&aid={!Opportunity.AccountId}&oname={!Opportunity.Name}

Then the code on the receiving end can just extract the values from the query string.
0
 
LVL 11

Expert Comment

by:techhealth
ID: 20398171
That's why I asked what your BPM takes as input.

>>All you really need is a custom link that uses merge fields.

That'll work fine if your BPM doesn't expect a Web Service call.

You'll still need some querying though, if you need more than just info from the current object in context, i.e., combining info from multiple objects.
0
 

Author Comment

by:SUMA ANAND
ID: 20398197
Thanks Bill.

let me try this now...and I will let u know in a short while.

thanks
0
 

Author Comment

by:SUMA ANAND
ID: 20398753
Hi again,

I have a question regarding this statement?


\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Is BPM system expecting a Web service call?
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

We have decided on simple HTTP POST method? Is this not a good thing? What am I missing here?

 
0
 
LVL 11

Expert Comment

by:techhealth
ID: 20398913
It's easier to implement in some cases (like Bill suggested), but it's a less flexible and scalable way to do it.  Don't worry too much about it.  You'll be fine either way.
0
 

Author Comment

by:SUMA ANAND
ID: 20399372
Thanks techhealth.

Bill,

About what you mentioned earlier :-
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
For example, to pass all of the fields you listed above to some external system, you can just create a URL to the external system like this:

https://your_server/your_agent?id={!Opportunity.Id}&aid={!Opportunity.AccountId}&oname={!Opportunity.Name}

Then the code on the receiving end can just extract the values from the query string.
/////////////////////////////////////////////////////////////////////

Since, I do not have the URL address at this moment, can I still try out this option. Later, when I get the URL address I will edit it. This will help me understand it more better.

I am thinking like this:-

1.> Create a custom button, with Display Type = List Button
2.> Content Source = URL
3.> In the Body section, what should I mention?


0
 

Author Comment

by:SUMA ANAND
ID: 20400073
I have found the answers to your questions:-

Answers to you questions to the best of my knowledge:

 

1.> BPM isnt taking, we are sending the information. So we need to use HTTP POST message only.

The key is, to get it into an HTTP POST message.

I guess you need to figure out how to make an HTTP POST message and then get Salesforce to put the correct data into that message to be sent to whatever address BPM wants us to send it to.

This is my requirement. and that is the reason why I created that S-Control. This S-control for now is only displaying data in a seperate window, later on when I get that BPM address I will edit it accordingly.

My question again is:-
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

How will I send the data from Salesforce to BPM system using the HTTP Post method?


thanks
0
 

Author Comment

by:SUMA ANAND
ID: 20423069
looks like this problem is solved. Here is what I found from one of the research over the Apex Wiki network.

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

You can do this using Salesforce SOA, in an S-Control, button, or link. If you have Unlimited Edition, you can also create calls using Http, HttpObject, and HttpResponse from the Apex Code object library. If you have the AJAX version, simply call the function in a place convenient for you. In Apex Code, you can't (unfortunately) use triggers, so you have to use a webservices method or use Apex AJAX to invoke the code via the Salesforce API through the browser. For example:

Code: {!RequireScript("/soap/ajax/11.1/connection.js"} postParams = {} postParams.url = 'http://www.mydomain.com/services/function' postParams.method = 'POST' postParams.requestData = 'data to send' // place your data here postParams.requestHeaders = {} postParams.requestHeaders['Content-Type'] = 'text/plain' //or another mime-type postParams.requestHeaders['Content-Length'] = postParams.requestData.length //required for POST postParams.onSuccess = processSuccess postParams.onError = processError sforce.connection.remoteFunction(postParams) function processSuccess(message) { // do something with results } function processError(message) { // do something with the error }
 You can use that in a button or link on the object, or you can replace the first line with a normal script include for an S-Control. I do hope you find this useful.
/////////////////////////////////////////////////////////////


Thank you so much.


Please check again, I will be posting more Sales force related queries.


regards to all.
0
 
LVL 11

Expert Comment

by:techhealth
ID: 20423409
Salesforce SOA is certainly the way to go for SOAP based BPM endpoint.  But Bill's method is still way easier if your URL is a simple query string format.
0
 

Author Comment

by:SUMA ANAND
ID: 20423979
Hi again,,


I did discuss Bills solution, which was:-

For example, to pass all of the fields you listed above to some external system, you can just create a URL to the external system like this:

https://your_server/your_agent?id={!Opportunity.Id}&aid={!Opportunity.AccountId}&oname={!Opportunity.Name}

Then the code on the receiving end can just extract the values from the query string.

    * Accept Multiple Solutions
    * Accept as Solution

===================================================================
===================================================================


1.> The problem is that I do not have any URL related information of the external system.

2.> Bill, is suggesting to write a code at the receiving end, however in real world I will not be able to access the external system.

3.> We just want to send data from Salesforce to the External system in a simple format. We dont care what is happening at the receiving end.

4.> This is the reason, HTTP POST method inside the S-control would be a best option.

If you still think otherwise, please let me know I am open to suggestions and thoughts.

Kind regards

0
 
LVL 11

Expert Comment

by:techhealth
ID: 20428259
I guess you'll HAVE TO know a bit more about your receiving end.  If you're talking to a dog, speak cat is not gonna help. :)  You said "sending data to the external system in a simple format".  And what is that simple format?  Does your external system expect plain text parameters? Or does it expect SOAP messages?  The answer will decide what your put in your requestData, Content-Type, and so forth.

And if the remote system only needs plain parameters, then why bother with remoteFunction()?  A custom URL with merge fields will work fine.

Bill is not suggesting YOU writing the code at the receiving end.  He's just saying you need to know HOW the receiving end is going to consume your data, so you can tailor your output.  Tossing a lettuce to a hungry tiger won't be a proper feed for the beast.  :)
0
 

Author Comment

by:SUMA ANAND
ID: 20428805
I need some time to give this a thought. It makes so much sense, but I need to find out a way to put this together and present this to the management.

I will post my reply again by weekend.

thanks
0
 

Author Comment

by:SUMA ANAND
ID: 20445799
Can you please put a hold on this question.

I am still reviewing the suggestions provided by other experts, and that maybe the better option. I am not sure.

thanks
0
 

Author Comment

by:SUMA ANAND
ID: 20454098
I would like to split points between - techhealth and Bill-hanson. they both make sense and I need to do more research on my part about this question.

Thanks guys.
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Supply Chain Event Management Supply chain visibility is the ability of a company to track its products and business processes in supply chain towards building operational excellence. The goal of supply chain visibility is to improve and strength…
Oracle Apps Profiles option: A user profile is a set of shifting options that alter the way one runs an application. A value is set for each option under the user's profile when the Oracle application user logs on to any responsibility or changes…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question