Is it possible to get "sys_created_on" value from within client script?

Nisar2
Mega Guru

Hi,

I've a requirement where in I need to compare a date with the record's created date and make sure it is not before/earlier than that.

For this, I'm using the "onChange" trigger set on the date field and I was wondering if it would be possible to get hold of the created date within the script?

One approach that I can think of is using GlideAjax to call a server script include and query the database by passing the "g_form.getUniqueValue()" value to the function. Then as a response, I can return the value back to the client. However, I was hoping if I can avoid going through all that for a single value.

 

Another approach is to use a "display" business rule to make use of "g_scratchpad" and send that value to the client. But again, this will involve the use of an additional business rule. 

Any other alternatives/suggestions?

 

PS: The "Created" date is not present on the form and I do not have permissions to change the form layout.

1 ACCEPTED SOLUTION

Ashutosh Munot1
Kilo Patron
Kilo Patron

HI,

If you want to use client script then its mandatory that it should be on form. But now in this case its not on form.


So we are left with either BR or GlideAjax.

So pleaase use them and its a recommended best practice.

Thanks,
Ashutosh Munot

View solution in original post

5 REPLIES 5

reginabautista
Kilo Sage
Hi ddi you try g_form.getValue('sys_created_on')?

The created field is not available on the form and I do not have the permissions to add it. So I don't think getValue() will work.

rad2
Mega Sage

if you want the sys_created_on of the same record, then you can get the value directly in client script using getValue().

Do make sure the variable is available in the form with the help of form-layout.

 

To compare the dates, this thread might be helpful - https://community.servicenow.com/community?id=community_question&sys_id=624f3e69db58dbc01dcaf3231f96...

The created field is not available on the form and I do not have the permissions to add it. So I don't think getValue() will work.