Import US format address to Espo format address
Collapse
X
-
Haaa just see : more simple in formula
string\split ","
then
array\at
then as i don't find regex in formula :
string\split. " " -
Hi,
it's not formula but something so :
with this sample : 10749 New Haven St UNIT 1, Sun Valley, CA 91352
PHP Code:<?php
namespace Espo\Custom\Hooks\Lead;
use Espo\ORM\Entity;
class MyHook
{
// An optional parameter, defines in which order hooks will be processed.
// Lesser value means sooner.
public static $order = 5;
public function __construct(
// Define needed dependencies.
) {}
public function beforeSave(Entity $entity, array $options): void
{
if ($entity->isNew() && $entity->get('flatAddressField')) {
$addressArray = explode(",", $entity->get('flatAddressField'));
$entity->set('addressStreet', $addressArray[0]);
$entity->set('addressCity', $addressArray[1]);
$entity->set('addressState', preg_replace( '/[^a-z]/i', '', $addressArray[2]));
$entity->set('addressCountry', preg_replace( '/[^0-9]/i', '', $addressArray[2]));
}
}
}Leave a comment:
-
There's no such ability. One possible solution is to create a custom auxiliary field (of varchar or text type) and write a parsing formula script or a custom formula function. Import the address to this field, the formula will parse it and set parsed values to address fields.
Very interesting, can you please help with such formula?Leave a comment:
-
There's no such ability. One possible solution is to create a custom auxiliary field (of varchar or text type) and write a parsing formula script or a custom formula function. Import the address to this field, the formula will parse it and set parsed values to address fields.Leave a comment:
-
Import US format address to Espo format address
How can we import files with such address:
10749 New Haven St UNIT 1, Sun Valley, CA 91352
To Espo formatted address, and make it
Street: 10749 New Haven St UNIT 1
City :Sun Valley
State: CA
Postal: 91352
I know that system can do a very similar thing to the name, parse it, and make it first/last, but I can't find anything similar for the address, any options?
I appreciate your help!Tags: None
Leave a comment: