The 1C:Enterprise developers forum

#1
People who like this: 0 Yes / 0 No
Active user
Rating: 5
Joined: Jun 4, 2013
Company:

Hi
I'm trying to delete a specific catalog item  from another catalog ... for example i'm now in customers catalog and i want to check if there is any same item in the contact catalog (I'm comparing the description) ... if there isn't i gonna write a new one ... if it exists I want to update it (write a new one and delete the old one)

but i'm failing in the deleting part ... can anyone help me with that ?!

and thanks in advance

 
#2
People who like this: 0 Yes / 0 No
Timofey Bugaevsky
Guest

Joined:
Company:

Code
ContactPersonRef = Catalogs.ContactPersons.FindByDescription("John Doe");
If Not ValueIsFilled(ContactPersonRef) Then
   ContactPersonObject = Catalogs.ContactPersons.CreateItem();
   ...
   ContactPersonObject.Write();
   ContactPersonRef = ContactPersonObject.Ref;
EndIf;

 
#3
People who like this: 0 Yes / 0 No
Active user
Rating: 5
Joined: Jun 4, 2013
Company:

Sorry but it's not working ... it prevent the duplication but it doesn't update the new entries

I wrote like this:  

Code
ContactPersonRef = Catalogs.Contacts.FindByDescription( object.Description );
If Not ValueIsFilled(ContactPersonRef) Then
   ContactPersonObject = Catalogs.Contacts.CreateItem();
   ContactPersonObject.Description=Object.Description;
   ContactPersonObject.Email=Object.Email;
   ContactPersonObject.TelephoneNumber=Object.TelephoneNumber; 
   ContactPersonObject.Website=Object.WebSite;
   ContactPersonObject.SecondTelephoneNumber=Object.SecondTelephoneNUmber;
   ContactPersonObject.Write();
   ContactPersonRef = ContactPersonObject.Ref;
EndIf;

 
#4
People who like this: 0 Yes / 0 No
Just came
Rating: 0
Joined: Oct 8, 2012
Company: SPD Shcherbakov

Code
ContactPersonRef = Catalogs.Contacts.FindByDescription(object.Description);       
If Not ValueIsFilled(ContactPersonRef) Then 
   ContactPersonObject = Catalogs.Contacts.CreateItem(); 
Else
   ContactPersonObject = ContactPersonRef.GetObject();
EndIf;
ContactPersonObject.Description=Object.Description; 
ContactPersonObject.Email=Object.Email; 
ContactPersonObject.TelephoneNumber=Object.TelephoneNumber; 
ContactPersonObject.Website=Object.WebSite; 
ContactPersonObject.SecondTelephoneNumber=Object.SecondTelephoneNUmber; 
ContactPersonObject.Write(); 
ContactPersonRef = ContactPersonObject.Ref;

Edited: Dmitry Shcherbakov - Jul 03, 2013 04:12 AM
 
#5
People who like this: 0 Yes / 0 No
Active user
Rating: 5
Joined: Jun 4, 2013
Company:

thanks it worked :)

 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)