Any Solution - My business requirement is to capture current Login User details along with Logged in

How i could get current logged in user details and current logged in IP Address in skuid page.  Is there any skuid javascript or any other work around.

There is a salesforce object called LoginHistory that will capture all that information.  You can have a tab action that creates a record in a custom object with the details of the LoginHistory object upon initial load.

Thanks Mansour.  Appreciate your deep SF knowledge applied here… 

Funny, I’m having trouble just simply querying this object and showing User details on the related user object. Skuid data table doesn’t seem to like to traverse past the UserId field to get the username. Any ideas why this is or if you guys overcame this?

Fascinating… It looks like you can select the user fields in the model, but then they’re not working in the builder and they’re not coming in correctly. I’ll dig deeper and see if this is a Salesforce limitation or something on our end.

In the meantime, you can override the metadata for the User ID field to be a text field so it displays the Id number, and you can use Model Lookup UI-Only formula field to display the name of the users from another model - feel free to reach out if you need more help setting that up.

1 Like

Thanks for the feedback and recognition of this issue I ran into. Turns out the user didn’t and couldn’t have the permissions to see this skuid page report I was building so it isn’t critical, but would be curious for the future!

Hi Jeff, I did some more digging here and here’s what I found:

Stack Exchange confirms you can’t get at the user details through the Login History object.

However there you can upvote the idea on the Salesforce Idea Exchange to surface the related user fields through this relationship.

In the meantime, just for fun I built a Skuid page that uses a Model_Lookup formula field to show the user names on the login history table. There’s also a user list with a few filters, but you can update it based on what’s most helpful for you.

