• theDrew
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

Hello all,

I'm an APEX noob, so please help. It would be appreciated!

We have a custom button on the Opportunities page, "Create Contract."  The button opens a window for a new Contract and pulls certain fields from the Opportunity into the new Contract.

We have recently begun to use both Opportunity and Contract record types. We need to select the Contract record type based on the Opportunity record type.

Mapping examples:
Opportunity Record Type A - Contract Record Type A (this is the default Contract type)
Opportunity Record Type B - Contract Record Type A
Opportunity Record Type C - Contract Record Type A
Opportunity Record Type D - Contract Record Type B
Opportunity Record Type E - Contract Record Type C

I have succeeded in passing a single record type, but I am having trouble in setting up the IF- ELSE statement in the button code to handle multiple record types.

The code is below. I am 100% certain that my IF statement syntax is incorrect somewhere, because it appears that the program never enters the code.  The new Contracts page always opens with user's default contract page view.

If I replace the below IF statement with the line:

 

&RecordType=012M00000000AcK 

 


then that record type is used, and the Contracts page opens with the page view associated with that Contract Record Type.

If any of you could help me with the syntax for a two-part IF-ELSE statement then I can build out the rest of the scenarios. Thanks!

 

 

/800/e?retURL=%2F800%2Fo

&if ({!Opportunity.RecordTypeId}==012C00000003okgIAA){
// Do this if the condition is true 
RecordType=012M00000000AcK   
} else {
// Do this if the condition is not true 
RecordType=012800000003buxAAA
}

&ctrc7_lkid={!Opportunity.AccountId}
&00N80000003uEo4={!Opportunity.Country__c}
&CF00N80000003VFS3={!Opportunity.Name}
&00N80000003uEsV={!Opportunity.CloseDate}
&00N80000003uEn1={!Opportunity.Policy__c}
&ctrc5={!Opportunity.Contract_Start_Date__c}
&00N80000003uEnk={!Opportunity.ExPat__c}
&00N80000003uEnl={!Opportunity.ASO__c}
&00N80000003udsE={!Opportunity.Cross_Marketing__c}
&00N80000003uErI={!Opportunity.Type}
&00N80000003uEsG={!Opportunity.Pooled__c}
&00N80000004ILAP={!Opportunity.Insurance_Company__c}
&00N80000004ILAA={!Opportunity.Bill_Type__c}
&00N80000004CNNe={!Opportunity.Expat_Account_Manager__c}
&00N80000003uEmr={!Opportunity.LOB_Expat__c}
&00N80000003uEmh={!Opportunity.LOB_del__c}
&00N80000003uEui={!Opportunity.Quoted_Due_Date__c}
&00N80000003uEww={!Opportunity.Quoted_Received_Date__c}
&00N80000003uEnm={!Opportunity.Quoted_Release_Date__c}
&00N80000003uErJ={!Opportunity.Decline_Options__c}
&00N80000003uExV={!Opportunity.Lost_Options__c}
&00N80000003uEsH={!Opportunity.Currency__c}
&00N80000003uEn3={!Opportunity.Life_Premium__c}
&00N80000003uEn2={!Opportunity.of_Employees__c}
&00N80000003uEn4={!Opportunity.Medical_Premium__c}
&00N80000003uEo1={!Opportunity.Disability_Premium__c}
&00N80000003uEuh={!Opportunity.Dental_Premium__c}
&00NC0000004yFM1={!Opportunity.Business_Travel_Medical_Premium__c}
&00N80000004ENTC={!Opportunity.LTD_Premium__c}
&00N80000004ENTH={!Opportunity.Other_Premium__c}
&00N80000003uEmi={!Opportunity.Total_Premium__c}
&00N80000003uEsp={!Opportunity.Collected_Contribution__c}
&00N80000003uEo5={!Opportunity.Collected_ATO__c}
&00N80000003uEsv={!Opportunity.Total_Collected_Contribution__c}
&00N80000003uErE={!Opportunity.Est_Annual_Contribution__c}
&00N80000003uEtO={!Opportunity.Est_ATO__c}
&00N80000003uEtT={!Opportunity.Total_Est_Contribution__c}
&00N80000003uEtY={!Opportunity.Assets_Under_Mgmt__c}
&00N80000003uEsw={!Opportunity.Total_Atlas_Premium__c}
&Description={!Opportunity.Description}
&00NM0000000H3dR={!Opportunity.Discount_Percentage__c}

 

  • September 27, 2011
  • Like
  • 0

