Tagged: 

This topic contains 5 replies, has 2 voices, and was last updated by  admin 6 years, 11 months ago.

  • Author
    Posts
  • #73938

    kiwioz
    Participant

    Hi,

    Is there a way of using the MBS plugin to go to a date and view.

    I would like to call it from a script, this would stop the webview from having to refresh or be reloaded.

    If so could you please show an example of the code I would need.

     

    Craig

     

  • #73939

    admin
    Keymaster

    You don’t need MBS to get the date & view – that’s available in the URL of the web viewer.

    Use the following FileMaker function.

    getlayoutobject($$calendar_object;”source”)

    More info here:

    http://www.sosimplesoftware.com/forums/topic/hash-vs-date-shown-on-calendar/

     

  • #73940

    kiwioz
    Participant

    Morning Ken

    My solution I am building has the option to add a follow-up appointment for the client.

    So when you open the event I have a button bar with 1, 2, 3, 4 representing how many weeks in the future the follow-up appointment is needed.

    when the user clicks let’s say 2 it creates a new event and I would like to take the user to that day, so the user can set the correct time.

    In your option what is the best way of doing this? Is there a way without the webview flashing when reloading the change of date?

     

    Craig

  • #73941

    admin
    Keymaster

    The easiest way to navigate to the new date is to change the URL to reflect the new date (see http://www.sosimplesoftware.com/products/calendar-documentation/calendar-builder-reference/adjusting-your-calendar/url-anchors-for-date-and-view-links/). There’s no need for MBS or JavaScript.

    To navigate the calendar using MBS, you can send this JavaScript to your webviewer:

    scheduler.setCurrentView(new Date(2017,7,4));
    

    See MBS documentation on how to do this:

    http://www.mbsplugins.eu/WebViewRunJavaScript.shtml

  • #73942

    kiwioz
    Participant

    Hi Ken,

    Thanks for the sample code.

    We I use this I am going 1 full month ahead, I can not work out why.

    I set up a workaround by ~_month -1 

    I have set up a test with the following:

    Date19/12/2017

    Custom function to pass the date into the correct format =

    dateForScheduler (theDate)

    Let([

    ~_month =Month (theDate);

    ~_day = Day(theDate );

    ~_year = Year(theDate )

    ];

    ~_year  & “,”  & ~_month  & “,”  &  ~_day

    )

    then set a veriable  = MBS(“WebView.RunJavaScript”; “web_calendar”; “scheduler.setCurrentView(new Date(” & dateForScheduler (  Date )  & “));”)

     

    Any advice would be very helpful

    Craig

    • This reply was modified 6 years, 11 months ago by  kiwioz.
  • #73945

    admin
    Keymaster

    Your “workaround” is fine. JavaScript date function uses zero-based months, so new Date (2017, 0 , 5) is Jan 5.

     

You must be logged in to reply to this topic.