Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Automatic propose logged in user as contributor (writer)

Questions related to using nuBuilder Forte.
Post Reply
ingar
Posts: 10
Joined: Mon May 06, 2019 9:31 am

Automatic propose logged in user as contributor (writer)

Unread post 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
Janusz
nuBuilder Team
Posts: 506
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 8 times
Been thanked: 18 times

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

Unread post 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)
If you like nuBuilder, please leave a review on SourceForge
ingar
Posts: 10
Joined: Mon May 06, 2019 9:31 am

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

Unread post 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
Janusz
nuBuilder Team
Posts: 506
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 8 times
Been thanked: 18 times

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

Unread post 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();
}
If you like nuBuilder, please leave a review on SourceForge
Janusz
nuBuilder Team
Posts: 506
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 8 times
Been thanked: 18 times

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

Unread post 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
If you like nuBuilder, please leave a review on SourceForge
Post Reply