I am passing mashup parameter with base type of "DateTime". Now i want to remove milliseconds from Time. Now how to format the DateTime of mashup parameter?? If i used any custom services, the output is coming wrong all the times. So i need to change the formatting property of DateTime mashup parameter.
You can use an expression widget to remove milliseconds if it has to be client side.
However if you do it in a service on the server, what is coming out 'wrong'?
So I can better understand your use case are you trying to display the mashup parameter in a mashup ( with formatting ) and also use the same mashup parameter in a service on the same mashup?
Yes you are correct. When iam receiving value from mashup parameter(datetime), i want the datetime to be formatted without milliseconds.
Hi @AP_9587236 ,
You will need an expression Function as Pai mentioned that takes in the date time parameter and formats it. Here is a simple example of the expression code that can be bound to a display widget ( label
Output = "Expression time - " + dateIn.toLocaleString('en-US');
I am not sure what you mean by comes out wrong in the service but you should pass in the mashup parameter to your target service so the original provided date is unmodified.
I have attached two screen shots, one showing my mashup bindings where I call the expression and a service to add minutes. The second screen shot is my runtime where you can see the original start time ( now minus 10 minutes ). Then a service that runs adding user defined minutes. Here you can see only time minutes change and the milliseconds are not lost.
Iam taking the mashup parameter in the child mashup of collection widget. I tried this service to format the date and passing the output to the label of child mashup. When the collection widget loading, thousands of child mashup is loading at a time. That moment the Formatted date output getting interchanged with some child mashups to another set of child mashups of collection widget. This is my problem.
As strange as this sounds it is best to try and not have any services run on mashup load within a collection, and yes it is not always avoidable. If all of these cells are getting the same timestamp formatted have you tried using the mashupGlobalPropertyBinding and then setting the formatted date here. This will prevent the browser from having to do so much work.
If all of the cells are getting different time stamps, I recommend adding an additional infotable column that has the formatted date here. Formatting the date in the service that populates the collection is more efficient than client side in this case. This will also ensure each cell has the original unmodified date time as well.
I am not sure what other services are doing what in your collection cells, but if they are just getting cell specific data to display it may also be better to use a nested infotable ( or addiitonal columns ) and return all data from one service. Depending on the service(s) and amount of cells, you indicate thousands, this is a lot of calls to the ThingWorx server and could produce significant load times.