Input Dialog Date/Time & Global Variable Date/Time
Moderator: Martin
Input Dialog Date/Time & Global Variable Date/Time
I have been trying to figure out for the last few days how to use the Input Dialog Date/Time to work with the Global Date/Time Variable trigger. No success so far. What I want to accomplish is simply to schedule the Date & Time for an event (eg. Send scheduled sms or email) .
The output from the dialog are numbers and would not be passed to the global variable. Take for example the date/time selected is 1st Jul 2014 12:00am, log({value}) would produce "1404144000000".
If I dateformat it like:
global_trigger_date = "getDate({value, dateformat, dd-MM-yyyy HH:mm})" and
log({global_trigger_date})
would correctly produce "01-07-2014 00:00" but the global variable doesn't receive it.
Strangely, it will trigger if I simply send a script like:
"global_trigger_date = getDate(2014, 7, 1, 0, 0, 0)"
but wouldn't work if the value was fornatted by {value, dateformat, yyyy, M, d, HH, mm, ss} .
Am I missing something? What do the numbers from the Input Dialog represent? Is there a specific format to be accepted by the global variable trigger?
The output from the dialog are numbers and would not be passed to the global variable. Take for example the date/time selected is 1st Jul 2014 12:00am, log({value}) would produce "1404144000000".
If I dateformat it like:
global_trigger_date = "getDate({value, dateformat, dd-MM-yyyy HH:mm})" and
log({global_trigger_date})
would correctly produce "01-07-2014 00:00" but the global variable doesn't receive it.
Strangely, it will trigger if I simply send a script like:
"global_trigger_date = getDate(2014, 7, 1, 0, 0, 0)"
but wouldn't work if the value was fornatted by {value, dateformat, yyyy, M, d, HH, mm, ss} .
Am I missing something? What do the numbers from the Input Dialog represent? Is there a specific format to be accepted by the global variable trigger?
Re: Input Dialog Date/Time & Global Variable Date/Time
Hi,
The action Input Dialog provides the selected value as a regular date (the number of milliseconds since 1970). This is also the type that the trigger Global Variable Date/Time expects in the global variable.
This means that you can simply assign value to global_trigger_date without worrying about formats at all. You generally only need to format dates when you either want to present the date to the user for example in an action Notification on Screen or when you get the date from an external source as a text and want to convert the text to a date (with function getDate("01.12.2013", "dd.MM.yyyy")).
Something like this should work:
Flow 1:
-trigger Global Variable Date/Time: global_trigger_date
-action Vibrate
-Flow 2:
-trigger none
-action Input Dialog: Date & Time
-action Script: global_trigger_date = value;
Enable Flow 1 then manually execute Flow 2 to select a date/time in the future.
Regards,
Martin
The action Input Dialog provides the selected value as a regular date (the number of milliseconds since 1970). This is also the type that the trigger Global Variable Date/Time expects in the global variable.
This means that you can simply assign value to global_trigger_date without worrying about formats at all. You generally only need to format dates when you either want to present the date to the user for example in an action Notification on Screen or when you get the date from an external source as a text and want to convert the text to a date (with function getDate("01.12.2013", "dd.MM.yyyy")).
Something like this should work:
Flow 1:
-trigger Global Variable Date/Time: global_trigger_date
-action Vibrate
-Flow 2:
-trigger none
-action Input Dialog: Date & Time
-action Script: global_trigger_date = value;
Enable Flow 1 then manually execute Flow 2 to select a date/time in the future.
Regards,
Martin
Re: Input Dialog Date/Time & Global Variable Date/Time
LOL So the variable "value" was the culprit after all. l had the impression that you need to put variables in curly braces in an expression. I'm sure I had done the same thing you've described before and didn't work. I created 2 fresh flows and it worked this time. Thanks.
Re: Input Dialog Date/Time & Global Variable Date/Time
Glad it's working now.
The curly braces are only required when a variable/inline expression should be replaced within a regular text, for example in an action Notification on Screen: it's {triggertime,dateformat,HH:mm}.
It's not required when you are in a text field of an action that requires a script since Automagic already knows that the whole content has to be interpreted as a script.
The curly braces are only required when a variable/inline expression should be replaced within a regular text, for example in an action Notification on Screen: it's {triggertime,dateformat,HH:mm}.
It's not required when you are in a text field of an action that requires a script since Automagic already knows that the whole content has to be interpreted as a script.
Re: Input Dialog Date/Time & Global Variable Date/Time
I'm not sure if you do but i get confused with how variables are treated in different scripting languages.One more issue requiring advice perhaps after you return from your holidays.Although I could bring up the contacts using the Start Activity action, I couldn't make use of the selection. I have no knowledge on Android intents and I wouldn't know what to fill in for Action, Category List, Data URI, Mime Types etc..Also do Mime Types vary Android versions?
Re: Input Dialog Date/Time & Global Variable Date/Time
The contact provider is not much fun to work with and it requires knowledge of intents and content providers.
There's an example Pick contact in the examples of action Start Activity. Wait for result has to be checked in the action so that Automagic receives the result and does not continue directly with the next action.
The contact selection activity will provide the selected contact in variable data_string which can be used in an action Query Content Provider to load more information.
A flow like this could work:
-action Start Activity: android.intent.action.PICK
-action Query Content Provider: SELECT * FROM {data_string} (simply enter {data_string} in the content URI field)
-condition Debug Dialog
The action Query Content Provider will provide a table with many fields of the contact in a table structure (list of lists) which might not be very comfortable to work with. You can also limit the selected columns by setting the projection field to a value like display_name and set the result type to Single value if you only want to get the information of one row.
What information of the contact do you want to access?
Regards,
Martin
There's an example Pick contact in the examples of action Start Activity. Wait for result has to be checked in the action so that Automagic receives the result and does not continue directly with the next action.
The contact selection activity will provide the selected contact in variable data_string which can be used in an action Query Content Provider to load more information.
A flow like this could work:
-action Start Activity: android.intent.action.PICK
-action Query Content Provider: SELECT * FROM {data_string} (simply enter {data_string} in the content URI field)
-condition Debug Dialog
The action Query Content Provider will provide a table with many fields of the contact in a table structure (list of lists) which might not be very comfortable to work with. You can also limit the selected columns by setting the projection field to a value like display_name and set the result type to Single value if you only want to get the information of one row.
What information of the contact do you want to access?
Regards,
Martin
Re: Input Dialog Date/Time & Global Variable Date/Time
My intention is to pick up the phone # from the phone book. I've taken a look at the example but i think it'll only pick up the contact's name. I'll try again using your suggestions.
Re: Input Dialog Date/Time & Global Variable Date/Time
@Martin.
No success following your suggestions but i think it's close. The action Start Activity sets variable {data_string} to "content://com.android.contacts/contacts/lookup/931i4b95182a8b42a08e/329". The action Query Content didn't produce useful results as I wasn't sure what to input to the Projection field. It didn't allow selection from the list since the Uri was a variable. Is there a table to refer to for the column names to use with Projection?
By the way, by using "vnd.android.cursor.dir/phone_v2" for Data Mime Type, it allows selection from the list of numbers that the contact has. I'm not sure how to use the result though.
No success following your suggestions but i think it's close. The action Start Activity sets variable {data_string} to "content://com.android.contacts/contacts/lookup/931i4b95182a8b42a08e/329". The action Query Content didn't produce useful results as I wasn't sure what to input to the Projection field. It didn't allow selection from the list since the Uri was a variable. Is there a table to refer to for the column names to use with Projection?
By the way, by using "vnd.android.cursor.dir/phone_v2" for Data Mime Type, it allows selection from the list of numbers that the contact has. I'm not sure how to use the result though.
Re: Input Dialog Date/Time & Global Variable Date/Time
I usually paste an example content URI into the Query Content Provider action so Automagic is able to fetch the available column names to fill in the projection and then later switch to the variable. I also recommend to add some conditions Debug Dialog into the flow so you can check the contents of each variable.
Selecting a phone number should work with a flow like this:
-action Start Activity: android.intent.action.PICK (Data Mime Type: vnd.android.cursor.dir/phone_v2, Wait for Result: checked)
-action Query Content Provider: SELECT data1 FROM {data_string}
-condition Debug Dialog (to show the result)
Flow: Pick phone number
The flow should provide the phone number in variable phone_number.
Google provides the following documentation to work with the contacts provider:
http://developer.android.com/guide/topi ... vider.html
In my opinion it's quite difficult to understand this stuff.
Selecting a phone number should work with a flow like this:
-action Start Activity: android.intent.action.PICK (Data Mime Type: vnd.android.cursor.dir/phone_v2, Wait for Result: checked)
-action Query Content Provider: SELECT data1 FROM {data_string}
-condition Debug Dialog (to show the result)
Flow: Pick phone number
The flow should provide the phone number in variable phone_number.
Google provides the following documentation to work with the contacts provider:
http://developer.android.com/guide/topi ... vider.html
In my opinion it's quite difficult to understand this stuff.
Re: Input Dialog Date/Time & Global Variable Date/Time
Finally done and I thought it would look complicated. Thanks.