- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2025 03:54 AM
Greetings,
Element used:
Workspace: BCM Workspace
Table: Event
Code written in : UI Action (ClosedComplete), Workspace Client Script field.
We have a requirement where upon clicking on a button the 'closed on' field should get populated with current date and time in BCM workspace.
But when we used 'var dateNow = new Date();' we received a different type of date format which cannot be used in the field i.e.., 'Fri Mar 21 2025 16:15:58 GMT+0530 (India Standard Time)'
Below is the code that we have written so far.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2025 04:45 AM
why are you using JSON.parse() when you are not returning JSON from script include
that line is breaking the script
try this
function onClick(g_form) {
var title = getMessage('Accept policy');
var message = getMessage("Are you sure you want to accept this policy?");
g_modal.confirm(title, message, function(confirmed) {
if (confirmed) {
var ga = new GlideAjax('sn_recovery.Crisis_Event_Client_Utils');
ga.addParam('sysparm_name', 'getDatetime');
ga.getXMLAnswer(function(answer) {
alert('5 hi');
alert('7 - result: ' + answer);
g_form.setValue('closed_on', answer);
g_form.setValue('state', '30');
g_form.save();
});
}
});
return false;
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2025 05:11 AM - edited 03-21-2025 05:17 AM
I am getting this in the alert
and i want dd:mm:yyyy hh:mm:ss format
also the 'Closed_on' date is staying empty even after update
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2025 05:27 AM
the date format is correct. what's your date/format for your profile or in preferences?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2025 05:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2025 05:47 AM
why?
your date time format is DD-MM-YYYY then why to get it in other format?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2025 05:49 AM
try this
getDatetime: function() {
var gdt = new GlideDateTime();
gs.addInfoMessage('Hi');
return gdt.getDisplayValue();
},
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader