• Marketing 20112
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 8
    Replies
I want to use javascript to send a http request when editing the stage field on the opportunity page. 
I can't find where I can inject this javascript. Do I override the default edit button? Or is there a way to write a custom field that triggers a javascript when its edited?

What is the simplest way to do this?
I want to create a custom field in the contacts page. I was wondering if its possible to set the field values as some data aquired by an API. Something like calling a javascript to get the values. I wasn't quite able to find anything like that when trying to create a new custom field.
I'm trying to send a http post to our API using a costum detail page button executing javascript. 
The problem I'm having is that it seems the parameters needed for the API isn't coming through. 

This is the javascript running:

{!RequireScript("/soap/ajax/11.1/connection.js")}

var phone = '{!Contact.MobilePhone }'

postParams = {}
postParams.url = 'https://api.example.com/'
postParams.method = 'POST'
postParams.requestData = 'phonenumber='+phone
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¨
alert(message);
}
function processError(message)
{ // do something with the error
alert('error');
}

Found this example in another question and worked from there. The API recives the post but with no "phonenumber"-parameter. What am I doing wrong?
I want to create a custom field in the contacts page. I was wondering if its possible to set the field values as some data aquired by an API. Something like calling a javascript to get the values. I wasn't quite able to find anything like that when trying to create a new custom field.
I'm trying to send a http post to our API using a costum detail page button executing javascript. 
The problem I'm having is that it seems the parameters needed for the API isn't coming through. 

This is the javascript running:

{!RequireScript("/soap/ajax/11.1/connection.js")}

var phone = '{!Contact.MobilePhone }'

postParams = {}
postParams.url = 'https://api.example.com/'
postParams.method = 'POST'
postParams.requestData = 'phonenumber='+phone
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¨
alert(message);
}
function processError(message)
{ // do something with the error
alert('error');
}

Found this example in another question and worked from there. The API recives the post but with no "phonenumber"-parameter. What am I doing wrong?