Hello all,

I'm an APEX noob, so please help. It would be appreciated!

We have a custom button on the Opportunities page, "Create Contract."  The button opens a window for a new Contract and pulls certain fields from the Opportunity into the new Contract.

We have recently begun to use both Opportunity and Contract record types. We need to select the Contract record type based on the Opportunity record type.

Mapping examples:
Opportunity Record Type A - Contract Record Type A (this is the default Contract type)
Opportunity Record Type B - Contract Record Type A
Opportunity Record Type C - Contract Record Type A
Opportunity Record Type D - Contract Record Type B
Opportunity Record Type E - Contract Record Type C

I have succeeded in passing a single record type, but I am having trouble in setting up the IF- ELSE statement in the button code to handle multiple record types.

The code is below. I am 100% certain that my IF statement syntax is incorrect somewhere, because it appears that the program never enters the code.  The new Contracts page always opens with user's default contract page view.

If I replace the below IF statement with the line:

 

&RecordType=012M00000000AcK 

 


then that record type is used, and the Contracts page opens with the page view associated with that Contract Record Type.

If any of you could help me with the syntax for a two-part IF-ELSE statement then I can build out the rest of the scenarios. Thanks!

 

 

/800/e?retURL=%2F800%2Fo

&if ({!Opportunity.RecordTypeId}==012C00000003okgIAA){
// Do this if the condition is true 
RecordType=012M00000000AcK   
} else {
// Do this if the condition is not true 
RecordType=012800000003buxAAA
}

&ctrc7_lkid={!Opportunity.AccountId}
&00N80000003uEo4={!Opportunity.Country__c}
&CF00N80000003VFS3={!Opportunity.Name}
&00N80000003uEsV={!Opportunity.CloseDate}
&00N80000003uEn1={!Opportunity.Policy__c}
&ctrc5={!Opportunity.Contract_Start_Date__c}
&00N80000003uEnk={!Opportunity.ExPat__c}
&00N80000003uEnl={!Opportunity.ASO__c}
&00N80000003udsE={!Opportunity.Cross_Marketing__c}
&00N80000003uErI={!Opportunity.Type}
&00N80000003uEsG={!Opportunity.Pooled__c}
&00N80000004ILAP={!Opportunity.Insurance_Company__c}
&00N80000004ILAA={!Opportunity.Bill_Type__c}
&00N80000004CNNe={!Opportunity.Expat_Account_Manager__c}
&00N80000003uEmr={!Opportunity.LOB_Expat__c}
&00N80000003uEmh={!Opportunity.LOB_del__c}
&00N80000003uEui={!Opportunity.Quoted_Due_Date__c}
&00N80000003uEww={!Opportunity.Quoted_Received_Date__c}
&00N80000003uEnm={!Opportunity.Quoted_Release_Date__c}
&00N80000003uErJ={!Opportunity.Decline_Options__c}
&00N80000003uExV={!Opportunity.Lost_Options__c}
&00N80000003uEsH={!Opportunity.Currency__c}
&00N80000003uEn3={!Opportunity.Life_Premium__c}
&00N80000003uEn2={!Opportunity.of_Employees__c}
&00N80000003uEn4={!Opportunity.Medical_Premium__c}
&00N80000003uEo1={!Opportunity.Disability_Premium__c}
&00N80000003uEuh={!Opportunity.Dental_Premium__c}
&00NC0000004yFM1={!Opportunity.Business_Travel_Medical_Premium__c}
&00N80000004ENTC={!Opportunity.LTD_Premium__c}
&00N80000004ENTH={!Opportunity.Other_Premium__c}
&00N80000003uEmi={!Opportunity.Total_Premium__c}
&00N80000003uEsp={!Opportunity.Collected_Contribution__c}
&00N80000003uEo5={!Opportunity.Collected_ATO__c}
&00N80000003uEsv={!Opportunity.Total_Collected_Contribution__c}
&00N80000003uErE={!Opportunity.Est_Annual_Contribution__c}
&00N80000003uEtO={!Opportunity.Est_ATO__c}
&00N80000003uEtT={!Opportunity.Total_Est_Contribution__c}
&00N80000003uEtY={!Opportunity.Assets_Under_Mgmt__c}
&00N80000003uEsw={!Opportunity.Total_Atlas_Premium__c}
&Description={!Opportunity.Description}
&00NM0000000H3dR={!Opportunity.Discount_Percentage__c}

 

  • September 27, 2011
  • Like
  • 0