# Adding Sunrise/Sunset Dates Programmatically to Specific Entitlements

**URL:** <https://developer.sailpoint.com/discuss/t/adding-sunrise-sunset-dates-programmatically-to-specific-entitlements/72446>\
**Category:** IIQ Discussion and Questions\
**Tags:** workflows, access-requests, entitlements, identityiq, provisioning\
**Created:** [July 12, 2024, 2:46pm UTC](https://developer.sailpoint.com/discuss/t/adding-sunrise-sunset-dates-programmatically-to-specific-entitlements/72446 "2024-07-12T14:46:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lesliepierrot](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/lesliepierrot/32/34940_2.png) [@lesliepierrot](https://developer.sailpoint.com/discuss/u/lesliepierrot)\
**Post date:** [July 12, 2024, 2:46pm UTC](https://developer.sailpoint.com/discuss/t/adding-sunrise-sunset-dates-programmatically-to-specific-entitlements/72446/1 "2024-07-12T14:46:31Z")

</div>

### Which IIQ version are you inquiring about?

Version 8.3

### Please share any images or screenshots, if relevant.

 ![undefined](https://global.discourse-cdn.com/sailpoint/original/2X/8/8d53c43dd94dce75b0a6a13555d0803a48827e53.png)

### Share all details related to your problem, including any error messages you may have received.

Hello, fellow sailors!

I’m currently trying to add Sunrise/Sunset dates to specific entitlements automatically when they are selected in Manage User Access.  
(I’ve already tried adding this during the BeforeProvisioning rule. Although Sunrise/Sunset dates appeared in the Access Request, the sunset Request object didn’t generate.)

Does anyone know what workflow or rule is triggered by the time you get to the “Review and Submit” screen? I need to apply the dates similar to the calendar widget, but without someone physically clicking the calendar.

---

<div class="post-metadata">

**Author:** ![lesliepierrot](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/lesliepierrot/32/34940_2.png) [@lesliepierrot](https://developer.sailpoint.com/discuss/u/lesliepierrot)\
**Post date:** [July 12, 2024, 7:41pm UTC](https://developer.sailpoint.com/discuss/t/adding-sunrise-sunset-dates-programmatically-to-specific-entitlements/72446/2 "2024-07-12T19:41:15Z")

</div>

I figured it out!

- Added a “Apply Sunrise/Sunset Dates” step to the our main LCM Provisioning workflow before the “Initialize” step.
- Made sure that I returned the `plan` generated from that “Apply Sunrise/Sunset Dates” step.
- Removed the adding of the Sunrise date, as same day adds don’t work through the UI since everything has to be set at midnight, and midnight has already passed today. So, programmatically, had to utilize the same pattern.

Below is a small snippet of the main code that actually applies the Sunset date. You’ll need to access the `plan` attribute to be able to eventually to get to this point.

```auto
// Setting Sunset only since IdentityIQ does not recognize same day activations since the start time is midnight of that day, and midnight has already passed today.
Calendar calendar = Calendar.getInstance();

/* SUNSET:
Expiration date needs to be 30 days in the future at midnight.
*/
calendar.add(Calendar.DATE, 30);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date sunset = calendar.getTime();
attributeRequest.setRemoveDate(sunset);

```

---

<div class="post-metadata">

**Author:** ![tanaychouhan1](https://avatars.discourse-cdn.com/v4/letter/t/cab0a1/32.png) [@tanaychouhan1](https://developer.sailpoint.com/discuss/u/tanaychouhan1)\
**Post date:** [August 23, 2024, 5:34pm UTC](https://developer.sailpoint.com/discuss/t/adding-sunrise-sunset-dates-programmatically-to-specific-entitlements/72446/3 "2024-08-23T17:34:34Z")

</div>

Does that mean that even if you try to set sunrise day at 8AM & sunset at 6PM on the same day it won’t work ?

The sunset & sunrise time has to be midnight?

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/sailpoint/original/2X/f/f2136700ed5e3703e0b85e02f6be799dacca7735.png) [@system](https://developer.sailpoint.com/discuss/u/system)\
**Post date:** [October 22, 2024, 5:34pm UTC](https://developer.sailpoint.com/discuss/t/adding-sunrise-sunset-dates-programmatically-to-specific-entitlements/72446/4 "2024-10-22T17:34:40Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
