Auto Populate the Opportunity Owner name into custom text field - salesforce

I am trying to auto populate the Opportunity Owner name in to custom field(Manger) on the same page. But when i am trying it's getting only Id but not Owner Name. This logic i am implementing using Flow in the process builder. Can some one help on this.
In the flow i am using 'Record Lookup'(getting OwnerId and passing to Temp variable), Record Update(Assigning the temp variable to Custom field). But not luck.

Not sure why you would not want the Id. I personally would use the Owner field as a basis and just create a formula field called Manager with this formula: Owner.Name
If you still insist on getting the Owner Name from the flow, you would have to do a SOQL Select in the flow to search and save the Name first.

Related

Salesforce Lightning Flow Builder lookup Error

I am trying to build a Flow to create records for contacts. I am going to create a button off of Accounts on the related list of Contacts.
Step 2 is where I am having an issue
1.) I created a Get Records - which gets the ID of accounts.
2.) I created a Screen:
I have a lookup field that I want to be defaulted to the parent.
I have the FieldAPIName as AccountID which is a Varialble I created that is stored from Step 1.
Label : Entity Name
Object API Name : Account
When I run the program I get the following error:
Looks like you don't have access to this field, or the object or field API name is not valid on this Lookup component. Contact your Salesforce admin for help.
Your source object is Contact and the field is AccountId.

Salesforce validations

I'm new in Salesforce and I have to create an app for gym owner.
I made 3 objects, Member, Membership and Booking. My member object has data about gym members like address, date of birth etc.
Membership object has fields like MEMBER(lookup relationship with Member object), START DATA, END DATE and ACTIVE (checkbox to see if membership is stil active).
If membership of that member is still active, I have to prevent customer to create another membership for that member until current expires. How can I do that?
You could pull something like that with validation rule using VLOOKUP function (but then you need to always put something fairly unique & predictable in the Name field on your membership object). I'm thinking something along the lines of "if there exists membership 'Member #1234 active' then VLOOKUP should prevent creating another one like that".
A nasty user could then delete the membership, create new one and restore it from recycle bin :P
So I have better idea for you (still without using any code). Convert membership->member lookup to master-detail relation. This would let you create rollup summary fields, read up about them. Create a rollup field that would be COUNT() of active memberships for the guy. Make validation rule that throws tantrum when you insert new membership and the count is already > 0.

How to associate a custom object record to a user account

In force.com I have created a custom object named Sales_Agents. Is there a way to specify that the users I relate here are associated to an real force.com ID ? For instance, how do I create a lookup to a real user under my tenancy account ?
You can make a custom Lookup field on the Sales_Agents object that relates to the User object. You cannot however make a custom Lookup field on the User object that relates to the Sales_Agents object.
This is a platform limitation. There is an idea on the IdeaExchange that you can vote up, but I would not count on it being available any time soon.
Here is how to add a Lookup field to your custom object:
Setup -> Create -> Objects
Select Sales_Agents
In the Custom Fields & Relationships section click New
Select Lookup Relationship and click Next
Select User and click Next
Complete all steps in the new field wizard and click Save

How do i get a list of users whose roles have first 5 characters are sales

I need to get a list of users whose role has the first 5 char as 'Sales'
I want to use this on a apex class
My first thought was to use something like this
select id from user where UserRoleId__r like 'Sales%'
But this throws an error
No such column 'UserRoleId__r' on entity 'User'.
Do i need to query the role object to get all ids and then query the user object using those ids?
is there a better way of doing this?
Thanks
You need to fix the name of the User Role column in your search. Here's is the correct syntax:
select id from user where userrole.name like 'Sales%'
You only need to append the __r suffix to relationships in queries when the object is custom. For built in objects, you only need the name of the object (no __r).

Granting access of specific user to specific (multiple) docs

I'm building a small project with database. I have a user table which has two columns, user_id and name, The second table stores the id and name of some documents: it also has two columns doc_id and doc_name. I want to grant access of specific user to specific (multiple) docs.
For example:
user1 can access doc_2 and doc_3 Only.
user2 can access doc_1 and doc_2 Only and so on.
Users and forms keep changing (eg. after some time i need to add a new doc, and add access to existing or new user to that new doc).
Do i need to change database design? (for example add a column in docs to store name of each user who can access it? ) If this is so, can you tell me what changes i should do?
OR
Is it possible to do by creating views? In this case, do i still need to change the database design? If this is the case, can you tell me an example view please? In this case, will i need to create view for each user? For example if there are 100 users, i will need to create 100 views?
You need a third table (I'll call it user_doc). You need 2 main columns; user_id and doc_id.
You then insert one row for each document and user combo that has access permissions.
If their user_id doesn't appear in the user_doc table with the relvelant doc_id, they don't have permission.
A sample query to get a list of all docs a specific user has access to:
SELECT doc_id FROM user_doc WHERE user_id = #UserId
or to find all users with access to a specific doc:
SELECT user_id FROM user_doc WHERE doc_id = #DocId
You need to have a PERMISSIONS table with relationship between Users & Documents. The columns could be PERMISSIONS_ID,USER_ID (Refer User), DOC_ID (Refer Document). Every time access has to be given to a user for a document this table needs to be populated.

Resources