Not able to get Lookup Filter to show correctly

Im am very new to both Skuid and Salesforce and have probably not understood how to set it up correctly so any advice welcome.
Bit of background first
I have a custom object with a few hundred entries which are site detail records
my users are only authorised to create documents based on certain sites which are assigned to them, this is stored on a custom field in the user object. actual access to the documents is via the role hierarchy so that is covered, what I needed to do is only allow the users to add documents for  sites they are authorised for and did not want to use validation to stop them afterwards as the picklist would still show hundreds of entries which are not relevant to them. so getting to my problem I looked at using lookup filter which I was able to do on the document object to create within salesforce by creating a lookup reference field as setting the formula to  Current User: WHS Current Site Name CONTAINS Site Name: Site Name, which works as the user contains a list of valid sites
on attempting this with Skuid on the lookup filter primary field I can only select fields from within that object not the user, so what ends up happening is the filter doesn’t pick up anything as its trying to match the wrong way.

I hope I haven’t confused all the terminology and thanks for any assistance
Neil  

Neil,

I am not following the setup of your objects.  I am not sure how to guide you.  Are you trying to limit what sites a user can add documents ‘to’?  Would you post some screenshots of your page and describe what you want to happen when a user does ‘xxx’.  

Thanks,

Bill

Hi Bill,
Thanks for the reply,
thought it wouldn’t make much sense.
I have an object called MMSite that contains the site records (name code type) about 300 of
I hold an authorised list of site names/codes on each users user object
when a user creates this MeetingPlan Object I have a lookup ref field to the MMsite object
I only want the picklist to show those authorised sites
On the salesforce image below you can see I can say
lookup the user records and show only mmsite records where the user records contains the right sitecode
while on the Skuid version the primary lookup will only show fields from MMsite Not User.
It is functioning somewhat as the saleforce lookup blocks them from being able to save non authorised sites which is half way there, I would really rather stop it showing them in the beginning
let me know I need to clarify further
Thanks Neil

Neil,

Your explanation helps a lot. Your user can create a Meeting Plan. They can designate what Site the meeting is ‘for’. You want to limit what Sites show in the lookup field on the Meeting Plan page to the Sites they are supposed to see.

I think you are storing the MMSite with the OwnerId set to each user. That is they are the ‘Salesforce’ owner of the MMSite record.

If this is the case, then you have 2 options to make this work.

Option 1 : Change the security access to the MMSite object to be ‘Private’. Make sure that each of the users is in the same Role or in a Role in a different hierarchy so that Role hierarchy doesn’t allow one of them to see the other’s MMSite. You will also need to make sure that the users are in a Role that is not System Administrator since they will normally be at the top of the Role hierarchy. If one of the users is a System Administrator and you want to limit the Sites that show, then Option 1 is not for you. This option has the advantage that it will always work on any Skuid page that you build. You won’t need to add the filter setting to each Site lookup on each page you build.

Option 2 : Set the Lookup filter to only show Sites where the current user is the Owner of the Site. To do this, first add a CurrentUser model to your page. Make sure it is the first model on the page (i.e. its at the ‘top’ above all other models). Return the Id (User Id) field. Add a Condition where the Id (User Id) equals the Running User Attribute User Id.

Now return to your Field Properties for your Site lookup. Set the Filter to only show MMSites where the OwnerId of the MMSite equals the User Id from the CurrentUser model.

Thanks,

Bill

Hi Bill,
Thanks, I think that sounds the sensible option but the problem I have with that is the MMSite records are pre-created ie not associated to a user at all just a list of places, names and an internal site code,
I am the owner on all the records as I created them via an import.
What I hold on the user object is a comma separated list of 3 digit authorised site “codes” not id’s I guess I could store the Id’s but the issue is still the visibility as users change ( swap locations, leave and new staff)
I can’t have them as direct owners of the Site record unless there is an easy way of managing those records centrally as they are a master record and I can’t expect the users to create/maintain, If I was to maintain centrally it appears to be able to transfer ownership initially the user needs read permission which I have turned off by making it private
Any thoughts
Thanks
Neil

Neil,

I recommend that you create a Skuid page that shows a table view of all MMSite records.  Make sure that the Table Actions for Mass Edit and Mass Update are enabled.  You don’t have to make this page available in any of your navigation.  Then you can manage this list using Skuid’s built in ‘mass record’ actions.  You will easily be able to change the owners as needed to match which sites they should see.  For instance, you can easily add a filter for the Owner field;  filter the records by Owner; select all rows; then mass update the Owner field to set a new owner for those records.

Then remove all of your MMSite records and reimport them and include the Owner field in your import.  You should be able to add the name of the user and use this to lookup the UserId for the Owner field during import.  This will save you the time of having to modify them in the user interface.

For your lookup field to work, each user who uses it must have at least read permission on MMSite.  They won’t be able to edit the record, but they will be able to see any they own and select the ‘Id’ for the lookup field.  This is how Salesforce is setup to work.  For example, the User object is setup for all users with read permission.  Salesforce uses field security to block out what fields the user can see and edit.  This allows someone to ‘transfer’ a record they own to another user.

If you continue with the design you have, you will have to write Javascript code for the Skuid page to build a model that you can use for the Lookup field and an Apex Class to access the MMSite object since the user won’t be able to see any records.  While this is technically possible, you now own all of the responsibility for developing and managing this code going forward.  This is counter to how Salesforce and Skuid are setup to help you.  You shouldn’t do it unless you have a very good reason.

Thanks,

Bill

Hi Bill,
Thanks for all your help, have taken your advice and re structured around the owner and all is working nicely

Great Work Bill.  Thanks for your help here.