function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MisbahMisbah 

Get User info Through SOQL

Hi

 

Is there any way to get current Logged in user information through Mobile SDK. I have some custom records which are assigned to users and we want to filter records based on logged in user.

 

I was doing a query 

 

"Select Inspection_Name__C , Inspection_Date__c,Assigned_To__c from Inspecition__C where Assgined_To__c =: UserInfo.getUserId()

 

This query works fine in Apex class but on Mobile SDK it is giving error.

 

Is there any other way to even detect the logged in user login info so i could query the USER object to get more information about user.

Best Answer chosen by Admin (Salesforce Developers) 
Tom GersicTom Gersic

The user ID is returned in the oAuth callback URI after login. It's available from the SFOauthCredentials. The call to retrieve it varies a bit by platform (iOS, Android, or Hybrid/JS).

All Answers

Tom GersicTom Gersic

The user ID is returned in the oAuth callback URI after login. It's available from the SFOauthCredentials. The call to retrieve it varies a bit by platform (iOS, Android, or Hybrid/JS).

This was selected as the best answer
MisbahMisbah

Hi TOm

 

I am using IOS SDK, I found SFOauthCredentials class and it has a USERID string function. can you please share the syntex how to initilize this class.

MisbahMisbah

Hi Tom

 

Thanks for your help i played another trick in "SFAppDelegate" there is a method which is doing authentication , i added my code there to save the USERID in Preferences.

 

- (void)oauthCoordinatorDidAuthenticate:(SFOAuthCoordinator *)coordinator {

    NSLog(@"oauthCoordinatorDidAuthenticate for userId: %@", coordinator.credentials.userId);

    NSUserDefaults *pRef = [NSUserDefaultsstandardUserDefaults];

    [pRef setValue:coordinator.credentials.userId forKey:@"UserID"];

    [pRef synchronize];

    [coordinator.view removeFromSuperview];

    [self loggedIn];

}