+ Start a Discussion
ChitraChitra 

Resetting Parent ID

Hello.

I m trying to reset the parent field for the Account.! I tried setting the ParentID to null. It doesnt seem to work. Is there any other way to do this?

How should I reset the Parent ID and make it point to null.

Chitra

 

ScotScot

Chitra,

If you're not already familiar with it,  you might need to check out the "fieldsToNull" array in the sObject. There's a small note about this, entitled "Resetting Values to null" on page 76 of the API document, and it's also explained in
http://forums.sforce.com/sforce/board/message?board.id=general_development&message.id=867

Scot

ChitraChitra

Thanks Scot.

I checked if the parent field were editable and nillable( nullable). The parent Id is editable and nillable.

I always tried the following

1.     acc.setParentId(null);
   
2.     String fields[] = new String[1];
        fields[0] = "ParentId";
        acc.setFieldsToNull(fields);

3.    acc.setFieldsToNull(1, "ParentId");

 

-   Where acc is the account object I m trying to update.! Ofcourse the first one doesnt work . the second and third solution throws an error message.

Bad field name parentId on update/insert call.

I verified the field name ParentID  using DescribeObject call on Account. So I m not sure why this fails , inspite of provinding the correct Field name.

Or I might not be doing the right thing to set the parent id to null.

Any help is appreciated.

Thanks

Chitra

 

ScotScot

Chitra ..
     I'm afraid I can't offer the next help ... I'm not familiar enough with your language.
     On the other hand ... from what I do know, it seems you're doing the right thing ...

Someone else ...?

Scot

DevAngelDevAngel

Hi Chitra,

 

This syntax is correct:

 

acc.Id = "00130000002sTYJ";

acc.ParentId = null;

acc.fieldsToNull = new String[] {"ParentId"};

binding.update(new sforce.sObject[] {acc});