How to get the user id by an email address?

i have an email of a user.
How do i get a user id by the email address?

$user->retrieve_by_string_fields(array('email1' =>  $organizerEmail));
doesn't work.

looked it up , no answer, only how to get the current user email addess , which i dont need.

Using SugarCRM community 6.5.13
Parents
  • Try to fetch the Logged in user Information in this way.

    var userID= app.user.get("id");

    To fetch the Email ID - email1 helps you.

    Or Normal ajax function to get from database using User ID.


  • Even if it's a Sugar CE 6.5 Topic, is good to know how to do it in Sugat 7 too, using javascript

    The complete code  in Sugar 7 is:

    var userEmail = ''

    var moduleName = "Users";

    var filters = [{id: app.user.get("id")}];

    var Users = App.data.createBeanCollection(moduleName)

    var req = Users.fetch({"filter": filters});

         req.xhr.success(function (data) {

           if (data.records.length > 0) {

                // console.debug(data)

                   userEmail = data.records[0].email[0].email_address

           }

    });

    // email object structure

    email[0]

    email_address           "email@example.com"

    invalid_email                false

    opt_out                          false

    primary_address           true

    reply_to_address           false

Reply
  • Even if it's a Sugar CE 6.5 Topic, is good to know how to do it in Sugat 7 too, using javascript

    The complete code  in Sugar 7 is:

    var userEmail = ''

    var moduleName = "Users";

    var filters = [{id: app.user.get("id")}];

    var Users = App.data.createBeanCollection(moduleName)

    var req = Users.fetch({"filter": filters});

         req.xhr.success(function (data) {

           if (data.records.length > 0) {

                // console.debug(data)

                   userEmail = data.records[0].email[0].email_address

           }

    });

    // email object structure

    email[0]

    email_address           "email@example.com"

    invalid_email                false

    opt_out                          false

    primary_address           true

    reply_to_address           false

Children
No Data