0 votes

Hi

I need to update some property patterns on a scheduled basis and am doing this via a powershell script. The particular attibute will be a drop down, but for ease of use I would like to set a default value if the list only has one option.

I've got the following which configures the attribute correctly, but is there a way to set the default value?

$item = $userPattern.Items.Create()
$item.PropertyName = "primaryTelexNumber"
$item.IsPropertyRequired = $True

$constraints = $item.GetConstraints()
$constraint = $constraints.Create("ADM_PROPERTYCONSTRAINTTYPE_VALUERANGE")
$constraint.AreValuesDenied = $False
$constraint.Values = @($dlList)
$constraints.Add($constraint)
if ($dlList.Count -eq 1) {$constraints.DefaultValue = $dlList[0]} #This doesn't work!
$item.SetConstraints($constraints)
$item.SetInfo()
$userPattern.Items.Add($item)

Thanks

Matt

by (4.5k points)

1 Answer

0 votes
by (189k points)

Hello,

Yes, it is possible. You need to use the IAdmPropertyPatternItem::DefaultValue property. The value set as default must also be present in the list of allowed values for the property.

0

Thanks, I've seen that page already which is what made me think that having

if ($dlList.Count -eq 1) {$constraints.DefaultValue = $dlList[0]}

would work but it comes up with an error. Is that command right? Do I need to use the SetInfo() for the values first then do the DefaultValue after?

Matt

0

Hello,

You are using the property for an object that supports an interface that does not have the DefaultValue property. To achieve the desired, the code line should be as follows:

if ($dlList.Count -eq 1) {$item.DefaultValue = $dlList[0]}

There is no need to do any other changes.

0

Perfect, thank you as always for the quick responses.

Related questions

0 votes
1 answer

We are trying to enforce better consistency for user attribute values in a domain but without overly restricting user input when modifying/creating users. Is it possible to ... to these fields and create Custom Commands to change them which is very tedious.

asked Mar 21, 2019 by Staj (1.4k points)
0 votes
1 answer

We have a form to used by our HR Reps to create non-employee records. There are two fields on the form that are auto-generated via a property pattern: Full Name ( ... changed to cause this new behavior? Nothing has changed with our property pattern set-up...

asked Aug 30, 2016 by sandramnc (3.4k points)
0 votes
1 answer

Is it possible to update a Propery Pattern using a powershell script? If a new department OU is created, is it possible to automaticly update the User Pattern's Department property to reflect that a new department has been added?

asked Jan 28, 2013 by kjesoo (7k points)
0 votes
1 answer

Hi, Is it possible to modify a property pattern drop down list from the web interface? Thanks.

asked Feb 8, 2018 by bistromath (4.3k points)
0 votes
1 answer

Is there an option to load the possibles values of the Property Pattern, from SQL or other external sources?

asked Aug 5, 2013 by sdavidson (5.1k points)
2,352 questions
2,107 answers
5,746 comments
131,042 users