- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2019 01:05 PM
Is there a way to convert the html type 'date' to Servicenow type 'date' ?
Screenshots for reference -
HTML type -> date :
Servicenow type --> date :
I'm not able to copy the 'date' from the registration form to the table. Registration form is on the portal.
Any suggestions? Thanks in advance!
Solved! Go to Solution.
- Labels:
-
Service Portal Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2019 06:46 AM
I got what you need. You need some form of handler to display the date when it changes. By default, it displayed (for me) before the date was changed. Client script code that is not in a function gets run on load time. Here is my HTML and Client script as an example. I suspect your main issue was that the field and ng-model attributes didn't match.
<div class="col-sm-6">
<div class="form-group">
<label for="date">Inspection Date</label><span id="p3" class="req"></span>
<sp-date-picker field="data.date" ng-model="data.date" Placeholder="Inspection date" sn-change="dateChanged()"></sp-date-picker>
</div>
</div>
Client script
function($scope) {
/* widget controller */
var c = this;
$scope.dateChanged = function() {
console.log('date=' + c.data.date);
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2019 01:54 PM
Hi,
Can you try:
var date = new GlideDate('u_htmlfieldname');
alert("Date field shows " + date);
This would be for a client script as I'm assuming that's where you're working with this?
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
I invite you to visit my ServiceNow focused YouTube channel: Allenovation!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2019 02:39 PM
Hi Allen,
This is my HTML -
<div class="col-sm-6">
<div class="form-group">
<label for="date">Inspection Date</label><span id="p3" class="req"></span>
<sp-date-picker id="date" name="date" field="date" ng-model="c.data.date" Placeholder="Inspection date"></sp-date-picker>
</div>
</div>
Trying to figure out the client part - ???
var idate = document.getElementById('date');
c.data.date = idate;
Server Script -
if (input) {
// Initialize GlideRecord
if (input.action == 'Submit') {
// Create template record
var gr = new GlideRecord('mytable');
gr.initialize();
gr.u_date = input.idate;
gr.insert();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2019 03:17 PM
If your ng-model is already bound to c.data.date, then your client script already has access to it as c.data.date. There's really nothing to figure out here. You'll get a value like '2019-06-13' in c.data.date. Put in a console.log('date=' + c.data.date); in your client script and observe what happens in the browser's console log.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2019 06:21 AM