Unable to get sys_created_on date from UI Policy Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10 hours ago - last edited 8 hours ago
We have a record producer that contains a variable "year_end" which has a UI Policy on Target Records only that controls the visibility based on if the request was created in Q4. The purpose of the field is for our users to access historical requests and work them to completion, which is why this policy is on Target Records, not the Catalog Item.
Rather than using UI Policy Actions, we're trying to accomplish this via script because we have specific conditions and you can't write a condition based on a table level field; only a variable. Here is my script:
var created = g_form.getValue('sys_created_on'); // get the date the request was created
alert('created is ' + created);
var date = new Date(created); // convert the value to a date
alert('date is ' + date);
var month = date.getMonth()+1; // extract the month from the date
alert('month is ' + month);
if (month = 10 || month = 11 || month = 12){
g_form.setMandatory('year_end',true);
g_form.setVisible('year_end',true);
}When testing the UI Policy Script, my created variable is showing blank for my request that was already created last year. See below:
Any idea how I can get the value of sys_created_on?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
9 hours ago - last edited 9 hours ago
Hi @neil_b
I think sys_created_on field return empty because it gets populated only after the record is inserted which happens on the server side.
You can use the current date new Date () on the client side to determine whether the request is being created in mentioned month 10,11 or 12
Thanks and Regards,
Mohammed Zakir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
9 hours ago - last edited 9 hours ago
Hi @Mohammed8 but in this case, the request was already created. It was created in November of last year so it should already have that date as a value.
The purpose of the field is for our users to access historical requests and work them to completion.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
9 hours ago
Hi @neil_b
Can you share a screenshot of your Record Producer form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
9 hours ago
Hi @Mohammed8 see below form screenshot.
