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
Dara WardeDara Warde 

VF Create Contract button on Opp

I am not a developer and have existing code that I'm having trouble with.
I am expecting that this Create Contract button on the Opp would then allow the Contract to show up in a Contract Related List. However, it only adds a link to the Opp in a custom field. That would be ok except that the connection between the two objects seems to be missing. There are other fields that I would like to associate from the Opp to the contract, and I cannot do so. For instance, on the Contract, I am unable to use the formula Opportunity__r.CloseDate to pull the first Opp's close date to the Contract. I have attempted that both with a PB and a WFR.
Any help would be greatly appreciated!
We use Classic and are on Enterprise Edition.

<!-- File: CreateContractFromOpportunity.page *************************************************************************
Description: Build url and redirect to the create opportunity page *************************************************************************
History: --> <apex:page standardcontroller="Opportunity" extensions="ia_crm.CreateContractFromOpportunity" action="{!backToOpportunity}"> <apex:includescript value="{!URLFOR($Resource.ia_crm__Intacct, '/js/jQuery.min.js')}" /> <style> .myCustomMessage .message { background: none !important; border: none !important; background-image: none !important; }
.msgIcon { Display: none; }
</style> <apex:slds />
<div class="slds"> <apex:form > <apex:outputtext rendered="{!IF(pageStatus == 'ERROR', true, false)}"> <apex:outputpanel styleclass="myCustomMessage"> <figure> <apex:image id="errorImage" value="{!URLFOR($Resource.ia_crm__Intacct,'images/error.png')}" style="margin: auto; display: block; padding-top: 100px;" /> </figure> <div style="text-align: center;"> <apex:outputpanel rendered="{!AND(conToAdd != null, conToAdd.Id != null)}"> <apex:outputtext value="Add-on Opportunity created with errors" style="font-size: 200%;" /> </apex:outputpanel> <apex:outputpanel rendered="{!AND(conToAdd == null, conToAdd.Id == null)}"> <apex:outputtext value="Failed to create Contract" style="font-size: 200%;" /> </apex:outputpanel> </div>
</apex:outputpanel> <apex:outputpanel styleclass="myCustomMessage"> <p> <div class="demo-only"> <div class="slds-has-dividers_around-space slds-align_absolute-center"> <div class="slds-item " style="width: 550px;"> <article class="slds-tile slds-tile_board"> <apex:outputpanel rendered="{!AND(conToAdd != null, conToAdd.Id != null)}">
The &nbsp;<apex:outputlink value="{!'/' + conToAdd.Id}" styleclass="slds-text-link">Contract</apex:outputlink>&nbsp; got created successfully, but an error occured while tring to associate it with the Opportunity: You can manually asociate the newly created contract with the Opportunity. Contract Number: &nbsp; <apex:outputlink value="{!'/' + conToAdd.Id}" styleclass="slds-text-link">{!conToAdd.ContractNumber}</apex:outputlink> </apex:outputpanel> <apex:outputpanel rendered="{!AND(conToAdd == null, conToAdd.Id == null)}"> <apex:pagemessages id="xx" /> </apex:outputpanel> </article> </div> </div> </div> </p> </apex:outputpanel> <apex:outputpanel > <div style="text-align: center;"> <apex:commandbutton action="{!'/' + Opportunity.Id}" style="margin-top: 20px;" value="Back to record" styleclass="slds-button slds-button--neutral" /> </div> </apex:outputpanel> </apex:outputtext> </apex:form> </div> </apex:page>