tanmay_nehete
I'm new here

Get current user name in F.S in content creator

I tried this: #global.project.getUserService().getUser().getLoginName() but this returns "SYSTEM".
Why? What I would like to have is the current user.

I want to retrieve currently logged in user name

16 Replies
MarsDD
Occasional Observer

Hi,

I had the same requirement Aktueller FS-User über globale Systemvariable global im Contentcreator

kind regards

Marcel

0 Kudos

but i need code for same

0 Kudos

Write a executable where you get the current user.

The ClientScriptContext has a method "getUser".

but unfortunately my complete code is written in HTML o/p channel.

0 Kudos

Hi,

getting the user during generation time is not possible as the generation is not user/session specific. For example, the generated files are cached in the preview for a while, so it is not even guaranteed that a preview generation is performed at all when a user calls a preview page.

Could you describe your use case in more detail?

Michael

0 Kudos

Hi Michael

We require only login user name in content creator. currently we're getting only "SYSTEM" with following API.
#global.project.getUserService().getUser().getLoginName()
#global.project.getUserService().getUser().getEMail()
#global.project.getUserService().getUser().getName()
#global.project.getUserService().getUser().getLDAPSection()
Regards Tanmay

0 Kudos

Hi Tanmay,

could you explain the purpose / scenario why and when you need the user name in CC? Maybe there is another solution than trying to use template syntax (which will not be successful).

Regards

Michael

0 Kudos

Hi,

write a executable like that

public final synchronized Object execute(Map<String, Object> params) {

     ClientScriptContext context = params.get("context");

     Map<String, String> returnMap = params.get("returnMap");

     User user = context.getUser();

     returnMap.put("userName", user.getLoginName());

}

This executable is callable from a FirstSpirit Script and also with WE_API.

kind regards

Marcel

HI
Could please help me where should I write this & how to call this on HTML o/p channel?

0 Kudos