Tried to use email1 field for updating account’s primary email, but with no success. The below request has no effect (account still has old primary email).
I see the different response format (from the one in the referred topic) for /V8/module/Accounts/{{account.id}}/relationships/email_addresses
request.
And I do not see primary_address field though the corresponding column is present in email_addr_bean_rel table. I suspect the response data depends on the SuiteCRM (minor) version.
Hi @ilsid
You’re right, primary address is on the relationship.
Could you try your same API v8 calls on the online demo, which is current version Suite 8.6, and see if it returns the information you expect, primary_address.
@chris001 , I tried version 8.6.0 (image suitecrm:8.6.0-debian-12-r3). I see the same response result for /V8/module/Accounts/{{account.id}}/relationships/email_addresses
There is no primary_address field in the response
The standard approach of creating a new email address record and relating it to the Account with the primary flag set to 1 doesn’t work as expected in SuiteCRM versions 7.8 and above, by general consensus.
Workaround:
Create a new email address record, and then update the existing related primary email address on the Account to mark it as non-primary, followed by setting the new email address as primary. Here’s the steps involved:
Create a new Email Address record with the desired email address. You’ve done this.
Retrieve the existing related email address(es) of the Account.
Update the existing email address(es) by setting the primary flag to 0.
Relate the newly created email address to the Account. You’ve done this.
Update the newly related email address by setting the primary flag to 1.
So, steps 3 and 5 assume a direct database access, correct?
Maybe I’m missing something, but I didn’t find a way of updating the primary_address field in email_addr_bean_rel table via API
Steps 1-5 (including 3 and 5) are all REST API v8.
If there truly is no field for primary_email, then that would be a bug.
However, I’m sure primary_email is accessible somewhere in the REST API v8.
primary_email is not a EmailAddress field. It is relationship’s field ( email_addr_bean_rel table). I didn’t find a way of updating (and getting) it via API’s.
That’s why I created this topic
Create a relationship between the Account and the email address using the v8 API. You were doing this, however you failed to include the field primary_address. Be sure to include the field primary_address, and set it to 1.
I tried this before creating this topic.
I’m getting an error.
Looks like a bug. As a (temporary) workaround, I will implement this via direct database update.
{
"errors": {
"status": 400,
"title": null,
"detail": "The option \"primary_address\" does not exist. Defined options are: \"id\", \"type\"."
}
}