You need to sign in to do that
Don't have an account?
Karina Chang
Passing parameters to JavaScript
On an Opportunity, I have created a button to execute Javascript using sforce.apex.execute (I am calling an Apex Class).
The apex class creates a Contract record. I would like to get the record id (of the Contract just created) displayed on an alert after clicking on the button if creation is successful.
_______
{!RequireScript("/soap/ajax/34.0/connection.js")}
{!RequireScript("/soap/ajax/34.0/apex.js")}
function success() {
// Indicate success
var alertString="Success!";
window.open('www.google.com');
alert(alertString);
}
function error() {
// Indicate failure
//window.open('www.yahoo.com');
var alertString="Fail!";
alert(alertString);
}
sforce.connection.sessionId = "{!$Api.Session_ID}";
sforce.apex.execute("InsertContractAndPO", "createContractAndPOAsset",
{ accountId: "{!Opportunity.AccountId}", opportunityId: "{!Opportunity.Id}" },
{ onSuccess:success , onFailure: error});
The apex class creates a Contract record. I would like to get the record id (of the Contract just created) displayed on an alert after clicking on the button if creation is successful.
_______
{!RequireScript("/soap/ajax/34.0/connection.js")}
{!RequireScript("/soap/ajax/34.0/apex.js")}
function success() {
// Indicate success
var alertString="Success!";
window.open('www.google.com');
alert(alertString);
}
function error() {
// Indicate failure
//window.open('www.yahoo.com');
var alertString="Fail!";
alert(alertString);
}
sforce.connection.sessionId = "{!$Api.Session_ID}";
sforce.apex.execute("InsertContractAndPO", "createContractAndPOAsset",
{ accountId: "{!Opportunity.AccountId}", opportunityId: "{!Opportunity.Id}" },
{ onSuccess:success , onFailure: error});
function success(result) { // result will hold the returned value I think.
please try once
All Answers
function success(result) { // result will hold the returned value I think.
please try once