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
sswaminasswamina 

Open custom object new/edit page from custom button and pass parameters using JavaScript

Hello all,

 

Have a custom button on opportunity page. The custom object and opportunity pages  are configured with page layouts for new & edit pages not VF.

 

 

I want to achieve the following:

  1) On click on that button for very first time want it to open up "new"page of the custom object. The second time on it should open up the "edit" page.
   2) I also want to be able to pass 2 or more parameters from the opportunity page to the new/edit pages, mainly for new page.

   3) On "Save" on the custom object page want it to redirect to opportunity view page.

 

Please can you provide me sample javascript or better way of doing that.

 

Thanks.

 

 

Following is Javascript used, but causing syntax errors without the redirect:

 

If ({!Opportunity.PQQ__c})
{!URLFOR($Action.PQQ__c.New, null,
[

"PQQ__c.Name"="{!Opportunity.Name}",
"PQQ__c.Opportunity__c"="{!Opportunity.Id}",
"save"="1"
],
true)}

else{{!URLFOR($Action.PQQ__c.Edit, null,
[

"PQQ__c.Name"="{!Opportunity.Name}",
"PQQ__c.Opportunity__c"="{!Opportunity.Id}",
"save"="1"
],
true)}