How to programmatically clear posting

The 1C:Enterprise developers forum

#1
People who like this:0Yes/0No
Just came
Rating: 1
Joined: Nov 26, 2012
Company: Roshan Ice Cream

Namaste!

I'm trying to create a Data processor to clear posting for a set of documents. Can you help me on how to programmatically clear posting?

 
#2
People who like this:0Yes/0No
Active user
Rating: 7
Joined: Sep 26, 2012
Company: individual

I write script for DocumentSelection. So you need use your set of documents

Code
DocSelection = Documents.Document1.Select();
While DocSelection.Next() Do
   DocSelection.GetObject().Write(DocumentWriteMode.UndoPosting);
EndDo;

 
#3
People who like this:0Yes/0No
Just came
Rating: 1
Joined: Nov 26, 2012
Company: Roshan Ice Cream

ivan avdonin, thank you!
And what if I need to clear posting not for all documents, but starting from some date?

 
#4
People who like this:0Yes/0No
Active user
Rating: 7
Joined: Sep 26, 2012
Company: individual

For this make query to Documents

Code
Query = New Query;
Query.Text = "
|SELECT
|   Document1.Ref
|FROM
|   Document.Document1 AS Document1
|WHERE
|   Document1.Date > &Date";

Query.SetParameter("Date", SomeDate);

DocSelection = Query.Execute().Choose();
While DocSelection.Next() Do
   DocSelection.Ref.GetObject().Write(DocumentWriteMode.UndoPosting);
EndDo;

 
#5
People who like this:0Yes/0No
Just came
Rating: 1
Joined: Nov 26, 2012
Company: Roshan Ice Cream

Thank you again! You did a great job!

 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.