You need to sign in to do that
Don't have an account?

Send data to external script on create/update of contact
Hi All,
My salesforce org is integrated with a third party tool. I need to pass the contact Id to a given URL or external script on create or update of contact.
Below is the link. Unavailable currently.
Any ideas or solutions to implement this. If I have to write apex script how can i invoke.
Haven't tested yet. Did something like this
public
class WebServiceCallout {
@future (callout=true)
public static void sendNotification(String name, String city) {
HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
Http http = new Http();
req.setEndpoint('http://my-end-point.com/newCustomer');
req.setMethod('POST');
req.setBody('name='+EncodingUtil.urlEncode(name,
'UTF-8')+'&city='+EncodingUtil.urlEncode(city, 'UTF-8'));
try {
res = http.send(req);
} catch(System.CalloutException e) {
System.debug('Callout error: '+ e);
System.debug(res.toString());
}
}
// run WebServiceCallout.testMe(); from Execute Anonymous to test
public static testMethod void testMe() {
WebServiceCallout.sendNotification('My Test Customer','My City');
}
}
You can execute
your callout in a trigger with the following example:
trigger
AccountCallout on Account (after insert) {
for (Account a : Trigger.new) {
// make the asynchronous web service callout
WebServiceCallout.sendNotification(a.Name, a.BillingCity);
}
}
All Answers
What do you want to happe? do you just want to send the id to the link. I mena do you want to give a button to which the id must be appended or do you want salesforce to navigate to that external app as soon as the contact is created?
I only want to send the recordID to the link every time a contact is created or updated.
Please tell me how to do it. This should happen immediately after user clicks save.
Check this code. Le me know if this helps you.
I am not sure If this well serve the purpose.
From little what I know, we should be using http POST or cURL something of this sort.
I know that this will be useful in just writing an account . but what is the functionality you want. what shud happen after the record is created?
I want to pass the record ID to the external link(end point). Hope you got me right.
I am not sure what you want to do after you set it as end point. jUst check this . this is as per my understanding . if you more clear and . let me know what do you want to do next. I am sorry but I am trying to understand the issue.
Was the code of any help?
Haven't tested yet. Did something like this
public
class WebServiceCallout {
@future (callout=true)
public static void sendNotification(String name, String city) {
HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
Http http = new Http();
req.setEndpoint('http://my-end-point.com/newCustomer');
req.setMethod('POST');
req.setBody('name='+EncodingUtil.urlEncode(name,
'UTF-8')+'&city='+EncodingUtil.urlEncode(city, 'UTF-8'));
try {
res = http.send(req);
} catch(System.CalloutException e) {
System.debug('Callout error: '+ e);
System.debug(res.toString());
}
}
// run WebServiceCallout.testMe(); from Execute Anonymous to test
public static testMethod void testMe() {
WebServiceCallout.sendNotification('My Test Customer','My City');
}
}
You can execute
your callout in a trigger with the following example:
trigger
AccountCallout on Account (after insert) {
for (Account a : Trigger.new) {
// make the asynchronous web service callout
WebServiceCallout.sendNotification(a.Name, a.BillingCity);
}
}