cancel
Showing results for 
Search instead for 
Did you mean: 

How to get current user (Customer Model) in ASM

former_member44066
Discoverer
0 Kudos
1,390

Hi,

I am trying to get the current customer for whom the ASM agent has started the session, tried below few OOTB services but nothing worked.

userService.getCurrentUser();
assistedServiceService.getAsmSession().getEmulatedCustomer()

I am using Spartacus ASM with Hybris 2011.

Thanks,

Accepted Solutions (0)

Answers (2)

Answers (2)

alemasetto
Participant
0 Kudos

Hi samsharma007

during an ASM session, the Out of The Box path param userId refers to the impersonated user while "current" is the agent user.

/users/{userId}/  

You have to ensure that the proper userId is provided to backend calls. If it's missing in the calls, then you have to apply some changes to Spartacus. Not all OCC Controllers have the path param in the @RequestMapping, in those cases you have to extend the backend APIs as well.

If you like the answer please accept it.

0 Kudos

Hi,

Did you try the assistedServiceFacade class like below?

assistedServiceFacade.getAsmSession().getEmulatedCustomer().getUid()
former_member44066
Discoverer
0 Kudos

Hi,

Yes, already tried, this is similar to assistedServiceService.getAsmSession().getEmulatedCustomer()

but getAsmSession() retuning null.

Apparently, there is no ootb option/service available for this in Spartacus.

0 Kudos

So, could you look into this document for spartacus => https://sap.github.io/spartacus-docs/asm/