# Populate user email address in the forms from REMOTE\_USER

**URL:** <https://discourse.openondemand.org/t/populate-user-email-address-in-the-forms-from-remote-user/3017>\
**Category:** Get Help\
**Created:** [October 14, 2023, 12:56pm UTC](https://discourse.openondemand.org/t/populate-user-email-address-in-the-forms-from-remote-user/3017 "2023-10-14T12:56:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![GKlouse](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/gklouse/32/1046_2.png) [@GKlouse](https://discourse.openondemand.org/u/GKlouse)\
**Post date:** [October 14, 2023, 12:56pm UTC](https://discourse.openondemand.org/t/populate-user-email-address-in-the-forms-from-remote-user/3017/1 "2023-10-14T12:56:34Z")

</div>

Is there a way I can pull the current user’s email address to automatically populate a field in the form.yml and submit.yml files for an interactive vnc submit?

Ultimately, I would like to add the option to my form which will enable slurm to email the user when the current session is at 50,80,90, and 100% time limit. You have implemented a similar option with the “bc\_email\_on\_started” option, and I would like to just pull the user’s email to add it into the submit.yml automatically based on the current user.

Thanks,  
Greg

---

<div class="post-metadata">

**Author:** ![travert](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/travert/32/3074_2.png) [@travert](https://discourse.openondemand.org/u/travert)\
**Post date:** [October 16, 2023, 5:05pm UTC](https://discourse.openondemand.org/t/populate-user-email-address-in-the-forms-from-remote-user/3017/2 "2023-10-16T17:05:59Z")

</div>

> [@GKlouse](#):
>
> Is there a way I can pull the current user’s email address to automatically populate a field in the form.yml and submit.yml files for an interactive vnc submit?

I’m not entirely sure to be honest. There is a previous thread around some questions about how the emailing works, with a suggestion of how to set `headers` with this information in the `cluster` config here:

> [@Global email setting](https://discourse.openondemand.org/t/global-email-setting/123/2):
>
> To verify, the goal is to set the email argument for each user, for each interactive app, in a single place. What resource manager are you using? Out of the box we don’t support this, but we have discussed adding support for this type of thing, as we would find it very useful as well. These are some related issues we have currently opened up: [https://github.com/OSC/ood\_core/issues/97](https://github.com/OSC/ood_core/issues/97) - want the ability to add default submission arguments in the cluster config for every job submitted through…

Which is a bit older and was linked form another conversation around getting emails for jobs here:

> [@E-mail to user at job start,](https://discourse.openondemand.org/t/e-mail-to-user-at-job-start/1665):
>
> There has been some discussion earlier on different sites implementing e-mail alerts when OOD jobs start, via the bc\_email\_on\_started attribute. For the user to get the e-mail, the scheduler needs to also have the e-mail address of the user and turn on the option to feed in that e-mail (in SLURM –mail-user). I can put this in each app’s submit.yml.erb (e.g., in our case –mail-user=$USER@utah.edu), but, given the amount of apps we have it’d be easier if this could be a global option for all jobs…

In short, I’m not sure of a way to pull this to populate the `form` and `submit` unless you can glean something from those posts.

---

<div class="post-metadata">

**Author:** ![mcuma](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/mcuma/32/171_2.png) [@mcuma](https://discourse.openondemand.org/u/mcuma)\
**Post date:** [October 16, 2023, 6:47pm UTC](https://discourse.openondemand.org/t/populate-user-email-address-in-the-forms-from-remote-user/3017/3 "2023-10-16T18:47:48Z")

</div>

Hi everyone, we do this in submit.yml.erb:

\<%-  
emailcmd = '/uufs/chpc.utah.edu/sys/bin/CHPCEmailLookup.sh ’ + ENV[“USER”]  
emailaddr = %x[#{emailcmd}]  
-%\>

* * *

batch\_connect:  
template: vnc  
script:  
email: \<%= emailaddr %\>

The /uufs/chpc.utah.edu/sys/bin/CHPCEmailLookup.sh is a script that matches the Linux user name with the e-mail address in our database. That is more robust than the previous setting we had:  
email: \<%= ENV[“USER”] %\>@utah.edu  
because some users use other e-mail addresses than our domain.

You could do the same thing in the form.yml.erb to display the e-mail address in the submission form.

HTH.

---

<div class="post-metadata">

**Author:** ![GKlouse](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/gklouse/32/1046_2.png) [@GKlouse](https://discourse.openondemand.org/u/GKlouse)\
**Post date:** [October 17, 2023, 4:13pm UTC](https://discourse.openondemand.org/t/populate-user-email-address-in-the-forms-from-remote-user/3017/4 "2023-10-17T16:13:43Z")

</div>

Thanks guys for the feedback. I ended up using a text input widget for the email address within the form, then calling that variable in the submit.yml like this:

… “–mail-user”, “#{email}”, “–mail-type”, “TIME\_LIMIT\_50,TIME\_LIMIT\_80,TIME\_LIMIT\_90,TIME\_LIMIT”]

I didn’t realize how easy this was to implement, so I am happy with the result =)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/osc/original/2X/b/bae70bd0ed39a3ae769c2108155f4cb3e9da8385.png) [@system](https://discourse.openondemand.org/u/system)\
**Post date:** [April 14, 2024, 4:13pm UTC](https://discourse.openondemand.org/t/populate-user-email-address-in-the-forms-from-remote-user/3017/5 "2024-04-14T16:13:54Z")

</div>

Closed on April 14, 2024, 4:13pm UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
