logo
Welcome to our new AbleCommerce forums. As a guest, you may view the information here. To post to this forum, you must have a registered account with us, either as a new user evaluating AbleCommerce or an existing user of the application. For all questions related to the older version of Gold and earlier, please go to AbleCommerce Gold forum. Please use your AbleCommerce username and password to Login. New Registrations are disabled.

Notification

Icon
Error

Options
Go to last post Go to first unread
ray22901031  
#1 Posted : Tuesday, June 8, 2021 3:06:26 AM(UTC)
ray22901031

Rank: Advanced Member

Groups: Authorized User, Developers
Joined: 2/17/2019(UTC)
Posts: 909

Thanks: 3 times
Was thanked: 15 time(s) in 15 post(s)
What would be the best way to prevent a user in the admin backend from editing an order, (not being able to change anything at all, including the line items), if a specific condition is met?

Thank you

Wanna join the discussion?! Login to your AbleCommerce Forums forum account. New Registrations are disabled.

judy at Web2Market  
#2 Posted : Tuesday, June 8, 2021 6:03:20 AM(UTC)
judy at Web2Market

Rank: Advanced Member

Groups: Developers
Joined: 11/7/2018(UTC)
Posts: 303

Thanks: 21 times
Was thanked: 5 time(s) in 5 post(s)
In a Gold site, I disabled links like the change status link, or the delete/edit order item buttons.
ray22901031  
#3 Posted : Tuesday, June 8, 2021 6:10:31 AM(UTC)
ray22901031

Rank: Advanced Member

Groups: Authorized User, Developers
Joined: 2/17/2019(UTC)
Posts: 909

Thanks: 3 times
Was thanked: 15 time(s) in 15 post(s)
Hey Judy,

That is my concern, there are so many different buttons and links inside the order form view. If this was a desktop application, I would check the before edit event of the table itself, then issue an abort statement after displaying a friendly message.

We are trying to prevent any orders that are set to "complete" or "cancel" status, that are over 35 days old, from being deleted, modify, or changed in any way. This is determined by a custom field in the orders table, and the manipulation of this field is based on a desktop app.

I am assuming that AbleCommerce version 9, current version, does not have access to table events?

Any reply from anyone, would be useful.

Thanks
shaharyar  
#4 Posted : Wednesday, June 9, 2021 1:55:02 AM(UTC)
shaharyar

Rank: Advanced Member

Groups: Admin, Developers, Registered, HelpDesk, Authorized User
Joined: 10/5/2018(UTC)
Posts: 704

Thanks: 5 times
Was thanked: 113 time(s) in 112 post(s)
There is a Save method in the repository class. You can try to add the prevent logic in that method and abort the final save process.
CommerceBuilder\Orders\OrderRepository.cs

Code:
AbleContext.Current.Database.RollbackTransaction();


You can try using this method to roll back the SQL changes.

Hope this helps!
ray22901031  
#5 Posted : Wednesday, June 9, 2021 2:06:14 AM(UTC)
ray22901031

Rank: Advanced Member

Groups: Authorized User, Developers
Joined: 2/17/2019(UTC)
Posts: 909

Thanks: 3 times
Was thanked: 15 time(s) in 15 post(s)
Not the best way to do this since an editing process is underway, and we are also talking about the order line items as well. I wish there was a "before edit event" that we could tap into.

It is also a waste of time to have somebody make lots of changes, and then try to abort the moment you try to save, it's better to address this issue before trying to edit in the first place, and trying to prevent the edit by displaying a friendly message.

Remember it's not only the orders table, it's payments, shipping, and so many other factors that revolves around orders.

Besides going into the order view and capturing every single click there, any other way that you can see this happening with this current version?

I know you guys are planning on increasing events in the future, this is definitely one area you may wish to look into.

Any feedback would be helpful.
-Thanks
ray22901031  
#6 Posted : Wednesday, June 9, 2021 2:17:32 AM(UTC)
ray22901031

Rank: Advanced Member

Groups: Authorized User, Developers
Joined: 2/17/2019(UTC)
Posts: 909

Thanks: 3 times
Was thanked: 15 time(s) in 15 post(s)
Just to give you an idea what it would look like in Object Pascal by tapping into Before a Table Edit Event. - Six lines of code

If database.FieldByName("cf_OrderLock").Value = 1
then
begin
MessageDlg,info("This Order is LOCKED, please see your supervisor.");
Abort;
end;

The above is self-explanatory, it just shows and demonstrates what I'm trying to accomplish.

Again many thanks for anyone who can help.

-Ray
judy at Web2Market  
#7 Posted : Wednesday, June 9, 2021 6:03:08 AM(UTC)
judy at Web2Market

Rank: Advanced Member

Groups: Developers
Joined: 11/7/2018(UTC)
Posts: 303

Thanks: 21 times
Was thanked: 5 time(s) in 5 post(s)
You could try putting javascript on the page to disable all fields if the order has a particular order status. We have a specialized version of Gold for some clients that does that on the edit product page because all the product data is supposed to come from an import.
ray22901031  
#8 Posted : Wednesday, June 9, 2021 6:56:09 AM(UTC)
ray22901031

Rank: Advanced Member

Groups: Authorized User, Developers
Joined: 2/17/2019(UTC)
Posts: 909

Thanks: 3 times
Was thanked: 15 time(s) in 15 post(s)
Thanks Judy,

We are looking at many options to try to get this done, the lack of events, especially those that tie directly to a table is making it a little bit more complicated than it needs to be.

The good news is, in order to manipulate any change in an order, you need to click something first. In the order view only, not including the line items, they are 21 different areas were someone can click to manipulated an order.

Right now I'm trying to acquire as much information as possible, to discuss this with a developer to see which is the best way to proceed. Another way would be to capture this with a trigger at the table level, but that could create havoc in the admin section.

I wish that Able's documentation was more up-to-date, especially with the MVC stuff, everything pretty much just reference Gold and even that lacks detail.

Still waiting on support to see what they would advise, a before edit method in the repository class would be ideal.

Your feedback is highly appreciated,
-Ray
shaharyar  
#9 Posted : Wednesday, June 9, 2021 9:44:03 AM(UTC)
shaharyar

Rank: Advanced Member

Groups: Admin, Developers, Registered, HelpDesk, Authorized User
Joined: 10/5/2018(UTC)
Posts: 704

Thanks: 5 times
Was thanked: 113 time(s) in 112 post(s)
You can also make use of a global filters in MVC. Please look into the articles for more help
https://www.tutlane.com/...ion-handling-and-logging
https://stackoverflow.co...er-automatically-in-mvc5

You can write your logic in this class and prevent the actual code from being executed.

I hope this helps!
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.