Possible to transition Litium B2B order processor order from backoffice

Is it possible to make a order transition from waitingForConfirmation to confirmed via backoffice in Litium or is this some feature that is only built into mypages?

Litium version: 7.3

I have looked at the state transition builder and it looks like current user need to be Order approver for the organization on the order but i get error trying to place order with user connected to organization as order approver. But it doesnt looke like it is my user that is attached to the pushing in the orde rin backoffice. instead it looks like a system user that isnt connected to the organization.

2019-12-04 16:19:33.7992 [App:04] [6a289171-ca5a-45b2-bee8-de12f0673c97] [ERROR] [] Could not determine user role, organization not found - For the order with Id 83247779-bff8-4ff3-ad69-d27111beffd8 (LS100169), state transition engine could not determine whether user has Ordergodk䮮are role or not for the user id 00000000-0000-0000-0000-000000000001. Organization with organizationId 47824471-bdb4-4a8a-8930-9fb04b407d17 was not found in relations module

In the OrderStateBuilder.HasApproverRole we have the line var person = _personService.Get(token.UserID); that verifies if the current user is OrderApprover for the organization on the order. If you changing the state from back office the token.UserID will be the administrator account. If you change this method to verifies that the token has content permissions for sales and in that case always return true in this method you will bypass the check.

using (token.Use())
{
    if (IoC.Resolve<AuthorizationService>().HasOperation(Operations.Function.Sales.Content))
    {
        return true;
    }
}

I assume that it’s ok to always allow an administrator account for sales to place orders.

i was thinking in the line of

if (person.SystemId.Equals(ModuleECommerce.Instance.AdminToken.UserID)) return true;

but you solution is perhaps more elegant :slight_smile:

will only work if you login with windows credentials, not if you are logged in with a normal user account that have permission to sales area.

The Error log above is from me login is as normal litium person/user actually connected to organizations connected to order i try to change and the user are also order approver.
why are then user id 00000000-0000-0000-0000-000000000001 logged in the error message?


image

00000000-0000-0000-0000-000000000001 are the person id for the System when you have logged in with Windows Credentials or executed with the admin/system-token…

Yes i understand that but that is why you previous answer is confusing to me. You say i need to login with windows credentials for the code to work but the code is executed with the same user regardless if a login with windows credentials or as a normal litium user.

This code resurns true regardless of windows credentials or not.
if (person.SystemId.Equals(ModuleECommerce.Instance.AdminToken.UserID)) return true;

The token that is passed into the method should be for the current logged in user. When you logging in with windows credentials this will be the admin/system account, if you login with a normal account that have permission to sales module it should be the normal account’s token that is passed into the method.

It can be that the old view think that you already is logged in and have access to this function so that will pass the admin-token instead (haven’t debug) and that’s the reason your if-statement also is working.

Ok for me admin token is always passed but now i understand you reasoning.
Thanks!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.