Hi I'm trying to create a custom button with Javascript OnClick function on an object that will use Upsert Functionality.

Here's my Javascript Button Function:

{!REQUIRESCRIPT("/soap/ajax/22.0/apex.js" )}
var connection = sforce.connection;
var newVacancyMember = new sforce.SObject("Vacancy_Member__c");
var accId;
var Users = sforce.connection.query("SELECT Id, AccountId, Persons_Account_ID__c FROM User WHERE Id = '{!$User.Id}'");

var UserArray = Users.getArray("records");
currentUser = UserArray[0];

if(currentUser.Persons_Account_ID__c != '') {
    accId = currentUser.Persons_Account_ID__c;
} else if(currentUser.AccountID != '') {
    accId = currentUser.AccountID;
newVacancyMember.Apply__c = "Yes";
newVacancyMember.Account__c = accId;
newVacancyMember.Vacancy__c = '{!Vacancy__c.Id}';

var vacancyMember = 

result = sforce.connection.upsert("Unique_Identifier__c",[newVacancyMember]);


Then this error is being thrown:

{created:'false', errors:{message:'Unique_Identifier__c not specified', statusCode:'MISSING_ARGUMENT', }, id:null, success:'false', }

Am I missing something? Thanks

1 Answer 1


You need add to the user query the field that you are ussing as externalId, in your case Unique_Identifier__c

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.