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 (216k 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.

Related questions

0 votes
1 answer

Hi, we save the start date of employees within adm-CustomAttributeDate1 and I would like to fetch them based on this field. My criteria looks like this, however I get ... units, but none of them allow me to use the adm-CustomAttributeDate1 as search filter.

asked Aug 5 by wintec01 (2.2k points)
3,742 questions
3,420 answers
8,641 comments
550,395 users