Inmagic Forums
Inmagic Forums
Scripting
Can I open a textbase from another, paste date info in field?|
Go
![]() |
New
![]() |
Find
![]() |
Notify
![]() |
Tools
![]() |
Reply
![]() |
|
I am a total JS ignorant.
I apologize in advance. I need to keep strict control on a linked field (resides in "Archive"), but need to allow the user to add a new entry to the "Archive" database from the "Main" textbase edit screen. A numeric representation of the date and time (YYYYMMDDhhmmss) is used as the Unique record number in the archive database. I have figured out the code to create the number via JS, but I have no idea how to open a new record in the other textbase, identify the box I need to paste the content into, etc. I am sorry to be so helpless...but I have found the command to start the process using a button as I would like to... <button onclick= I have found the command to open a textbase, but am not sure where in the script to put it or how to use it properly. Command.openTextbase() Do I put the name of the other textbase in the parenthesis Like this: Command.openTextbase(Archive Management) I can get help on the more standard java content but I just want to be sure that I get the text base opening and the "naming" of the fields so I can reference them properly in the script. |
|||
|
I was able to work something out when I finally found someone who "spoke java". Thus in case anyone actually needs the same kind of script I did, I am posting my own answer.
It actually entails adding scripts to two forms. Since the two textbases are linked I am able to initiate editing the secondary record with a script button and the script: function assignarchive_onClick() { Application.userStore.value("testfile") = Form.boxes("MAINfilenumber").content; var test = Application.userStore.value("testfile"); Form.boxes("MAINarchnumber").setFocus(); Command.editSecondaryRecord(); } Then in the secondary record, a script button pastes the needed data (some copied from the previous form and some generated by the script): function ARCHcreate_onClick() { // Simulates PHP's date function Date.prototype.format = function(format) { var returnStr = ''; var replace = Date.replaceChars; for (var i = 0; i < format.length; i++) { var curChar = format.charAt(i); if (replace[curChar]) returnStr += replace[curChar].call(this); else returnStr += curChar; } return returnStr; }; Date.replaceChars = { // Day d: function() { return (this.getDate() < 10 ? '0' : '') + this.getDate(); }, // Month m: function() { return (this.getMonth() < 11 ? '0' : '') + (this.getMonth() + 1); }, // Year Y: function() { return this.getFullYear(); }, // Time H: function() { return (this.getHours() < 10 ? '0' : '') + this.getHours(); }, i: function() { return (this.getMinutes() < 10 ? '0' : '') + this.getMinutes(); }, s: function() { return (this.getSeconds() < 10 ? '0' : '') + this.getSeconds(); }, // Full Date/Time U: function() { return this.getTime() / 1000; } } var myDate = new Date(); var testing = myDate.format('YmdHis'); Form.boxes("ARCHnumber").content = testing; var test = Application.userStore.value("testfile"); Form.boxes("ARCHfilenumber").content = test; } |
||||
|
| Powered by Eve Community |
| Please Wait. Your request is being processed... |
|
Inmagic Forums
Inmagic Forums
Scripting
Can I open a textbase from another, paste date info in field?
