0 votes

Hi,

I want to format all existing entries in "telephone number" to the E.164 without exporting and importing a list.

At the moment we have the following formats:

+49123456789 0123456789 +49.123.456.789

It should be by default +49 123 456 789

How can I catch this with a scheduled task?

Thanks

by (470 points)
edited by

1 Answer

0 votes
by (272k points)

Hello Boris,

There is no possibility to verify/update existing user phones in a business rules as they only trigger when a specific operation is executed. For this purpose, you need to use a scheduled task like the following: image.png In the task condition, use the following regular expression: ^\+[0-9]{2}\s[0-9]{3}\s[0-9]{3}\s[0-9]{3}$.

As for the script, it should take the existing value and format it according to your requirements. If you have issues writing the script, please, specify what should be done in case the property is empty.

To make sure that users cannot enter a phone that does not match the regular expression, you need to adjust your property patterns accordingly. The following tutorial should be helpful: https://www.adaxes.com/help/MakePropertyRequiredAndSpecifyFormat.

0

Thanks for your help, I would be very pleased if you could make the script. In case the property is empty, the script should ignore it and simply continue.

0

Hello Boris,

What exactly do you mean by continue? Should the script just exit as there will be no data to use for proper formatting? Maybe it would be best if the script is not executed at all if the property is empty (it can be done using the corresponding condition)?

0

Yes, that would of course be even better. Thanks

0

Hello Boris,

Thank you for specifying. As such, the scheduled task should look like the following: image.png You can find the script below. In the script, the $propertyName variable specifies the name of the property to process. It should be the same one as in the condition.

$propertyName = "mobile" # TODO: modify me

# Get property value as is
$propertyValue = $Context.TargetObject.Get($propertyName)
$propertyValue = $propertyValue.Replace("+","").Replace(" ","").Replace(".","")

if (($propertyValue.Length -eq 10) -and ($propertyValue -like "0*"))
{
    $propertyValue = $propertyValue.Remove(0,1)
}

if ($propertyValue.Length -eq 9)
{
    $propertyValue = "49" + $propertyValue
}

if ($propertyValue.Length -ne 11)
{
    $Context.LogMessage("The value $propertyValue of property $propertyName cannot be formatted as its length does not meet the requirements.", "Warning")
    return
}

# Format property value
$formattedValue = "+" + $propertyValue.SubString(0,2) + " " + $propertyValue.SubString(2,3) + " " + $propertyValue.SubString(5,3) + " " + $propertyValue.SubString(8,3)

# Update the user
$Context.TargetObject.Put($propertyName, $formattedValue)
$Context.TargetObject.SetInfo()
0

Thanks for the script, works great!

Related questions

0 votes
1 answer

Good afternoon, I've been asked to change our phone number fields to be E.164 compliant. I have come up with the following Regular Expressions for the Phone (with extension), Fax, and mobile device numbers. I ... {1,14}([\ ]{1}[\bext\b]{3}[\ ]{1}[0-9]{3,5})?

asked Jun 13, 2016 by Dbradford (170 points)
0 votes
1 answer

To avoid typos at the user creation, I want if it is possible to define der Property "IP Phone" by default as the last 4 digits of the property "Telephone Number" ? Thanks

asked Oct 11, 2022 by boris (470 points)
0 votes
1 answer

Hello Would it be possible for us to have a report which details: User Name Description Office Mobile Phone Number Custom Attribute 3 (we are using this alongside mobile phone number to contain the model of phone) Mobile Phone (Other) Thanks in adavance

asked Feb 2, 2016 by CBurn (700 points)
0 votes
1 answer

Is there anyway to provide a corporate phone directory list to employees through the self service portal? Based on what I've seen in a search, it doesn't appear to be that this is possible. Thx! --Joel

asked May 21, 2018 by ashmite (470 points)
0 votes
1 answer

At user creation, when the inbox is created, I'd like to be able to format the address as firstname.lastname@domain.com for some users. Other users firstnameintial.lastname@domain.com, is this possible? Envornment is hybrid O365. Thanks!

asked Jan 4 by cewilson (140 points)
3,351 questions
3,052 answers
7,791 comments
545,104 users