You need to sign in to do that
Don't have an account?
Scott.M
URLFOR
Hi I'm attempting to write a custom button that generates a contract from an opportunity. It's working except I had to use a hack for the redirect after the contract is generated. Here's the code:
Code:
I'd like to replace the new url with:
Code:
Thanks in advance for any help
Code:
{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")} var opportunity_id = '{!Opportunity.Id}'; var result = sforce.apex.execute("CreateContract","createContractService", {opp_id : opportunity_id}); var newURL = 'https://tapp0.salesforce.com/'+result+'/e—retURL=%2F'+result; //HACK window.parent.location.replace(newURL);
I'd like to replace the new url with:
Code:
var newURL = "{!URLFOR($Action.Contract.Edit, [result], null, false)}";Where [result] is the id of the contract that was just created by the web service (the return value). Unfortunately these functions don't seem to have access to the javascript variables. Any ideas how I could pass the contract id to the URLFOR function. Keep in mind I'm in the opportunity detail context.
Thanks in advance for any help
Since the {!URLFOR... stuff is processed when the page is first loaded you can't refer to javascript variables.
Also note that although using URLFOR is probably the right way to go, you could also get rid of the
Thanks Steve, it helped.