UserInfo Property

  • 1
  • Question
  • Updated 3 years ago
  • Answered
I have a model (VendorRecords) which needs a Condition to only allow users that work for the supplier connected to the record (i.e. the model has a "supplier" field as well).  I'm trying to utilize the "Running User Attribute" in order to pull the user's Company.  There is a drop down list called "UserInfo Property", but this list doesn't seem to include the fields included in the Manage Users > Users section of Skuid:





Am I missing something?  Is there another way to look up a user's company name?  Is there a better way of doing this?
Photo of Scott

Scott

  • 2,722 Points 2k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Scott, the "Company" field on the User's record can be retrieved by using a "Field from another Model" Condition and having another Model that retrieves this value for the running User. 

Technically there are only certain fields that Skuid can pull in from Salesforce about the "User Info" of the running user without having to make a SOQL query in the background. Because not all users might care about the Company field / other fields on the user object not exposed without a SOQL query, and because you have the ability to add a separate Model to request this information (and therefore effectively make this SOQL query yourself), Skuid does not automatically query for this information and add it to the "User Info" property. 
Photo of Scott

Scott

  • 2,722 Points 2k badge 2x thumb
Thank you!
Could you possibly give a little more detail for "Scott, the "Company" field on the User's record can be retrieved by using a "Field from another Model" Condition and having another Model that retrieves this value for the running User."?  How do I pull the Company field into a model?  I can't locate the Salesforce Object Name where it would be stored.  I really appreciate you help!
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Add a Model on the Salesforce User object. Search for the Company field and add it to the Model's fields. Add a single Condition to the Model, on the User Id field, with Value being "User Info property --- User Id".
(Edited)
Photo of Scott

Scott

  • 2,722 Points 2k badge 2x thumb
Okay - I found the "User" table that lists this data... I'm gonna see what I can finagle!  Thanks!
Photo of Scott

Scott

  • 2,722 Points 2k badge 2x thumb
I was able to create the necessary models and connect to the correct data, but now i'm having an issue applying the condition to the primary model.

Basically, I have a list of records, each with a SUPPLIER field.  I also have a model which lists all available users and has the condition to only output the current user.  This user model seems to work fine.  Finally, I then add a condition to the main table so the SUPPLIER = USER.COMPANY NAME.  The values definitely match.  When I hardcode the COMPANY number (i.e. SUPPLIER = "9999999"), the condition works properly, but with the USER.COMPANY lookup, the condition is not outputting any records:



The image above shows the user info on the left (see the company name) and the main table on the right (the condition is removed for this image).  The COMPANY NAME and SUPPLIER fields match.



This second image is the condition added to the main table which links the Supplier field to the User model > Company Name field.

Does anyone know why this condition isn't working?  This is a crucial element for my project and my last big hurdle.  I'd really appreciate some help on this one...
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Scott, make sure that in the list of Models, your CurrentUser Model is at the top (the first Model in the list). Otherwise when the other Models' queries are run, the CurrentUser.Company field won't be available yet, and the Condition won't have a value, so it won't work as expected. Basically it's an Order of Operations thing --- you can't have a Condition reference a value that Skuid doesn't have yet because the Model the value is contained in didn't get queried yet. Order of Models matters.
Photo of Scott

Scott

  • 2,722 Points 2k badge 2x thumb
Great!  That did it!  Thanks SO MUCH!