Hello! First off loving Seatable. I have been searching for this unicorn of a software forever And am happy to have finally found it. After learning of the hard limits and extreme pricing of aircough cough table, I am currently evaluating the developer edition on Ubuntu server edition and all has been working well. I literally just cannot figure out a simple script to save my life.
My use case is when pressing a button, I trigger a script to display a confirmation dialogue asking if I am ready to begin setup? IF āOKā is clicked the current date and time will be set into a column called āStart Setup Timeā. IF ācancelā is clicked, the column is cleared. All works well, however the time automatically reverts to 00:00. Can any one help me with this? Thank you!
if (confirm(āReady to begin setup?ā)) {
let newdate = new Date();
var res = newdate.toLocaleString();
base.modifyRow(table, row, {āSetup Start Timeā : res });
}
Thanks for your response Attached is screen shot!
As you can see in the date column type the time is shown as 00:00 instead of the current time referenced from calling new Date ();
And in the script I know it is referencing a different column name then what is in a screen shot I just am on the move and asked an employee to screen grab a column. We have 4 identical scripts dropping into for columns āStart setup time, end Setup time, start run time, end run timeā. So functionality is the same.
Thanks for your effort and the screenshot. Now I understand.
I think your script is missing something: the new Date() will return a datetime with minutes bu it cannot be written correctly into a date cell yet. You need the base.utils.formatDateWithMinutes:
let date = new Date();
let formatDate = base.utils.formatDateWithMinutes(date);
And then use the formatDate to write into your date column. Try if this helps?
const table = base.getActiveTable();
const row = base.context.currentRow;
if (confirm("Ready to begin setup?")) {
let date = new Date();
let formatDate = base.utils.formatDateWithMinutes(date);
base.modifyRow(table, row, {'Setup Start Time': formatDate });
}
else {
base.modifyRow(table, row, {āSetup Start Timeā : āā });
}
However, now nothing is placed into the column. To test things, I removed the else statement to allow for the record to be unchanged in event of cancel being pushed on the dialogue however this had no effect as nothing is still being placed into the cell. This is a head scratcherā¦
const table = base.getActiveTable();
const row = base.context.currentRow;
if (confirm("Ready to begin setup?")) {
let date = new Date();
let formatDate = base.utils.formatDateWithMinutes(date);
base.modifyRow(table, row, {'Setup Start Time': formatDate });
}
else {
}
You know what ā¦ I typed your code into my table and it worked perfectly.
What Iāve noticed in your code above, is that you donāt have indents in the if statement.
Of course the indents shouldnāt be the problem - but from this phenomena I assume, you might have copied and pasted your code somewhere else to SeaTable.
Thatās the tricky thing: when pasting codes into SeaTable, sometimes some invisible formatting symbols are pasted in, too.
Would you try copying the following code and pasting into your table and see if it works now? Itās directly copied from my table.
const table = base.getActiveTable();
const row = base.context.currentRow;
if (confirm("Ready to begin setup?")) {
let date = new Date();
let formatDate = base.utils.formatDateWithMinutes(date);
base.modifyRow(table, row, {'Setup Start Time': formatDate});
}
else {
}
You are going to love thisā¦ I copy and pasted your code in and still nothing happened.
THEN I HAD A THOUGHT.
I was working directly in safari and remembered javascript sometimes gets weird thereā¦opened chrome and BOOM perfect! I knew it had to be something simple!!
Thank you so much for your help. I also just got my EE license and upgraded from the DE. I am presenting seatable to the principles of our screen printing company in just under 2 months. Provided all goes well we will requesting additional paid seats well beyond the 3 free. Great Great Great product and support!