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

Javascript custom button - I need help!

I'm basically just learning as I go here - so bear with me!


I have a custom button on a custom object detail page that when clicked, I would like for it to create a child record and then update the lookupfield with the newly created child on the parent record. 


Here is the code I have - the first part works fine - the record creates seamlessly.  The second part updating the lookup field does not work  - I've altered, googled, altered, studied, and altered again with absolutely nothing working.


{!REQUIRESCRIPT("/soap/ajax/26.0/connection.js")} {!Partnership_Employees__c.Employee_Onboarding__c}

var copyonboarding = new sforce.SObject("Employee_Onboarding__c"); 
copyonboarding.Partnership_Employee__c = "{!Partnership_Employees__c.Id}"; 
copyonboarding.Name = "{!Partnership_Employees__c.Employee__c }";
copyonboardingID = copyonboarding.get("ID");


//update employee record
var employee = new sforce.SObject("Partnership_Employees__c")
employee.Employee_Onboarding__c = copyonboardingID;

window.alert("Employee Onboarding Created");