Modify VA format for AD

Hi, 

We are trying to create a VA with a mobile number so that a workflow is triggered and sets the number in AD.

The issue we face is the formatting of the number, see below:

Original VA: 07702874158


Transformed Value to set in AD: +44 7702 874158

Note: This is a made up number!

Does anyone have any ideas on how we can achieve this using the settings in the workflow options?

Thanks in advance.

Top Replies

  • Hi  

    I'm assuming you already know how to create a VA?

    The issue you've got is how you convert the telephone number from what is entered, into the format you actually want in the native mobile…

  • Hi  

    I'm assuming you already know how to create a VA?

    The issue you've got is how you convert the telephone number from what is entered, into the format you actually want in the native mobile attribute.

    There is no direct OOTB conversation available, however you could do this in a number of ways. For my example I'm going to make a number of assumptions:

    • All telephone numbers are for UK based mobiles (therefore am not covering other countries telephone formats, nor land line formats other than where there is a cross over) 
    • All telephone numbers provided are into the VA are exactly 11 numeric characters long
    • There are no special characters enter in the VA (IE no +)
    • The number entered if not already an in UK international format (IE 441111444444 or +441111444444), and therefore 12 or 3 characters long.

    Therefore I would

    1.  Create an Administration Policy, which controls the value of your edsvaCustomerMobile VA, which restricts the VA to only numbers and must be 11 characters long

    2. Create a script module to convert your source value to the destination value, I created the below for this example, but you'd need to test it for your exact use case, and add any error handling etc  etc. 

    Function Covert-Mobile($Request)
    {
        $CountryCode = "+44"
        $Attribute = "edsvaCustomerMobile"
        $Length = 11
        $Return $null
        $AreaCode = $null
        $Number = $null
        
        $Value = $Request.Get($attribute)
        
        If($Value)
        {
            If($Value.length -eq $Length)
            {
                $AreaCode = $Value.Substring(1,4)
                $Number = $Value.Substring(5,6)
                
                $Return = [string]::Format("{0} {1} {2}",$CountryCode,$AreaCode,$Number)
                $EventLog.ReportEvent($Constants.EDS_EVENTLOG_WARNING_Type,"$Attribute is $Length, return `"$Return `"")
            }
            Else
            {
                $EventLog.ReportEvent($Constants.EDS_EVENTLOG_WARNING_Type,"$Attribute is not $Length, return `"$Return `"")
            }
            
        }
        Else
        {
            $EventLog.ReportEvent($Constants.EDS_EVENTLOG_WARNING_Type,"$Attribute is blank, return `"$Return `"")
        }
        
        Return $Return
    }
    
    
    
    
    
    }

    2. Create workflow(s) for create/update of the edsvaCustomerMobile VA, where you modify the request

    Then update the Mobile attribute with a value generated by the script above

    Which you'd select by choosing "Value generated by rule expression"

    Then from the "Add entry" drop down, select "Value generated by script"

    Then select your script, and the function in the script it uses:

  • Hi  

    Thanks for the reply. I followed your logic and adjusted the number format using your post as a guide. 

    I can get the script to work in PowerShell if I hard code the $mobile number however when i change this to a $workflow.savedobject properties i get the error below:

    "At line: 4 char:5. Exception calling "SavedObjectProperties" with "1" argument(s): "The given key was not present in the dictionary." "

    Here is a copy of the script i am executing:

    function Convert-MobileNumberFormat($Request)
    {
    $CountryCode = "+44"
    $mobile = $workflow.SavedObjectProperties("UserDetails").get("VA-UserMobile")
    $Length = 11
    $Return = $null
    $AreaCode = $null
    $Number = $null

    $Value = $Request.Get($mobile)

    if($Value)
    {
    if($Value.length -eq $Length)
    {
    $StartPrefix = "(0)"
    $AreaCode = $Value.Substring(1,4)
    $NumberSet1 = $Value.Substring(5,3)
    $NumberSet2 = $Value.Substring(8,3)

    $Return = [string]::Format("{0} {1} {2} {3} {4}",$CountryCode,$StartPrefix,$AreaCode,$NumberSet1,$NumberSet2)
    }

    }

    return $Return
    }

    I searched the forums and I see   resolved it for another user with a similar problem, hopefully you can help me with mine. 

    Error calling saved object properties to script from workflow - Forum - Active Roles Community - One Identity Community

  •   - any ideas on how I can resolve this? 

  • I don't think you really need to use "Saved Object Properties".

    You should be able to just grab the contents of the mobile number as it was saved directly from the $Request - assuming that your workflow is being triggered by a modification to your VA.

    $mobile = $Request.Get("VA-UserMobile")

  • Hi  

    I have updated my script as per your post however i now get "At line: 12 char:1. You cannot call a method on a null-valued expression."

    FYI here is my script below and the aim is to trigger this script when a VA is modified and update the mobile field in AD with the converted format. 

    function Convert-MobileNumberFormat($Request)
    {
    $CountryCode = "+44"
    #$Length = 11
    $mobile = $Request.Get("VA-UserMobile")
    
    if ($mobile -ne $null) 
    {
    $StartPrefix = "(0)"
    $AreaCode = $Value.Substring(1,4)
    $NumberSet1 = $Value.Substring(5,3)
    $NumberSet2 = $Value.Substring(8,3)
    
    $Return = [string]::Format("{0} {1} {2} {3} {4}",$CountryCode,$StartPrefix,$AreaCode,$NumberSet1,$NumberSet2)
    }
    
    return $Return
    
    }

    Any suggestions on how i fix this error? 

    thanks

    Ashley

  • Hi  

    The error you mention relates to your code attempting to so something either an variable, when its blank.

    I suspect the issue is down to the use of $value, as you appear to be attempting to get some sub string values from it, however it doesn't look like you've get the $value to some value.

    It is always a good idea to test the length of a string before attempting to do a substring, so you don't either try and perform an operation against a null string, or you don't attempt to get substring beyond the end of the string. (IE you want 3 characters from position 8. but the string is only 5 characters long).

    Hope that helps