1

A program have merge features to merge two Accounts, however the merging is fail due to the isPartner value of Master Account is false.I want to update isPartner value of the Master Account to true but it throw me this error.

Uncaught {faultcode:'soapenv:Client', faultstring:'A duplicate value was specified for field 'IsPartner' in object 'Account', duplicate value 'true' prior value 'true'', }

This is snippet of my code

function updateIsPartner(masterId){

   var queryResult=sforce.connection.query("select Id ,Name,IsPartner from Account where Id IN (\'"+masterId+"\'")");
              var records=queryResult.getArray('records');
              alert('records...' + records);
                for (var i=0; i< records.length; i++) {
                     var record = records[i];

                       alert(record.Name+' -'+ record.Id);
                      if(record.Id==masterId){
                         alert('masterId');
                            record.isPartner=true;
                            var result = sforce.connection.update([record]);

                      }

                }

        }

Anyone knows what went wrong with my code? Please note my page version is 30.

2

I did a short research on that field and it's a bit special. First this is a Standard Field, however you can't find it in an out-of-the-box vanilla Org. It's not there by default.

It is created by the old Partner Portal feature or by communities.

Looking into the shema (e.g. with Force.comIDE/eclipse), this field is updatable. But there seem to be another validation to intercept and prevent you from writing to it. Accounts with IsPartner==true are related to a Partner-Portal-Login and therefore Salesforce might restrict you from simply writing to that boolean field without taking care of the Partner-Portal.

As an workaround to merge Accounts I would recommend that you

  1. check if there are none, one, or many accounts with IsPartner==true in your merge bundle

  2. case "none": simply omit this field (since all are ==false)

  3. case "one": take that Account which has the IsPartner as target (which survives the merge process) and other Accounts which has IsPartner==false as sources (these end up deleted after merge) and omit the field during merge. This assumption should usually make sense, but please verify.

  4. case "many": force the users to merge manually using the UI and to take care of the Partner-Portal access, too.

  • Actually just now while troubleshooting this, I add checking if(record.Id==masterId && record.IsPartner) and IT WORKS.Let me try write the full code later. – unidha Feb 6 '15 at 9:48
1

Well, my bad guys.This is nothing to do with the condition checking.It is something to do with the typo.

The correct field IsPartner not isPartner.

record.IsPartner=true;

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.