M.App Enterprise Discussions

Discuss topics with other M.App Enterprise Product pioneers and experts to get the most out of it.
Showing results for 
Search instead for 
Do you mean 
Reply
Highlighted
Contributor
Posts: 30
Registered: ‎03-16-2020
Accepted Solution

Save user id by javascript api

Hello,

 

I just need to save user id in form by JavaScript API function.

 

just like that, there is getUserName() return name of the user

 

 

<SaveShellAction.BeforeScript>
Context.setValue('user_name', Context.getUserName());			</SaveShellAction.BeforeScript>

so I just want a function to return id of the user.

 

Highlighted
Technical Evangelist
Posts: 1,351
Registered: ‎09-11-2015

Re: Save user id by javascript api

I suppose this question was already answered (in support ticket), but you can use Entity Trigger to store the user id before saving the form:

<Entity Id="Crime_ent" Table="Crime" Key="Guid" SyncType="Automatic" >
   ...
   <Field Name="userID" Type="Guid" />
   ...
   <Entity.Triggers>
      <UpdateFieldTrigger Method="BeforeSave,BeforeUpdate" Field="userID" Value="@{System.UserId}" />
   </Entity.Triggers>
</Entity>

 

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial