Changes

Jump to navigation Jump to search
3,070 bytes added ,  15:39, 10 August 2021
m
no edit summary
Line 102: Line 102:  
| 2021-07-24 || Ernst || Ernst's playground German home page || Home page in German || To begin to work in the wiki || In progress
 
| 2021-07-24 || Ernst || Ernst's playground German home page || Home page in German || To begin to work in the wiki || In progress
 
|-
 
|-
| 08.08.2021 || Ernst || Erläuterung für MementoWorld || Installation || Zum Testen || Anfang  
+
| 08.08.2021 || Ernst || [[Erläuterung für MementoWorld : Installation ]] || Installation || Zum Testen || Anfang  
 
|}
 
|}
 
</span>
 
</span>
Line 202: Line 202:  
! Colors
 
! Colors
 
|- bgcolor="#E8F0E8"
 
|- bgcolor="#E8F0E8"
| Active
+
|
 
=== Sergio's photographic equipment email ===
 
=== Sergio's photographic equipment email ===
 
I have a LOT of camera equipment (Camera, Lens, Filters, tripods, bags, etc.). I want to be able to create records of all of this equipment for personal inventory as well as insurance purposes.
 
I have a LOT of camera equipment (Camera, Lens, Filters, tripods, bags, etc.). I want to be able to create records of all of this equipment for personal inventory as well as insurance purposes.
Line 245: Line 245:     
<hr><hr>
 
<hr><hr>
 +
 +
=== Example: Making a Shared library function available & call-in it from a trigger or action ===
 +
{| class="wikitable"
 +
! From forum email
 +
|+ Considering scripting Memento
 +
|- bgcolor="#E8F0E8"
 +
| stary-@live.com, Aug 10 2021
 +
If you want to extend Memento with JavaScript, I suggest you read the wiki, so you can learn how to do it. If you want to use the simplest scripts, you could try using a JavaScript field, but it doesn't have fancy global functions like set() or link() or libByName(), but it does have simple global functions like field();
 +
 +
If you decide a usually simple JavaScript field is for you, read this page...
 +
JavaScript field, or...
 +
https://wiki.mementodatabase.com/index.php/JavaScript_field
 +
 +
If a fancy, probably longer script is what you feel you need, read this page, for starters, since all the other stuff is based on: Memento Javascript Library, or...
 +
https://wiki.mementodatabase.com/index.php/Memento_JavaScript_Library
 +
 +
If you're going for the fancier stuff & have read the MJL page, you can then branch out into various directions, depending on what you want to do next...
 +
 +
* For a button in the libraries list screen or a button in an edit view card (assuming mobile Memento): Actions, or...
 +
https://wiki.mementodatabase.com/index.php/Actions
 +
 +
* For a script to run automatically when certain things happen in certain circumstances: Triggers, or...
 +
https://wiki.mementodatabase.com/index.php/Triggers, or...
 +
 +
...and...
 +
Trigger examples: Trigger examples, or...
 +
https://wiki.mementodatabase.com/index.php/Trigger_examples
 +
 +
The rest of the MJL-based JavaScript pages are for other, less-often-used scripts...
 +
https://wiki.mementodatabase.com/index.php/Data_Sources, or...
 +
https://wiki.mementodatabase.com/index.php/How:Write_scripts_in_JavaScript_for_Memento, or...
 +
https://wiki.mementodatabase.com/index.php/Tips:Using_JavaScript_in_Memento
 +
|- bgcolor="#E8F0E8"
 +
|
 +
For a shared function definition, it should be...
 +
<pre>
 +
function sub(fieldname, fieldvalue) {
 +
    entry().set(fieldName, fieldValue);
 +
}
 +
</pre>
 +
Then call that in a trigger, action, or whatever with this...
 +
<pre>
 +
sub("name", "bullet");
 +
</pre>
 +
On Tue, Aug 10, 2021, 16:34 Bill Crews <bill.crews@gmail.com> wrote:
 +
Hide quoted text
 +
We know only what we can glean ... That there is a field named "name" and a value "bullet" that you want to go into that field. If it's a shared script, why does it call a global function field()? There is no such global function. There must be a "current entry" for that, and shared scripts (like most other things) don't work for JavaScript fields.
 +
 +
If you tell us more, we can be of more help, but all I can do is guess that the following is what you want...
 +
 +
It must be a trigger script or an action script located in an entry. This enables the entry() global function to work, so there is a "current" entry.
 +
 +
So, <code> entry().set("name", "bullet"); </code> is all the script you need, if your objective is to set that field's value to "button". If you're wanting to do something else, you might consider telling what that is.
 +
|}
    
== Work completed ==
 
== Work completed ==

Navigation menu