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
Raj Kumar 88Raj Kumar 88 

How to create a custom button on one object that inserts record in other object of look up value?


Hi ,
I found lots of post - https://success.salesforce.com/answers?id=90630000000gwhCAAQ.
I am doing the same thing, if i am using Name field only then it is working fine but 
if i put lookup field then it is not working.

Customer_Name__c - Look Up field - Contact Lookup
Requested_By__c- Look Up Field - Contact Lookup

{!REQUIRESCRIPT("/soap/ajax/23.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/23.0/apex.js")} 


var oppty =  new sforce.SObject('SalesOrder__c');
oppty.Name = '{!LeadGen__c.Name}'; - Working fine if i assign Name field only
oppty.Customer_Name__c = '{!LeadGen__c.Account_NameId__c}'; -- Look up Field 
oppty.Requested_By__c = '{!LeadGen__c.Contact_PersonId__c}'; -- Look up Field
result = sforce.connection.create([oppty]);

Both objects are custom.
Please help to resolve this issue. if i am wrong then please let me know

Thanks in advance
Balaji Chowdary GarapatiBalaji Chowdary Garapati

@Raj Kumar 88:

 You can refer to my respone in the below post:

https://developer.salesforce.com/forums/ForumsMain?id=906F0000000Au5OIAS


Hope it helps:

Thanks,
balaji