SAP Hybris: Assisted Service Module (ASM)

Manpreet Singh
Aug 31, 2018 · 3 min read

If you are not new to Hybris, you all must be aware of ‘Add-on’ concept in hybris. It is similar to an extension and is literally used in the form of an additional plug-in functionality. ASM is an add-on in hybris. It allows the customer service representative to login to the storefront or website as the customer and get the same view of storefront as the customer does. Once logged-in, the agent can perform any action on customers behalf.

Order placed by Assisted Service Agent on behalf of Customer B4

This functionality is available out-of-the-box in b2c_acc_plus and b2b_acc_plus recipes. However, in case you have initialized SAP Hybris using some other common ones, such as, b2c_acc or b2b_acc, you can still use the ASM modules by following the steps given below:

1) In order to enable ASM module make sure you have the below extensions in localextensions.xml file

<extension name=’assistedservicestorefront’ />
<extension name=’assistedservicewebservices’ />
<extension name=’assistedservicefacades’ />
<extension name=’assistedservicepromotionaddon’ />
<extension name=’assistedserviceatddtests’ />

2) Then install the addon:
> ant addoninstall -Daddonnames=”assistedservicestorefront” -DaddonStorefront.yacceleratorstorefront=”<yacceleratorstorefront>

<yacceleratorstorefront> should be replaced by your own storefront extension.

3) Build the system
4) Start server
5) Go to HAC and do a system update
6) Go to https://electronics.local:9002/yacceleratorstorefront/?site=electronics&asm=true
7) Enter the credentials to login as asagent [default credentials: asagent / 123456]

Any Employee that belongs to the ‘asagent’ or its related groups can login and emulate as any customer and perform all operations that a customer can. If you have observed in the previous sentence, any ‘Employee’ can act as an asagent. What if you want a user other than Employee to act as one? For that you would need to do some minor customization as shown in the following section.

Allow users other than ‘Employee’ to act as an Assisted service agent

You would need to customize some logic in the ‘DefaultAssistedServiceFacade’. By default, the logic checks if the asagent is an Employee or not, in the line below:

If you notice the line inside try{} block is the cause.

final UserModel agent = getUserService().getUserForUID(username, EmployeeModel.class);

we can change this logic and replace it with the line below:

final UserModel agent = getUserService().getUserForUID(username);

However, by adding the new line above, we are allowing any user to login as the asagent and that is not a valid scenario. Right? This way, even any customer can emulate another customer and so on. This is not recommended.

A work around would be to add an IF condition after getting the UserModel object. Something like below:

if (agent instanceof EmployeeModel || super.isAssistedServiceAgent(agent))
{}

The above condition says that either the user should be an Employee or the user should belong to the ‘asagent’. or its related groups.

The method ‘isAssistedServiceAgent(agent)’ is already available in the ‘DefaultAssistedServiceFacade’ to check if the user belongs to ‘asagent’ group. So when you will be overriding this method in your custom extension facade, you an simply use this method using the ‘super’ keyword. So the final code should look something like this:

And you can out all the rest of the default code inside the IF condition.

With this IF condition, you can assign the ‘asagent’ group to any user and authorize them to login as Assisted Service Agent. You can even assign a customer to this usergroup and allow them to act as an agent. In real life scenario, a customer should not be made an agent. That is the work of an Employee or some customer user.

While overriding this logic, don’t forget to also override the bean.

Happy Learning!

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade