SUMA ANAND
asked on
Salesforce integration with External system using the HTTP POST method
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
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.
ASKER
the SOQL Query for the above is following:-
Select o.AccountId, o.Account.BillingCity, o.Account.BillingCountry, o.Account.BillingPostalCod e, 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
Select o.AccountId, o.Account.BillingCity, o.Account.BillingCountry, o.Account.BillingPostalCod
NOTE:-
-------
How the CRITERIA is designed, where Opportunity.ID = Opportunity.AccountID
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.
SF can do an outbound SOAP message via workflow triggers, which is much easier to set up than custom S-Control actions.
ASKER
so what do you suggest is best approach to do this.
any example? any starting point to do this?
any example? any starting point to do this?
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?
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.
(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.
ASKER
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.
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.
ASKER
As a starting point, I wrote this S-Control:-
\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\ \\\\\\\\\\ \\\\\\\\\\ \\\\\\\\\\ \\\\\\\\\\ \\\\\\\\\\ \\\\\\\\\\ \\\\\\\\\\ \\\\\\\\\\ \\\\\\\\\\ \\\\\\\\\\ \\\\\\\\\\ \\\\\\\\\\ \\\\\\
<html>
<head>
<script src="/soap/ajax/9.0/connec tion.js" type="text/javascript"></s cript>
<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("o utput"),
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.Account ID}' ",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('reco rds');
//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.
\\\\\\\\\\\\\\\\\\\\\\\\\\
<html>
<head>
<script src="/soap/ajax/9.0/connec
<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("o
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.Account
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,
{
var output = "";
if (queryResult.size > 0)
{
//get the records array
var records = queryResult.getArray('reco
//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.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
>>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.
ASKER
Thanks Bill.
let me try this now...and I will let u know in a short while.
thanks
let me try this now...and I will let u know in a short while.
thanks
ASKER
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?
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?
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.
ASKER
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={!Op portunity. AccountId} &oname={!O pportunity .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?
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={!Op
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?
ASKER
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
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
ASKER
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/aja x/11.1/con nection.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-T ype'] = 'text/plain' //or another mime-type postParams.requestHeaders[ 'Content-L ength'] = postParams.requestData.len gth //required for POST postParams.onSuccess = processSuccess postParams.onError = processError sforce.connection.remoteFu nction(pos tParams) 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.
\\\\\\\\\\\\\\\\\\\\\\\\\\
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/aja
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.
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.
ASKER
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={!Op portunity. AccountId} &oname={!O pportunity .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
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={!Op
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
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. :)
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. :)
ASKER
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
I will post my reply again by weekend.
thanks
ASKER
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
I am still reviewing the suggestions provided by other experts, and that maybe the better option. I am not sure.
thanks
ASKER
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.
Thanks guys.
ASKER
please respond , I am desperately looking for some answers here.
thanks