Get particular user's all information

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • VigneshChinnaiyan
    Member
    • Jan 2018
    • 61

    Get particular user's all information

    Hello,

    I am using the below code to check the current user created the current entity or not.

    this.getUser().id==this.model.get('createdById')

    How to check the current user Country (Custom Field) = Current entity created by user Country (Custom Field).

    this.getUser().country==this.model.get('createdByI d').country Does this works?

    Thanks.
  • tanya
    Senior Member
    • Jun 2014
    • 4308

    #2
    Hello,
    this.getUser().get('country') - country of current user,
    but this.model.get('createdById') returns only id (string). You need user object. after you load it, you can get country value with userModel.get('country).

    Comment

    • VigneshChinnaiyan
      Member
      • Jan 2018
      • 61

      #3
      Thanks Tanya,

      Can you give me the exact syntax? Or please let me know this is correct,

      For getting the current user ID,

      var someUsr = this.model.get('createdById');
      var someUsrCountry = someUsr.userModel.get('country)

      Will the above method work?

      Thanks.

      Comment

      • VigneshChinnaiyan
        Member
        • Jan 2018
        • 61

        #4
        Tanya,

        How to load the user object, can you please explain.?

        Thanks.

        Comment

        • tanya
          Senior Member
          • Jun 2014
          • 4308

          #5
          call API 'api/v1/User/' + this.model.get('createdById')

          Comment

          • VigneshChinnaiyan
            Member
            • Jan 2018
            • 61

            #6
            Yes as you said i parsed the api, and it worked.

            Thank you.

            $.getJSON('User/' + this.model.get('createdById'), function (json) {
            console.log(json);
            });
            Last edited by VigneshChinnaiyan; 07-12-2018, 11:36 PM.

            Comment

            • tanya
              Senior Member
              • Jun 2014
              • 4308

              #7
              parse the data, you get. What the problem? You can load retrieved data in the model and use as object or not, as you wish.

              Comment

              • VigneshChinnaiyan
                Member
                • Jan 2018
                • 61

                #8
                Tanya,

                Thank you so much, It worked.
                Last edited by VigneshChinnaiyan; 07-12-2018, 11:35 PM.

                Comment

                Working...