• Resolved benjamen02

    (@benjamen02)


    Hi there,

    I would like to get query a contact guid using the contact email address. I had a look at the php api for some guidance

    $user_email = $user_info->user_email; //valid
    $user_contact = new Entity(‘contact’, ’emailaddress1′, $user_email); //not sure
    $user_guid = $client->entity( ‘contact’, $user_contact ); //not sure

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author alexacrm

    (@alexacrm)

    @benjamen02
    you can use the key attribute syntax only if you have the alternate key defined.

    If you do not have the alternate key then your choice is to use FetchXml to retrieve the records (or use Query by attribute). Note that with fetch you will potentially have multiple rows coming back so search by email could return 0, 1, or many matching records.

    HTH

    • This reply was modified 3 years, 9 months ago by alexacrm.
    Thread Starter benjamen02

    (@benjamen02)

    ok thanks

    Using the Dataverse plug in do you still reference the libraries like this:

    use AlexaCRM\Nextgen\ConnectionService;
    use AlexaCRM\Xrm\{
    EntityReference,
    Entity,
    KeyAttributeCollection,
    ColumnSet
    };`

    $query = new \AlexaCRM\Xrm\Query\QueryByAttribute( ‘contact’ );
    $query->AddAttributeValue( ‘lastname’, ‘Example’ );
    $query->AddOrder( ‘firstname’, \AlexaCRM\Xrm\Query\OrderType::Descending() );
    $query->ColumnSet = new \AlexaCRM\Xrm\ColumnSet( [ ‘fullname’, ’emailaddress1′ ] );
    $collection = $client->RetrieveMultiple( $query );

    or do not need to put the whole “\AlexaCRM\Xrm\Query\QueryByAttribute” path in

    Plugin Author alexacrm

    (@alexacrm)

    @benjamen02

    use AlexaCRM\Xrm\{
    EntityReference,
    Entity,
    KeyAttributeCollection,
    ColumnSet
    };

    is just a shortcut for

    use AlexaCRM\Xrm\EntityReference;
    use AlexaCRM\Xrm\Entity;
    use AlexaCRM\Xrm\KeyAttributeCollection;
    use AlexaCRM\Xrm\ColumnSet;

    Whether to punch in an explicit full reference or use statement – it’s really up to you and your preferred style of coding.

    HTH
    George

    Thread Starter benjamen02

    (@benjamen02)

    Got it thanks George

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Retrieving a contact guid based on email address’ is closed to new replies.