Page 1 of 1

Automatic propose logged in user as contributor (writer)

Posted: Fri May 31, 2019 10:50 pm
by ingar
Hello,

I can't figure out how to do this - my webcoding knowledge is too limited :-(

I have a customer support phonelog, to record phonecalls and cases from customers. We are several co-workers who's doing this support task and each has their own login.
In the subform (logging of customer calls) I was hoping to find a way for the column co-worker (labeled 'Medarb') to be automatically chosen (filled in) based on the logged in users ID.

I have a table for co-workers ('medarbeider') which has a connection to phonelog table ('telefonlogg') with a foreign key in phonelog table ('tel_medID') pointing at the primary key in table 'medarbeider'.
In the table 'medarbeider' (co-workers) I also have a column containing a copy of each users nuuserID (for instance '5ce170db2ae06e3').

Is it possible to have the subform phonelog ('telefonlogg') to fill in the column labeled 'Medarb' automatically when saving - if (!) the column is empty?


Image

Re: Automatic propose logged in user as contributor (writer)

Posted: Fri May 31, 2019 11:05 pm
by Janusz
Hi,
Not sure for the question - are you looking for the automatic name insertion (based on login) like in the following case?
https://drive.google.com/file/d/1mnd2wH ... 1PCIh/view

field "Kto" is automatically updated before save based on login name (in this case login name is Janusz)

Re: Automatic propose logged in user as contributor (writer)

Posted: Sat Jun 01, 2019 5:15 pm
by ingar
Hi,

Yes, something very similar to what you showed in your video.

The thing is: I have a separate table for co-workers ('medarbeider'), since I need that for other things too. Entries into the phonelog/subform (table 'telefonlogg') are based on the co-worker ID from table 'medarbeider' (co-worker).

I was hoping to achieve that it fills in users ID automatically WHEN SAVING the subform data. I'm having a correlation between the tables as shown in this image:

Image

Re: Automatic propose logged in user as contributor (writer)

Posted: Sat Jun 01, 2019 6:09 pm
by Janusz
Hi,
Please find enclosed the very good and clear description which I received from Kev1n some time ago:
https://forums.nubuilder.cloud/viewtopic.php?f=20&t=9716
(have a look at the end of the first page).

the above you can use to set initial value for the select field for example (the name must be present in the list - otherwise field will stay blank).

in my case for the select field I am using data from the table for example:

Code: Select all

SELECT
    Pracownicy.pra_imie, Pracownicy.pra_imie

FROM
    Pracownicy
WHERE
	Pracownicy.pra_status=1
ORDER BY 
    Pracownicy.pra_aux
to set initial value of the form with new record you can use as well in java script nuIsNewRecord - just any example belowe - if to be used on the subform pay attention to use proper addressing:

Code: Select all

if(nuIsNewRecord()){
$('#ofe_status').val('1*-do zrobienia').change();
$('#button_save').show();
var nuUser = getUser();
$('#ofe_created_by').val(nuUser).change();
$('#ofe_zrobione').val(nuUser).change();
}

Re: Automatic propose logged in user as contributor (writer)

Posted: Sat Jun 01, 2019 6:28 pm
by Janusz
and just one example with new forms with some fields prefilled which you can change easilly afterwards:
https://drive.google.com/open?id=1hsE30 ... REW_nq0D48