Tuesday, March 1, 2011

Do you know about RunAsId() ? here is the ans

It is to run the request against some other user id.

Ex. You(user Id: 1000) logged into the system .But you want to place an order as if your wife(User Id:1001) is placing an order. In this case, you can set RunAsId to 1001.

com.ibm.commerce.context.base Interface BaseContext.setRunAsId(java.lang.Long nMemberId)
This method sets the run-as user for the request associated with this context

getRunAsId()
This method gets the run-as user for the request associated with this context.

BaseContext baseContext = (BaseContext)getCommandContext().getContext(BaseContext.CONTEXT_NAME);
baseContext.getRunAsId();

Thanks for senthil ..

2 comments:

  1. Thats very usefull, i'm looking to do someting just like that in commerce 7 with the rest service GetCart to get the cart of any user been the admin. Thx for the data.

    ReplyDelete
  2. Hi,

    Did you manage to achieve this with the rest service GetCart? If so, could you please tell me how? I am struggling with exactly the same problem

    Dipak

    ReplyDelete