<skuid__page unsavedchangeswarning="yes" personalizationmode="server" showsidebar="false" showheader="false">
	<models>
		<model id="UserList" limit="" query="true" createrowifnonefound="false" datasource="salesforce" sobject="User">
			<fields>
				<field id="Username"/>
				<field id="Name"/>
				<field id="ProfileId"/>
				<field id="Profile.Name"/>
				<field id="PermissionSetAssignments" type="childRelationship" limit="10">
					<fields>
						<field id="PermissionSetId"/>
						<field id="PermissionSet.Name"/>
					</fields>
				</field>
				<field id="Id"/>
				<field id="UserRoleId"/>
				<field id="UserRole.Name"/>
				<field id="IsActive"/>
			</fields>
			<conditions>
				<condition type="fieldvalue" value="true" enclosevalueinquotes="false" field="IsActive" clientorserver="server" state="filterableon" inactive="false" name="IsActive"/>
				<condition type="multiple" field="ProfileId" operator="in" inactive="true" enclosevalueinquotes="true" name="__autofilter__ProfileId" clientorserver="server" state="filterableoff" value=""/>
				<condition type="multiple" field="UserRoleId" operator="in" inactive="true" enclosevalueinquotes="true" name="__autofilter__UserRoleId" clientorserver="server" state="filterableoff" value=""/>
			</conditions>
			<actions/>
		</model>
		<model id="LoginHistory" limit="20" query="true" datasource="salesforce" sobject="LoginHistory" orderby="LoginTime DESC">
			<fields>
				<field id="UserId" overridemetadata="true" ogdisplaytype="REFERENCE" displaytype="TEXT" datasource="salesforce"/>
				<field id="User" uionly="true" displaytype="FORMULA" length="255" ogdisplaytype="TEXT" readonly="true" returntype="TEXT">
					<formula>MODEL_LOOKUP("UserList", "Name", "Id", {{UserId}})</formula>
				</field>
				<field id="Application"/>
				<field id="LoginTime"/>
			</fields>
			<conditions>
				<condition type="fieldvalue" field="LoginTime" operator="gte" inactive="true" enclosevalueinquotes="false" name="__autofilter__start__LoginTime" clientorserver="server" state="filterableoff" value=""/>
				<condition type="fieldvalue" field="LoginTime" operator="lte" inactive="true" enclosevalueinquotes="false" name="__autofilter__end__LoginTime" clientorserver="server" state="filterableoff" value=""/>
			</conditions>
			<actions/>
		</model>
	</models>
	<components>
		<skuid__tabContainer deferTabRendering="true" uniqueid="sk-3O7r-23417" rememberActiveTab="true">
			<tabs>
				<skuid__tabPanel name="User List">
					<components>
						<skuid__table allowColumnFreezing="dragDrop" model="UserList" uniqueid="sk-3O7v-25722" mode="read" showSaveCancel="true" pageSize="10" rowActionsOnLeft="true" adaptiveColumns="true">
							<fields>
								<field id="Name" uniqueid="fi-3O7v-26519"/>
								<field id="Username" uniqueid="fi-3O7v-26518"/>
								<field id="ProfileId" uniqueid="fi-3O7v-26520" label="Profile"/>
								<field id="UserRoleId" label="Role" uniqueid="fi-3O8V-35467"/>
								<field id="PermissionSetAssignments" type="CHILDREL" label="Permission Sets" delimiter=", " uniqueid="fi-3O7v-26522" template="{{PermissionSet.Name}}" allowHtml="true"/>
								<field id="IsActive" displayAs="SWITCH"/>
							</fields>
							<filtering enableSearch="false"/>
							<actions/>
							<rowActions>
								<action type="multi" label="Manage User" icon="sk-webicon-ink:ext-link">
									<actions>
										<action type="redirect" window="blank" url="https://skuid-skool.lightning.force.com/lightning/setup/ManageUsers/page?address=%2F{{{Id15}}}%3Fnoredirect%3D1%26isUserEntityOverride%3D1"/>
									</actions>
								</action>
							</rowActions>
							<massActions/>
							<exportProperties useTableColumns="true"/>
							<sorting enable="false"/>
							<filters>
								<skuid__filter uniqueId="sk-3O9n-60184" type="multiselect" conditionSource="auto" filterMethod="server" labelMode="manual" fieldtargetobjects="Profile" conditionField="ProfileId" conditionName="__autofilter__ProfileId" conditionOperator="in" label="Profile"/>
								<skuid__filter uniqueId="sk-3O9--65946" type="multiselect" conditionSource="auto" filterMethod="server" labelMode="manual" conditionField="UserRoleId" fieldtargetobjects="UserRole" conditionName="__autofilter__UserRoleId" conditionOperator="in" label="Role"/>
								<skuid__filter uniqueId="sk-3OBJ-74817" type="select" conditionSource="manual" filterMethod="server" labelMode="manual" label="Status" conditionName="IsActive" createFilterOffOption="false" filterOffOptionLabel="All Users">
									<sources>
										<source type="manual" effectsbehavior="justdefault">
											<options>
												<option label="All Users" type="complex">
													<effects>
														<effect action="deactivate" value="" condition="IsActive"/>
													</effects>
												</option>
											</options>
										</source>
										<source type="manual" effectsbehavior="justdefault">
											<options>
												<option label="Active" type="simple" value="true"/>
												<option label="Inactive" type="simple" value="false"/>
											</options>
										</source>
									</sources>
								</skuid__filter>
							</filters>
						</skuid__table>
					</components>
				</skuid__tabPanel>
				<skuid__tabPanel name="Login History">
					<components>
						<skuid__table allowColumnFreezing="dragDrop" model="LoginHistory" uniqueid="sk-2Mmh-13877" mode="readonly" showSaveCancel="false">
							<fields>
								<field id="User" uniqueid="fi-3O7d-19799"/>
								<field id="Application" uniqueid="fi-3O7d-19800"/>
								<field id="LoginTime" uniqueid="fi-3O7d-19801"/>
							</fields>
							<filtering enableSearch="false"/>
							<actions/>
							<rowActions/>
							<massActions/>
							<exportProperties useTableColumns="true"/>
							<sorting enable="false"/>
							<filters>
								<skuid__filter uniqueId="sk-3O7e-20605" type="daterange" conditionSource="auto" filterMethod="server" labelMode="no" conditionField="LoginTime" startConditionName="__autofilter__start__LoginTime" endConditionName="__autofilter__end__LoginTime"/>
							</filters>
						</skuid__table>
					</components>
				</skuid__tabPanel>
			</tabs>
		</skuid__tabContainer>
	</components>
	<resources>
		<labels/>
		<javascript/>
		<css/>
		<actionsequences/>
	</resources>
	<background/>
	<interactions/>
	<surfaces/>
</skuid__page>