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
Kondal Rao learnerKondal Rao learner 

Its urgent requriment

Hi experts,

 

i have custom object called deal and standard object called oppotuntiy i created button called convert when i click on that deal has to convert in to opporuntiy its working fine now but my requirement is that

 
Once the deal converts to Opportunity transfer this benefit information to the Opportunity and apply deal benefits to Opportunity Line Items.
 
In opportuniy there is two custom fileds called %incentive and Doller incentive those benefits has to assign only these twoo filds and agian deal benefits to opportunity lineitem
 
 
This is my apexcode:
 
public with sharing class MyDealControllerExtension {
public ApexPages.StandardController CONTROL; 


    public MyDealControllerExtension(ApexPages.StandardController stdController) {
      this.CONTROL = stdController;
 
}
public pageReference doCreateOpportunity() {
 
    Opportunity   newOpp = new Opportunity();
    
    
   Deal__c Deal = [select Id, Name, Distributor__c, End_Customer__c, Industry__c, Partner_Specializations__c,Partner_Tier__c,Product_Category__c,Segment__c from Deal__c where id = :CONTROL.getId()];
 
     // add your field mappings here  
 
    newOpp.Name = Deal.Name;
    newOpp.stagename = 'Negotiation/Review';
    newOpp.CloseDate= system.today()+30;
    Deal.Deal_Status__c = 'Converted';
    
 // etc.
 
 
     insert newOpp;
 
     pageReference p = new pageReference('/' + newOpp.id);
 
    p.setRedirect(true);
 
     return p;
    }
 
Vf page:
 
<apex:page standardController="Deal__c" extensions="MyDealControllerExtension" action="{!doCreateOpportunity}" />
Suresh RaghuramSuresh Raghuram

I went through ur post and i did not under the following thing, can u please add some explination on the following lines.

 

Once the deal converts to Opportunity transfer this benefit information to the Opportunity and apply deal benefits to Opportunity Line Items.
 
In opportuniy there is two custom fileds called %incentive and Doller incentive those benefits has to assign only these twoo filds and agian deal benefits to opportunity lineitem
 
Correct me here.
this benefit information is the deal i am i right.
 
what are the deal benifits that need to be applied to the Opportunity Line items.
 
those benefits has to assign only these two u mean the deal benifits to be applied to the two filds.
 
Kondal Rao learnerKondal Rao learner

HI suree,

 

ya u have to apply deal benefits to the opportuntiy and one more thing is that %incentive and doller incentive are not there in the deal object we have to fetch from the deal process association(object) which is child object of deal , and we have to map deal process association and opportunity in our coding and we have to fetch the information from deal project association and we have to store in opportunity custom objects that is %inentive and doller incentive , and we have to apply all deal benefits to opportunity products.

 

when you need to search for fields of a child record, create a query for child records in the class and in that follow the in matrix for benefit type calculation as shared by Jasmeet previously and calculate the values on the Opportunity custom fields on Deal conversion.
 
We already have the convert controller class present and fields created on the opportunity object.
 
 

 

$ Benefit (A)
% Benefit (X)
$ Benefit (B)
A+B
B U X **
% Benefit (Y)
A U Y **
X + Y

     

Example

     

$ Benefit (100)
% Benefit (10)
$ Benefit (200)
300
200 + 10% of deal value
% Benefit (15)
100 + 15% of deal value
25% of deal value
 
Kondal Rao learnerKondal Rao learner

as i posted im not getting what they saying in my company what ever prsent in blue lines these lines told me by my lead so pls check it out once and tell me the requirement that is once deal is converted into opportunity

 

Once the deal converts to Opportunity transfer this benefit information to the Opportunity and apply deal benefits to Opportunity Line Items.

Kondal Rao learnerKondal Rao learner

hi

 

deal process associate is the child object of deal in deal process associate there are fields that is %incentive and doller incentive so we have to fetch those and have to store in opportunity custom fields i mean these two fields doller incentive and %incentive are prsent in opportunity also , we have to write query to fetch the records on the child object that is deal process associate for that when you need to search for fields of a child record, create a query for child records in the class and in that follow the in matrix for benefit type calculation

 

 

apexcode :

 

 

 

 

This is my apexcode:

 

 

 

public with sharing class MyDealControllerExtension {
public ApexPages.StandardController CONTROL; 


    public MyDealControllerExtension(ApexPages.StandardController stdController) {
      this.CONTROL = stdController;
 
}
public pageReference doCreateOpportunity() {
 
    Opportunity   newOpp = new Opportunity();
    
    
   Deal__c Deal = [select Id, Name, Distributor__c, End_Customer__c, Industry__c, Partner_Specializations__c,Partner_Tier__c,Product_Category__c,Segment__c from Deal__c where id = :CONTROL.getId()];
 
     // add your field mappings here  
 
    newOpp.Name = Deal.Name;
    newOpp.stagename = 'Negotiation/Review';
    newOpp.CloseDate= system.today()+30;
    Deal.Deal_Status__c = 'Converted';
    
 // etc.
 
 
     insert newOpp;
 
     pageReference p = new pageReference('/' + newOpp.id);
 
    p.setRedirect(true);
 
     return p;
    }

 

 

 

Vf page:

 

 

 

<apex:page standardController="Deal__c" extensions="MyDealControllerExtension" action="{!doCreateOpportunity}" />

 

 

 

$ Benefit (A)
% Benefit (X)
$ Benefit (B)
A+B
B U X **
% Benefit (Y)
A U Y **
X + Y

     

Example

     

$ Benefit (100)
% Benefit (10)
$ Benefit (200)
300
200 + 10% of deal value
% Benefit (15)
100 + 15% of deal value
25% of deal value