Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Issue setting date in global field on server

Featured Replies

Hi there,

 

I'm having a issue setting a global date field when performing script on server.

 

Here's some background:

 

I have a script that is passing a date field from a local instance of FMP to a script that is running on the server (need to run it on server for performance reasons)

 

The issue seems to come from the fact that the local system is set to dd/mm/yyy while the shared server we use is set to mm/dd/yyy - unfortunately we don't have access to the server admin.

 

To work around the issue I'm trying to convert the Local global date to a number (this is working fine)

Then passing the number as a script parameter to the server (this is also confirmed working)

the issue arises when I try and Set the global field as a date.

 

eg. Here are the script steps:


Set Variable [$StartDateParam ; Value:GetValue ( Get (Scriptparameter) ; 1 )
Set Field [Globals::zz__StartDate__gxd; GetAsDate ( $StartDateParam)]
Set Field [ProductSalesReport::Test ; Globals::zz__StartDate__gxd]

But I always get a ?

 

I have tried an number of different steps but it never works.

 

When I try the following:

Set Variable [$StartDateParam ; Value:GetValue ( Get (Scriptparameter) ; 1 )
Set Field [ProductSalesReport::Test ( $StartDateParam)]

I get the FMP date format eg 735630

 

I also tried:

Set Variable [$StartDateParam ; Value:GetValue ( Get (Scriptparameter) ; 1 )
Set Field [ProductSalesReport::Test; GetAsDate ( $StartDateParam)]

Which also resulted in ?

 

I've spent half a day on this so far, obviously missing something simple. Any Suggestions?

So, you're passing in 735630? and you're getting 735630 on the server. 

 

What if you do an intermediate step :

Set Variable [date;Value: GetAsDate($startDateParam)

Do you get a ? result?

  • Author

Yes tried that also - admitedly the only way I can test it is to then save it to a field and check on the local machine but in that instance I also received ?

 

I have changed the database structure so that I'm no t relying on global fields for the date value and that has solved my issue.

 

The only way I got it to work was the reformat the date on the server using:

Date ( Middle ( $StartDateParam ; 4 ; 2 ) ; Middle ( $StartDateParam ; 1 ; 2 ) ; Right ( $StartDateParam ; 4 ) )

The issue with using this though is that IF something changes on the server ie. move the file to different server with a different date format the script would break. Hence the changes in database structure to avoid having to pass the globals through the script.

That makes sense...global fields are local the the instance they are put in to.

 

Could you just use Get(CurrentTimeUTCMilliseconds). You can convert it to a date or timestamp and then shift the time for your timezone. It might be more stable.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.