Skip to Content
author's profile photo Former Member
Former Member

Passing currently logged in user id into an input field

Hello Gurus,

I have an application where i need to pass the currently logged in user ID into an input field, on that ID his employee smartform will be displayed via RFC. please send me the code to do so.

Add a comment
10|10000 characters needed characters exceeded

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jun 06, 2014 at 11:56 AM

    Dear Shilpi,

    1. Add component tc/je/usermanagement/api as a 'Used DC' (NW 7.0) / 'Required DC' (NW7.11 and up)

    2. Use the below code to get the logged in User

    try

    {

    IWDClientUser CurrentUser = WDClientUser.getCurrentUser();

    String UserId = WDClientUser.getCurrentUser().getSAPUser().getUniqueName();

    }

    catch(Exception e)

    {

    e.printStackTrace();

    }

    Thanks & Regards,

    Patralekha

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,Former Member


      As far as I know , use code like " IWDClientUser CurrentUser = WDClientUser.getCurrentUser(); "


      should just need depend dc "tc/wd/api".


      If user UME API,then should need depend "tc/je/usermanagement/api"

  • author's profile photo Former Member
    Former Member
    Posted on Jun 07, 2014 at 04:46 AM

    thank u gurus for ur instant help.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 09, 2014 at 09:45 AM

    Hi,

    I created two applications on the same RFC, in one of the applications the employee id is manually inputted and there is no error for the same. But when the currently logged in user id is fetched automatically, it is showing error.

    Add a comment
    10|10000 characters needed characters exceeded

    • hi shipi,

      In the second case , where you told that on fetching the currently logged user id ... u r getting error , it shows while creating applicaiton you have not checked the authentication check box.

      No worries for this component you have created application right ,

      double click the applicaiton, it opens application properties at the right hand side.

      now in the right hand side you have properties and application properites , choose Application properties tab.

      Click New Button->

      Now click Browse ->Choose Authentication -->In value drop down Choose True --now click finish

      now build your dc and deploy the same.

      like since you have not applied authentication to your application so wdclient.getuser...etc will give null

      now if you enable authentication to your application then it fetches the user.

      Regards

      Govardan Raj S

  • Posted on Jun 06, 2014 at 10:58 AM

    Hi Shilpi.

    WDClientUser.getCurrentUserOrNull().getSAPUser().getUniqueName()

    this will return the current user logon id.

    Regards Tobias.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 09, 2014 at 06:16 AM

    Hi Gurus,

    I use this code and my application is working very fine. When I am deploying the application, form is coming according to currently logged in user but it is also showing error

    Fill in all required entry fields , error key: RFC_ERROR_SYSTEM_FAILURE

    The code for user from display is:

    try

    {

    WDClientUser.getCurrentUser().getSAPUser().getUniqueName();

    user = WDClientUser.getCurrentUser().getSAPUser().getUniqueName();

    //wdContext.currentZfm_Empform_Portal_InputElement().setUsrid(CurrentUser());

    }

    catch(Exception e)

    {

    e.printStackTrace();

    }

    //String UserId1 = UserId;

    try

    {

    //wdContext.currentZfm_Empform_Portal_InputElement().setUsrid(wdContext.currentZfm_Empform_Portal_InputElement().getUsrid());

    wdContext.currentZfm_Empform_Portal_InputElement().setUsrid(user);

    wdContext.currentZfm_Empform_Portal_InputElement().modelObject().execute();

    }

    catch (WDDynamicRFCExecuteException e)

    {

    e.printStackTrace();

    wdContext.currentContextElement().setPdf_data(e.getMessage());

    }

    wdContext.currentContextElement().setPdf_data(convertXStringToURL(wdContext.currentOutputElement().getBin_File()));

    please help me to resolve this issue.

    Add a comment
    10|10000 characters needed characters exceeded

    • hi ,

      on click of display button ,

      what is the code being executed , there as suggested can u put in try catch block and post the logs that are coming in nwa , or else you can put this in exception block.

      //-------------------------------------------

      catch (Exception e)

      {

      StackTraceElement element[] = e.getStackTrace();

      StringBuffer buffer = new StringBuffer();

      for(int i=0;i<element.length;i++)

      {

      buffer.append(element[i]);

      }

      wdComponentAPI.getMessageManager().reportException(buffer.toString(),true);

      }

      //-----------------------------------------

      it will show the exactl line number where dump occurs we can trace the error easily...

      Regards

      Govardan Raj

  • author's profile photo Former Member
    Former Member
    Posted on Jun 09, 2014 at 12:28 PM

    Hi All,

    My problem got solved as i have rearranged my code and paste it in initialization to show the smart form on click of the tab according to the currently logged in user.

    thank you everyone for helping me out.

    thanks alot

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.