Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update all values by email? #10

Open
mcpacific opened this issue Sep 28, 2016 · 3 comments
Open

Update all values by email? #10

mcpacific opened this issue Sep 28, 2016 · 3 comments

Comments

@mcpacific
Copy link

mcpacific commented Sep 28, 2016

Is it possible to update all values to an existing contact based on email address? I would like to update lead score, star value, tags and properties in a single command, if possible.

@graut
Copy link
Contributor

graut commented Sep 29, 2016

Hi @mcpacific,

Yes it is possible with API, but need to careful while calling this API. Please follow the step mention below and condition -

1. Get Contact by email using below API

https://github.com/agilecrm/php-api#12-to-fetch-contact-data

$result = curl_wrap("contacts/search/email/[email protected]", null, "GET", "application/json");
$contact = json_decode($result, false, 512, JSON_BIGINT_AS_STRING);

2. Use setter method to set lead score, star value, and contact properties :
$result = curl_wrap("contacts/search/email/[email protected]", null, "GET", "application/json");
$contact = json_decode($result, false, 512, JSON_BIGINT_AS_STRING);

$contact ->lead_score="80";
$contact ->star_value="4";
$contact ->tags=array("Player","Winner");

$contact -> properties = array(
array(
"name"=>"first_name",
"value"=>"Ronaldo",
"type"=>"SYSTEM"
),
array(
"name"=>"last_name",
"value"=>"de Lima",
"type"=>"SYSTEM"
)
);

$contact_json = json_encode($contact);

$contactResult = curl_wrap("contacts", $contact_json, "PUT", "application/json");

print_r($contactResult );

3.
Note Make sure that while settings contact properties you are setting all remaining contact properties too otherwise that data will be lost. So if your existing contact have first name, last name, email, address, custom fields then you have to send all this properties and not only first name, last name.

Please let us know in case need further information.

Thanks

@mcpacific
Copy link
Author

This is great, and will speed up updates. I'll be sure to check fields to ensure no data is lost!

Thank you!!

@ghost
Copy link

ghost commented May 22, 2018

Hi @graut and @mcpacific ,

with regard to Point #2 and #3, does that mean if my contact has many properties such as mailing address etc, I will have to include it in the setter method code, even if I'm not going to update those data? Thank you. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants