0

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/connection.js")}
{!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;
}
alert(accId);
newVacancyMember.Apply__c = "Yes";
newVacancyMember.Account__c = accId;
newVacancyMember.Vacancy__c = '{!Vacancy__c.Id}';

var vacancyMember = 


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

window.location.reload();

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

0

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .