How to auto populate User id in a reference field in scoped apps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2019 01:56 PM
Hi All ,
I need help with situation explained below .
i am working in a scoped app called 'Lab client' ,on lab form i created a reference field 'Recorded By' which reference to sys_user table .
i am trying to auto populate it with logged in user id . for this i used " javascript:gs.getUserID() " in atrributes , it didn't work . used it in default value too , it didn't work .
i changed the default value or attribute to "gs.info(gs.getUserID());" , didn't work .
info about current functionality :
as shown below , visit notes is the field .
when user types something in this field , then two fields appear above Recorded by and spoke date as shown
when user selects a user in recorded by field and selects a date in spoke date and type something in the visit notes , then all data from these three fields are recorded in a 'Activities' journal notes below it and these three fields are emptied . so user can enter multiple meetings .
Questions :
1)as you see in above image , for 'recorded by' field i am selecting the user id but in the visit notes field it is being saved as sys id and same is stored in , how do i fix this issue ?
2)can i auto populate the recorded By field with logged in user id ? since there is a client script in the backend to make it mandatory , set display to false if visit notes is empty and to clear the value .
( my doubt is even thought we set it with logged in user id ,but the line of code from below screen shot g_form.clearvalue('u_reocrded_by'); will clear the value i guess )
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2019 02:26 PM
Try this out and let me know if it works
Ensure that u_recorded_by field has the reference to the User table in the "Reference Specification" section
In the Default Value section
Check the "Use dynamic default" option
Create a new Dynamic Filter option and in the Script field enter gs.getUserID();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2019 02:44 PM
Hi ,
Yup , it's exactly the way you configured . still no luch .
do you any idea about my question 1 above , i see sys id of the user selected in recorded by field . when i select it shows user id in that field , but when form is saved , then in acvities , it's saved as sys id .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2019 03:03 PM
I'm not entirely sure about your logic here
I'm looking at your screen shot and the Client script is set on some other field "Visit Note"
Can you try disabling the Client Script and instead use a UI policy to make the field mandatory ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2019 09:28 PM
hi,
navigation path
->recorded by -> configure dictionary -> go for advanced view -> in default value ->( click true on )use dynamic default ->in dynamic default value field select (me)in the reference value of dynamic default .
hope this will help you