Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Enterprise – Business applications platform > Delete a specific catalog item

Forum

Search UsersRules
Delete a specific catalog item
#1
Active user
Points:: 0
Joined:: Jun 4, 2013

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

Profile
#2
Guest
Points::
Joined::

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

Profile
#3
Active user
Points:: 0
Joined:: Jun 4, 2013

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;

Profile
#4
Just came
Points:: 0
Joined:: Oct 8, 2012

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;

Profile
#5
Active user
Points:: 0
Joined:: Jun 4, 2013

thanks it worked :)

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



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.