0 votes

Hello

Our user can set a CustomAttributeDate attribute (user object) on the WebUI, and also change the date.

The time must always be set to 23:50.

I need a script example that can show me how to set the hour and minute part on a customattributedate attribute.
Also if the attribute is already populated with a value.

- Thanks in advance

by (2.6k points)

1 Answer

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

Hello,

In your script, you can get the value provided by the user using the $Context.GetModifiedPropertyValue method. Also, you can modify the user input using the $Context.SetModifiedPropertyValue method. Here's a short sample script that does what you want:

$attributeName = "adm-CustomAttributeDate1" # TODO: modify me

$dateInput = $Context.GetModifiedPropertyValue("$attributeName")
$date = New-Object "System.DateTime" ($dateInput.Year, $dateInput.Month, $dateInput.Day, 23, 50, 00)

$Context.SetModifiedPropertyValue($attributeName, $date)

Note that a Business Rule that runs the script must be triggered before creating or updating a user.

No related questions found

2,740 questions
2,474 answers
6,475 comments
1,373,632 users