function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
nishant shrivastava 40nishant shrivastava 40 

Passing parameter from one Javascript button to another javascript button

Hi,
kindly have a look of button number 1 which calls button number2 and i need to pass id from button 1 to button 2.

Button 1:
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
var id= '{!Account.Id}';
var ids = sforce.apex.execute('CreateContract','CreateRecord',{recId :id});
alert(ids);
function openConga(){
window.open('{!URLFOR($Action.Contract.CreatesContracts, Contract.Id)}','_blank');
}
window.open(openConga());

button 2  (name=createscontracts):
/apex/APXTConga4__Conga_Composer
?serverUrl={!API.Partner_Server_URL_370}
&id={!Contract.Id}
&TemplateId=a0M1w000001uSspEAE
&SC0=1
&SC1=Attachments
&AttachmentParentID={!Contract.Id}


while calling the button number 2, it shows the id null in conga url for (contract.Id). 
could you please assist me, how can i pass id from first javascript button to another one and can get the value for contract.id in conga url.

I shall be grateful to you for your kind assistance.
Thanks and regards
Best Answer chosen by nishant shrivastava 40
nishant shrivastava 40nishant shrivastava 40
I simply wrote the method of button number 2 in button number 1. i took the id from button number 1 and called the conga url just after that. like this


{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
var id= '{!Account.Id}';
var ids = sforce.apex.execute('CreateContract','CreateRecord',{recId :id});
var str = ids;
window.location.href = '/apex/APXTConga4__Conga_Composer?serverUrl={!API.Partner_Server_URL_370}&id='+str+'&TemplateId=a0M1w000001uSspEAE&SC0=1&SC1=Attachments&AttachmentParentID='+str

All Answers

Vishwajeet kumarVishwajeet kumar
Hello,
Are both buttons on same page ?
You can try use javascript global variable of type "Var" to store the Id and use it in other button call method.

Thanks
nishant shrivastava 40nishant shrivastava 40
Hallo Vishwajeet Kumar,
Thanks for your kind response. could you please render an example. how can i do it? because it's not reading the value of id.
nishant shrivastava 40nishant shrivastava 40
I simply wrote the method of button number 2 in button number 1. i took the id from button number 1 and called the conga url just after that. like this


{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
var id= '{!Account.Id}';
var ids = sforce.apex.execute('CreateContract','CreateRecord',{recId :id});
var str = ids;
window.location.href = '/apex/APXTConga4__Conga_Composer?serverUrl={!API.Partner_Server_URL_370}&id='+str+'&TemplateId=a0M1w000001uSspEAE&SC0=1&SC1=Attachments&AttachmentParentID='+str
This was selected as the best answer