Current date in Mashup

I found this post about getting the current date in XAML. I gave it a try in a Mashup.

Here’s the code to get the current date and time in various formats in a Mashup. You can complement this with the Date picker in Mashup.

<Gridxmlns:sys=”clr-namespace:System;assembly=mscorlib”>

<TextBlock Text="{Binding Source={x:Static sys:DateTime.Today}, StringFormat='Today is: {0:dddd, MMMM dd, yyyy, hh:mm:ss}'}" />
<TextBlock Text="{Binding Source={x:Static sys:DateTime.Today}, StringFormat='One of LSO formats: {0:MMddyy}'}" />
<TextBlock Text="{Binding Source={x:Static sys:DateTime.Today}, StringFormat='M3 API format: {0:yyyyddMM}'}" />
<TextBlock Text="{Binding Source={x:Static sys:DateTime.Today}, StringFormat='\{0:yyyy/MM/dd}'}" />
<TextBlock Text="{Binding Source={x:Static sys:DateTime.Today}, StringFormat='\{0:yyyyddMM}'}" />

And here is a screenshot of the result with the current date displayed in five different formats:

UPDATE 2012-03-26: To get the date in a TextBox add the binding property Mode=OneWay, for example:

<TextBox Text="{Binding Source={x:Static sys:DateTime.Today}, StringFormat='yyyy', Mode=OneWay}" />

Published by

thibaudatwork

M3 Technical Consultant

16 thoughts on “Current date in Mashup”

  1. This was a great help! Thanks to you, I figured out how to use a datepicker to select a value in one date format, then send this value to a MI transaction in the M3 API format 😀

    Like

      1. I have done a bunch of researching how to call a JScript from a Mashup and it feels like it will not work. I did in fact create a JScript with a date funtion however I can’t seem to use it from the resource in the Mashup; even though it is in the manifest file. I’ve seen Karin’s post where the subject was brought up and the response was that it doesn’t work. When you say “script” would that mean a C# script? I have existing JScript running in the Mashup but it doesn’t seem to work the other way around.

        Like

    1. Hi Christian, it is possible to initialize a datepicker to the first date of the month.
      You must use a converter with formated date :
      In grid resources :

      and in your control like datepicker :

      Like

  2. Hello,
    In my mashup, I am using this binding for a textbox :
    {Binding Source={x:Static sys:DateTime.Now}, StringFormat={}{0:MM/dd/yyyy HH:mm:ss}, Mode=OneWay}
    which works perfectly fine (thanks to this post :))
    But now I am trying to regenerate this field’s value when I click on a button (to get the new current time).
    I tried adding an event on the button click using the ‘SetProperty’ on my Textbox’s ‘Text’ value but it seems the time isn’t re-calculated… (I’m guessing it has something to do with the ‘Static’ part)
    Is there any way to force this?
    Thanks,
    Best regards

    Like

    1. Bonjour Thomas. Did you try the conditions, converters, and property setters? There are examples in the Mashup Designer > Help > Common Controls. Probably the property setter would work. I think this is more of a WPF/XAML question than a Smart Office Mashup question, and I have not done this before so I do not have an answer right now. Maybe remove Mode=OneWay. Did you search on the Internet? Maybe ask Karin or ask on the PotatoIT forum. /Thibaud

      Like

  3. are people still out there?
    I was wondering if it was possible to do something like this, but instead find the current period, or at least year & month, to populate a text box in the column header in FCS001 for a mashup

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s