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
RCE_JereriahRCE_Jereriah 

Forcing Data into a lookup field using the following code

I'm using the following to create Commission entries from Opportunity line items and I have everything working correctly other than moving data into a lookup field on my Custom Object. Does anyone know the correct data the lookup field wants to populate upon creation? 

 

 

{!URLFOR($Action.Commission_Tracking__c.New, null, [ "00N50000001y1mA" = (100*OpportunityLineItem.OP_Commission_Rate__c), "00N50000001y20f" = Opportunity.Name, "00N50000001y20p" = OpportunityLineItem.OP_Account_Name__c, "00N50000001y214" = OpportunityLineItem.TotalPrice, "00N50000001y21s" = OpportunityLineItem.Link, "00N50000001y227" = OpportunityLineItem.OP_Product_Name__c, "00N50000001y22q" = OpportunityLineItem.Quantity, "00N50000001y22v" = OpportunityLineItem.UnitPrice, "00N50000001y23Q" = OpportunityLineItem.Cost_Floor__c, "00N50000001y1zc" = Opportunity.Id, "save"=1 ], true)}

 

The Opporutnity.Id is a valid field and the button works--it just doesn't populate my Opportunity Lookup field on my Commission Tracking entry. I've tried sending the Opportunity name to the field as well--no luck there.

Any help would be great! I've been hunting around for a solution to this for a while and finally decided I'd get a post up here.

 

Thanks,

~jm

 

Best Answer chosen by Admin (Salesforce Developers) 
RCE_JereriahRCE_Jereriah

Got it. The field names of Lookup fields in the button code have to start with CF. The data you force is in only the name. The working code looks like this:

 

 

{!URLFOR($Action.Commission_Tracking__c.New, null,
[
"00N50000001y1mA" = (100*OpportunityLineItem.OP_Commission_Rate__c),
"00N50000001y214" = OpportunityLineItem.TotalPrice,
"00N50000001y21s" = OpportunityLineItem.Link,
"00N50000001y22q" = OpportunityLineItem.Quantity,
"00N50000001y22v" = OpportunityLineItem.UnitPrice,
"00N50000001y23Q" = OpportunityLineItem.Cost_Floor__c,
"CF00N50000001y1zc" = Opportunity.Name,
"CF00N50000001y2RH" = Account.Name,
"CF00N50000001y2UQ" = Product2.Name,
"save"=1
],
true)}

 

This code takes data from a line item on an Opportunity and pushes it into a custom object (Commission Tracking).  The lookup fields work now and the new entry autosaves.

~jm