Script to ADD Contact

12 views
Skip to first unread message

Eoprava sk

unread,
7:52 AM (16 hours ago) 7:52 AM
to mementodatabase
Hello. 

I seek for an advice, I´d like to ADD customer contact to my Android Phone. 
I already set up , that when the customer is new one, i just writte it once and it will create customer in customers library. 

Now i ´d like to Add the customer to my contacts, so I know who´s calling me. 

Setup:
Android 14, Google Phone (Google Contacts) APP
Contact in library:
Name (Text field)
Phone (Phone field)
Email: (Mail field) - don´t need to store the mail , just in case for future. 

Anyone have an idea? 

Sending my script to ADD to another library as an example

let lbn = libByName('Zakaznici');
let cust = lbn.entries();
// Array of all phone numbers
let phon = cust.map(a => a.field('Mobil'));

let e = entry();
let ph = e.field('Mobil');

// Create a record if the phone number is not in Customers
if (!phon.some(a => a === ph)) {
    let obj = {};
    let arr = ["Mobil", "Meno,firma", "Email", "Firma", "Názov firmy", "Adresa", "PSČ Mesto", "IČO", "DIČ", "IČ DPH"];
    for (let abc of arr) {
        obj[abc] = e.field(abc);
    }
    lbn.create(obj);
    message('Zákazník pridaný ' + obj['Meno,firma']);
}
Reply all
Reply to author
Forward
0 new messages