0 votes
$property = "mail" # TODO: modify me
#$regex = "^[a-zA-Z0-9_.%%\-\+]+@([a-zA-Z0-9_\-]+\.)+[a-zA-Z0-9_\-]+$" # TODO: modify me

# Get property value
$value = $Context.GetModifiedPropertyValue($property)

if ([System.String]::IsNullOrEmpty($value))
{
    return # The property wasn't changed
}

# Remove spaces
$value = $value.Replace(" ", ".")

# Remove dashes
$value = $value.Replace("-", ".")

# Remove underscores
$value = $value.Replace("_", ".")


# Validate property
#if ($value -notmatch $regex)
#{
#    $Context.Cancel("The property must match the following regular expression: $regex") # TODO: modify me
#}

# Update property value
$Context.SetModifiedPropertyValue($property, $value)
by (480 points)

1 Answer

0 votes
by (294k points)

Hello Derek,

As per our check, the script works just fine. Make sure it is executed in a Business Rule triggering Before an operation (e.g. Before creating a user, Before updating a user). Should you still have issues with the script replacing spaces and/or characters, please, provide us with all the possible details regarding the issues. If you face error messages, please, post here or send us (support[at]adaxes.com) screenshots.

0

Yes i am runnign th correct script.

image.png

image.png

Still dashes and underscores:

image.png

0

Hello Derek,

According to the execution log, you are mail-enabling the group first and only then the script that replaces spaces and special characters is executed. You need to separate the actions into two Business Rules. Finally, you should have something like the following:

  • Business Rule triggering Before creating a group image.png
  • Business Rule triggering After creating a group image.png
0

Same result.

setup:

image.png image.png

test: image.png

Result: image.png

0

Hello Derek,

The behavior occurs because the first action in your Business Rule triggering After creating a group ( i.e. set Email to %cn%@ahfproducts.com) overrides the results of the script execution. Also, you are using a different property as alias then the one updated by the script which overrides the email property one more time after the email address is being established. You need to make sure that the script updates the very same property that is used in the establish email address action as alias and remove the first action from the Business Rule triggering After creating a group.

0

Thank you. I can't believe i missed that.

Works !

Related questions

0 votes
1 answer

After creating a new user I'm modifying the user and setting 2 proxy addresses. I'm doing this with the build-in modify user functionality. Our email format is %firstname%. ... anybody have an idea to get this working, i'm not as Powershell wizzard...

asked Oct 15, 2018 by Quinten (100 points)
0 votes
1 answer

I am trying to create a business rule to send an email to the manager of the group when a member is added or removed from a rule-based group. I have created the business rule and it works for other groups but not for a rule-based group. Can this be done?

asked Jul 19, 2021 by mark.it.admin (2.3k points)
0 votes
1 answer

Hi all, I've created a 'View User' command via the Web Interface Configurator. I don't want users to be able to make any changes, so I've created a Custom ... there any way to remove this, short of removing the entire Exchange section itself? Thanks, David

asked Sep 5 by dshortall (80 points)
0 votes
1 answer

We have been able to add email addresses using the script in E-Mail Addresses Is there a way to reverse the process and specify the smtp address you want to remove using a similar subset of code.

asked Dec 14, 2022 by martin.mcclorey (40 points)
0 votes
0 answers

Hi, I found the following example to remove special characters from an attribute but somehow I can't get it to work. I'm using this script in a business rule before ... "Information") } } Can someone identify what i'm doing wrong? Incorrect if statement?

asked Mar 4, 2019 by Quinten (100 points)
3,588 questions
3,277 answers
8,303 comments
548,091 users