Html type 'date' conversion to Servicenow type 'date'

AmritaT
Tera Expert

Is there a way to convert the html type 'date' to Servicenow type 'date' ?

Screenshots for reference - 

HTML type -> date : 

find_real_file.png

Servicenow type --> date :

find_real_file.png

 

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!

 

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

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);

	}
}

 

View solution in original post

8 REPLIES 8

Chuck Tomasi
Tera Patron

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);

	}
}

 

I found something similar here -

https://community.servicenow.com/community?id=community_question&sys_id=d5c68a84dbf01b8047c8f3231f96...

 

I'm getting this error every time I run the script :

find_real_file.png

Double check the values in field and ng-model. They need to match. For your use case, it needs to be data.date.

This is what I have and I still get this error message :

find_real_file.png

 

Error message :

find_real_file.png

Not sure what am I doing wrong here?