Restrict access to values based on profile - salesforce

I have a field which is a picklist. I want to restrict access to the values in this field based on profile so that certain profiles can only see eg. only 3 values out of 10. others could see 5.

To restrict picklist values, you would need to create separate record types for the object and assign them to your different profiles. You can then edit the available values within the record types on the object.

Related

Schema to store/generate dynamic messages with placeholder

I am creating an application to display the notification like facebook. I have database schema to save the user-specific notification. The notification message contains the placeholders. E.g. Suppose we have below notification messages (Calling it Notification Template):
{FrinedName} like your photo.
{FriendName} like your page {PageName}.
{FrinedName} posted a message in {groupName}.
It's {friendName} birthday today.
{FriendName} and {#count} likes your photo
So here the text inside {} represents placeholder and the value of these placeholders need to be replaced at the runtime.
Now I want to keep these placeholders and their value source in database tables.
The Value of different placeholders may refer to the different columns in different tables. (E.g. the value of {FriendName} may belong to the User tables LoginName column, value of {PageName} will refer to Pages table's Name column and the value of {groupname} placeholder refer to the the Groups tables Name column).
So, I would like to get the data dynamically for the placeholders. What is the best way to store such type of data in the database (something like below).
dbo.NotificationTemplates - Table to store all the notification templates
dbo.TemplatePlaceholders - Table to store the placeholders in the template
dbo.TemplatePlaceholdersMapping - Table to store the mapping of placeholders in a template.
dbo.PlaceholderValueProvider - table to store the placeholder's value source, i.e. from where to get the value for placeholder.
My suggestion is to use scalar function, you can have multiple conditions in scalar function and at the end, return your result in one column

Could one field be added to different record types?

I would like to know if one field could be added to multiple record type ?
Do I need a trigger for this or is it something related to salesforce record type system?
Record types are used for different business processes to use different pagelayouts and picklist values. There is nothing to worry about fields as they are independent from recordtypes.

Restricting user from chosing a value in picklist

I am having a requirement in the sales force where the user has to chose values from picklist.But the twist is the user has to select first received and then only it has to allow user to select recived.Can anyone tell me how to achieve this functionality.
Go to Setup | Customize for Standard Objects or Create for Custom
Objects | Click on Record types Then select the record type that you
need to change You'll see a section Picklists Available for Editing
You can specify which values should appear for the record type

Salesforce - Can I have a lookup field on two different object types?

My client requested to have a field that can be a lookup on either contacts or users.
I know that Salesforce does something like this in some standard objects. For instance, the Task objects has fields "who" (lookup on account or contact) and "what" (lookup on case, opportunity, and more stuff). Also, I know the Owner field on Case can reference either a User or a Queue.
Can I make custom fields that look up on more than one kind of object?
You can't create a custom lookup field that references multiple types. You would have to create 2 different fields.

Create multiselect lookup in salesforce using apex

I want to create a multi-select Contact Lookup.
What i want :
When user clicks on a lookup then he should be able to select multiple contacts from that.
What i have done:
I have created an object and a field inside that object using both
"Lookup" and
"MasterDetail Relationship" and
"Junction Object"
When i try to use this Field for any input text/Field then it always provides an option to select only one value from lookup but i want to have an option to select multiple.
Even in the Junction object i have created 2 master-detail relationships still lookup allows only one value to be selected.Moreover it makes the field mandatory which i don't want.
Links that i followed:
http://success.salesforce.com/questionDetail?qId=a1X30000000Hl5dEAC
https://ap1.salesforce.com/help/doc/user_ed.jsp?loc=help&section=help&hash=topic-title&target=relationships_manytomany.htm
Can anybody suggest me how to do this.
Its same as we use Email CC/BCC under Send Email option for any Lead.
Even you use a junction object a lookup is just that, it references (looks up to) one other record: when you create a record on the junction object you still have to set each lookup individually and you're still creating only one record.
Master Detail relationships are essentially lookups on steroids, one object becomes the child of the other and will be deleted if the parent object is deleted, they're not going to provide an interface to lookup to many records at once.
If you're not a developer then your best bet is to either just create on junction object record at a time, or look into using dataloader. You could prepare your data in Excel or similar and then upload all the records into Salesforce in one go.
If you are a developer, or have developers at your disposal, then what we've done in the past is create a Visualforce page to do the job. So if, for example, you wanted to link a bunch of contacts up to an Account, we'd have a single account lookup field on the page, then some search fields relating to fields on the contact. Using a SOQL query you can then find all contacts matching the search parameters and display them in a list, where you may want to provide checkboxes to allow the user to select the contacts they want. Then it's just a case of looping through the selected contacts, setting their Account field to be the chosen account.
There are areas in Salesforce (such as the send Email functionality you mentioned) where it's clear to see that bespoke work has been done to fulfil a specific task — another instance of what you want is in the area where you can manage campaign members. This is the model I've copied in the past when implementing a Visualforce page as described.
Good luck!
For adding multiple junction objects at one time, the only solution we have found is a custom Visualforce page, as described by LaceySnr.
For a slightly different problem, where we need to assign many of object B to object A, We have trained our users to do this with a view on object B. We are assigning Billing Accounts (B) to Payment Offices (A). The view on Billing Account has check boxes on the left side. The user checks the Billing Accounts to be assigned, then double-clicks on the Payment Office field on any of the checked rows. A pop-up asks if you want to update only the single row or all checked rows. By selecting 'all checked rows', the update is done to all of them.
The view is created by the user, who enters the selection criteria (name, address, state, etc.). All user-created views are visible only to them.

Resources