Help with fields Memento ID & Picture.http

304 views
Skip to first unread message

Aaron

unread,
Dec 12, 2018, 12:20:11 AM12/12/18
to mementodatabase
Hi All, I have a few fields that I need help with.

My Library:
  • Picture (image field)
  • Item Name (text field)
  • Model Nr (text field)
When I export to google drive it creates a spreadsheet and I get 5 fields:
  • Picture (something like file:///storage/emulated/0/memento/files/...jpg)
  • Item Name
  • Model Nr
  • Picture.http (something like https://drive.google.com/a/,,,,,,)
  • MEMENTO_ID (something like 1544552412839)
Picture.http seems to be a link of the image, but instead of the location on the phone, once it is uploaded to google drive, it is a url of that location.
MEMENTO_ID seems to be a unique id that memento uses, and it seems to be auto incrementing because if I quickly enter data, it is in sequence. But if I wait a while, there is a gap of missing numbers in the sequence. 

I want to use these two fields in my custom scripts that I am creating for my library. Is there any way of retrieving this data? I messed with lib().entries() and entry().field('whatever') without any luck.

Bill Crews

unread,
Dec 12, 2018, 9:39:46 AM12/12/18
to Aaron, mementodatabase
The ID is readily available as a property of the Entry object, so entry().id should get you what you want.

As for the URL, you might try an HTTP request. Check out http://wiki.mementodatabase.com/index.php/Memento_JavaScript_Library#Processing_an_HTTP_request. I think an Http object has a get() method that returns an HttpResult object that might contain what you want.

Aaron

unread,
Dec 12, 2018, 2:01:30 PM12/12/18
to mementodatabase
entry().id is something else, not the same "MEMENTO_ID".

Url: How can I know what the URL of the document is in order to use get()? 

Eoprava sk

unread,
Feb 7, 2024, 4:52:57 PMFeb 7
to mementodatabase
Hello. 

I would like to ask for a help. 
We need create unique ID based on current date in format YYYYMMDDXXXXXX // let´s say 2024020700001
X represents unique ID with autoincrement ideally if not possible Unique is good for us. 

We have created field "mydate" this one creates automatically with current date but we need to extract the numbers from it. Also we need system to remember last XXXXXX number so it could go on 
We have over 2500 entries created so that´s why we need the date prefix, when we generated Unique ID it´s not really working way we expect. 

we also tried entry.id to use but the default memento ID is just too long (it causes problem when we use it in print as barcode)

Purpose of the ID is that we used product serial number, but in most cases it´s missing or cant be read. So we need unique identifier of custom, but we print multiple documents from memento as jasper reports, (A4 & 80 mm thermal paper + labels 5*4CM)

So is need to has some format. Also we collect 5 pages and about 100 inputs in an entry so i´m looking for something elegant best practice would be a hidden JS or combination JS / trigger

Thank you for your help :) Memento is nice system for creating CRM :)

Dátum: streda 12. decembra 2018, čas: 20:01:30 UTC+1, odosielateľ: Aaron

Mmm

unread,
Feb 8, 2024, 7:48:51 AMFeb 8
to mementodatabase
Скрипт Действие в библиотеке.
Поле "mydate" заполняется датой создания записи (свойство entry().creationTime).
ID продукта создается по дате и номеру записи в библиотеке.
Требуется подключение библиотеки moment.min.js 
Заполняются только пустые поля.
Если хотите добавьте проверку на уникальность (обсуждали недавно).


let entries = lib().entries();

let new_id = '';
let p = entries.length;
let i = p;

while (i--) {
  let e = entries[i];
  if (e.field('mydate') === null) {
    e.set('mydate', e.creationTime);
  } 
  new_id = e.field('product id');

  if (new_id.length === 0) {
    new_id = moment(e.field('mydate')).format('YYYYMMDDHHmm') + String(p - i).padStart(5,'0');
    e.set('product id', new_id);
  } 
}

Шаблон с примером по ссылке:

четверг, 8 февраля 2024 г. в 00:52:57 UTC+3, eop...@gmail.com:

Mmm

unread,
Feb 8, 2024, 10:15:09 AMFeb 8
to mementodatabase
В дополнение к предыдущей записи. 

четверг, 8 февраля 2024 г. в 15:48:51 UTC+3, Mmm:
Scr_20240208_181300.jpg
Message has been deleted
Message has been deleted

Eoprava sk

unread,
Feb 8, 2024, 3:26:53 PMFeb 8
to mementodatabase
Hello. I deleted last 2 messages, i found out problem and solution for it. I can add product id text field with predilled value "1" then when i delete it and save, run the script it works, but can you help me program "Action" to set entry field "product id" to null / delete the "1" input in it it should work this way :) 

Thank you for your help :) script works perfectly i just added it as trigger

Dátum: štvrtok 8. februára 2024, čas: 16:15:09 UTC+1, odosielateľ: Mmm

Mmm

unread,
Feb 9, 2024, 12:35:22 AMFeb 9
to mementodatabase
Если я правильно понял, Вы хотите оставить некоторые поля с ID пустыми, но скрипт это не позволяет.
Добавьте новое поле логическое (флажок) "Do not change the ID" и внесите изменение в скрипт:


замените строку:

if (new_id.length === 0 && ) {

на:

if (new_id.length === 0 && !e.field('Do not change the ID')) {
// не пропустите "!" - это оператор "НЕ"


Пустые ID не будут заполняться при включённом флажке. 


четверг, 8 февраля 2024 г. в 23:26:53 UTC+3, eop...@gmail.com:
Reply all
Reply to author
Forward
0 new messages