0 votes

Hello,

I could use some help with a script. The script will need to do a couple of things.

1. Remove all special characters and spaces from %mobile% string, leaving a 10 digit phone number like 1234567890, and then add a 1 to the front for the US country code. I already have a regexp used as part of a property pattern that allows only the 10 digit phone number but allows for separators like parentheses, dashes, etc. The updated phone number with country code should be saved into %mobile%.

2. If custom text attrib #3 says no, the value provided in %mobile% should be moved to %otherMobile%, and then %mobile% should be cleared.

3. If custom text attrib #3 says yes, copy the %mobile% value into %othermobile%, but the %mobile% number stays where it is.

P.S. I know I could use a boolean attribute for the publish number field, but I've used up all the available boolean attributes and had lots of text attributes available, so I just used a property pattern to give a yes or no value option.


Thank You!
Ryan

by (920 points)
0

On second thought...I don't think I can use %otherMobile% for SMS sending since it's a multi-value attribute. So instead of %otherMobile% can I use a custom text field or maybe integer?

0

Hello Ryan,

On second thought...I don't think I can use %otherMobile% for SMS sending since it's a multi-value attribute. So instead of %otherMobile% can I use a custom text field or maybe integer?

When you configure SMS settings for Adaxes service, you can also specify which property of user accounts will be used for storing their mobile numbers. The property that you specify will be used everywhere in Adaxes where sending of SMS messages is involved: sending of SMS messages with the help of the Send SMS operation, sending SMS messages from Business Rules and scripts, as well as sending SMS verification codes from Password Self-Service. For this purpose, you can use any property that allows soring string (text) values, including Adaxes virtual properties, such as CustomAttributeText1, for example. For information on how to select a property to be used for storing mobile numbers, see the 5th step in the following help article: http://www.adaxes.com/help/?HowDoI.Mana ... tings.html.

I could use some help with a script. The script will need to do a couple of things.

OK, we've asked our script guys to write a script for you.

1 Answer

0 votes
by (216k points)
selected by
Best answer

Ryan,

Here's a script that meets your requirements. In the script, the mobile phone stored in the Mobile Phone property is copied to the CustomAttributeText8 property. If the CustomAttributeText3 property is not set to Yes, the Mobile Phone property is cleared.

Modify the following to meet your requirements:

  • $countryCode - specifies the country code,
  • $specialCharacters - specifies the special characters that need to be removed from the mobile phone.
$countryCode = 1 # TODO: modify me
$specialCharacters = @(" ", "-", "(", ")") # TODO: modify me

# Get mobile phone
try
{
    $mobilePhone = $Context.TargetObject.Get("mobile")
}
catch
{
    $Context.LogMessage("Mobile phone is not specified", "Warning") # TODO: modify me
    return
}

# Remove special characters
foreach ($character in $specialCharacters)
{
    $mobilePhone = $mobilePhone.Replace($character, "")
}

# Add country code to the mobile number
$mobilePhone = "$countryCode$mobilePhone"

# Update CustomAttributeText8
$Context.TargetObject.Put("adm-CustomAttributeText8", $mobilePhone)

# Get CustomAttributeText3
try
{
    $value = $Context.TargetObject.Get("adm-CustomAttributeText3")
}
catch
{
    $value = $NULL
}

if ($value -ine "Yes")
{
    # Clear Mobile Phone property
    $Context.TargetObject.Put("mobile", $NULL)
}

# Save changes
$Context.TargetObject.SetInfo()
0

That's awesome! Thanks so much for the quick reply!

Related questions

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

We would like to auto enroll our entire company into Adaxes for self service but do not want to use the question/answer format but instead their phone numbers (provided by HR department). Is this possible? Best, Evangelos

asked Oct 1, 2021 by evangelos (60 points)
0 votes
1 answer

Hello, i have a custom command which sets the oof-message for the selected user. in this custom command i have a parameter "param-vertretung" (ad-object picker). Now i want to ... and email of the stand-in in the oof-message. Can you help me with that? Thanks

asked Nov 13, 2020 by lohnag (160 points)
0 votes
1 answer

I have an issue with how phone numbers are rendered in the Web Interface. My Forms and Views configuration looks like this and when this is rendered in the web interface ... noting that in the other forms Create / modify, the property is handled as expected)

asked Apr 5, 2016 by sam.webster (370 points)
0 votes
1 answer

Let's say I have a Business Rule that is fired prior to adding members to a group. Is it possible to get the number of objects being added to that group as ... that tells me that 6 objects will be added or is each added user treated completely independently?

asked Apr 20, 2022 by ngb (220 points)
3,346 questions
3,047 answers
7,781 comments
544,981 users