Order Attachments Update Issues

Discussions related to order tracking development with the ProForm module.

Moderator: Phil Barton

Post Reply
joe.mag
Posts: 122
Joined: Thu Aug 04, 2011 3:11 pm

Order Attachments Update Issues

Post by joe.mag »

I am working with the Boylan release of Select.

I am going to be using the API to maintain a special document in some of my orders' attachments collections (i.e. IOrder.DocumentImage collection). I see samples on how to create a new document via the API (IOrder.DocumentImage.CreateNew()) which works great for document creation and attachment to an order. However, I do not see class members, examples, or discussion of how to perform the other core operations of CRUD (Create, Read, Update, Delete). Specifically, how can I either update or delete attachments?

As far as updating, I have tried simply editing the attributes of an existing document that have changed (i.e. OriginalLocation and SubmittedDate) and then saving the order (IOrder.SaveOrder) and while I get no errors neither does the document's content update--it still shows the content it had when I created it while the date does update as expected.

As far as deleting an attached document I don't have anything to go on so not sure what to even try. If I can get update to work then delete is not that important but it seems like the API should support full CRUD operation since sooner or later someone will need it.
John Morris
Posts: 411
Joined: Thu Sep 11, 2008 11:35 am
Location: Raleigh, NC, USA
Contact:

Re: Order Attachments Update Issues

Post by John Morris »

What is your timeline to upgrading to v3.0? The API in v3.0 is MUCH improved in this area and I highly recommending waiting (if possible) to implement anything against that area. Implementing against Boylan (v2.6) would require a rewrite when moving to v3.0 anyways.
John Morris
Sr. Software Architect
SoftPro
joe.mag
Posts: 122
Joined: Thu Aug 04, 2011 3:11 pm

Re: Order Attachments Update Issues

Post by joe.mag »

All I can tell you is I've been told by my management that Cameron is experiencing so many problems that we won't be upgrading for the indefinite future. You may disagree about the assessment of Cameron my management is operating under but that's the situation. So I would like a solution for Boylan.

If I can't get a solution via the API then I will consider a solution via direct database access (although I don't relish it). I would appreciate, if that's the most direct route, if you could tell me what tables need to be updated if I'm going to delete an attached document so that I don't get my orders in an inconsistent/corrupted state. As I said, I realize this is dangerous and bad practice but if it comes to it I'll have no choice. Related to this, can you tell me if IOrder.LockStatus provides an accurate, real-time status of order locking?

Thanks
joe.mag
Posts: 122
Joined: Thu Aug 04, 2011 3:11 pm

Re: Order Attachments Update Issues

Post by joe.mag »

By way of documenting my own issue, I found a couple of things:

1) Cursory experimentation indicates the lock status is not accurate. I could see the lock in SPAdmin but the API call indicated no lock and when I went to open the order r/w mode an exception was thrown that stated the order was locked.

2) As best I can tell from looking at keys in the SelectDb (on the DocumentImage table) and experimentation, it's pretty straightforward to directly manage attached documents via the API. A couple of items may save you time if you start deleting attachments via direct database access:
a) You can't delete a doc and add one back with the same name unless you save and reopen the order--the business logic won't know the original is gone so you'll get a duplicate document name exception
b) If you are also managing the physical files in the Image store remember that SoftPro Select marks everything in there as read-only so Flle.Delete will throw an exception "access denied" if you don't first set attributes to not-read-only using code like this:

Code: Select all

                        FileAttributes attrs = File.GetAttributes(strPath);
                        attrs &= ~FileAttributes.ReadOnly;
                        File.SetAttributes(strPath, attrs);

                        File.Delete(strPath);
Post Reply