Salesforce Lead Allocation based on Region - salesforce

My requirement is to automatically assign a Lead to Sales Representative based on Region.
A region is made of many countries. I want Salesforce to identify the region based on the country and assign the lead to Sales Representative accordingly.
How can I achieve this?

You will need to write a Trigger or workflow to stamp Region on a field (A custom field created) on Lead Record .
Write Assignment rules based on Region to assign these leads as per Region.
For Trigger you can create a Region Object and have child objects Country linked to Same .Or other way could be use custom setting and store for regions different countries that belong to Region.

Related

Google Data Studio - Is it possible to filter across data sources

I have seen the link below which explains that it is possible to create a filter on one field between sources by generating a calculated field and then assigning the same field ID to both fields for filtering purposes:
Using the same filter control for two different data sources
But my question is whether or not it is possible to make that particular field (that is now shared between 2 data sources) dependent on other filters that are tied to 1 of the data sources?
Example would be:
One dataset with country name and city name
One dataset with city name and population
I've generated a calculated field to be able to filter on city name since they now share the same field_id.
What I'd like to do is use a control that selects country from dataset 1 and then automatically filters city_name in both datasets.
I realize I could just pull country name into my dataset in the example above, but in my real dataset there are a significant number of fields I'd be looking to be able to use for filters.
If a filter is set, all charts and filters are updated with that setting. However, it would be a huge mess, if any of these objects would automatically changes the filters again. Then all object would be updated again and the filter setting could be changed once more, thus ending up in an infinity loop.
Therefore, a filter can only apply to a field. If this should cause further filtering an user action is needed. It would be possible to write a customer vizualisation, which would mimic an user action, but again it could end in an infinity loop.

Salesforce Lookup Object Relationships

I have a number of objects that contains references to other objects in Salesforce. An example is that a Shipping is the parent object related to ShippingItem by the shippingId. In order to save ShippingItems I need to get the ShippingId of the Shipping object. Also, the ShippingItems are related to ShippingMethod object which contains the shipping methods, UPS, FEDEX etc. This is a picklist type that allows users to pick the shipping method. In order to create/save the ShippingItem. I need to obtain all the related fields, i.e. ShippingMethod i.e UPS, ShippingId to which it is related and other similar information. How can I obtain these fields in order to save the ShippingItems? When I inspect the Objects, I am unable to determine the fields to query in order to obtain the related information.
Please help
If I understood this correctly, ShippingItem has a lookup to Shipping and a lookup to ShippingMethod. Are you providing a UI where people create ShippingItems? If yes then ShippingID and ShippingMethodID should be populated on the shipping record when you get the record back in controller.
If your question is how to provide a list of ShippingMethod records on the UI for users to select, you can query the object records separately and create a picklist for the user to choose.
Adding a little more information or code snippet will help you get better answers.

CakePHP - Behaviours/Behaviors - Advice on creating custom behaviour

I read up on behaviours and thought it might suit my simple requirements but i don't know how to get started in terms of creating a custom behaviour.
Scenario:
I have a master table called Companies. This table has a "hasMany" relationship to detail tables BusinessDescriptions and Addresses. Of course, these detail tables are linked to the Companies table by a foreign key.
Despite the "hasMany" relationship, only one record in these detail tables can be valid on any particular day. Hence in the detail tables for BusinessDescriptions and Addresses, I have fields "Startdate" and "Enddate" which tell you what time period the records are valid for.
Example use: Company X will have a new address from 01.01.2015. Hence when inserting the new address, its old address record which is valid from Startdate 01.01.2014 to Enddate 31.12.9999, needs to have its Enddate changed to 31.12.2014, to make way for the new record that starts from 01.01.2015.
All this "auto-delimitation/adjustment" of start/end dates of existing records, I wish to put into a behaviour, however tutorials on getting a custom behavior up and running are hard to find.
Can anyone point out to me how to start, or maybe show me skeletal structure of creating a behaviour for this?
I don't see a need for a Behavior on this one. Behaviors are for when you need to utilize logic across multiple Models - in this case, it seems you only need it on one model.
You might just use the beforeFind() callback in your Company model. It in, you can append the conditions for the date(s) you want to restrict by.
If you really want to make a behavior, you could put that beforeFind() into one, and utilize it any time you want said model to restrict based on the current date...etc.
On a side note, why not just retrieve the most recent address for that company? Order by the date DESC, and limit 1 ?

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.

What is a good way to model city, regions and postcodes?

I am thinking about the "best" way to model city, region, postcodes for usage in different countries. (Application should be used in different languages)
My first guess is:
class City {
String name
String region
static hasMany = [postcodes:PostCode]
static belongsTo = [region:Region]
static constraints = {
name size:2..100
region nullable:true
}
}
Now the questions are:
Can one city belong to more than one region? (States/Bundesländer/Communities/...)
As all of this is final, no new cities, regions or postCodes I thought about not using the database and put it into enums!?
As I want to separate data for different countries I have to add this to a city. I took a look at multiTenant-plugin but I am not quite sure if this isn't to much!?
Probably someone has dealt with this before and can share some insights.
Thanks a lot
Sebastian
Can one city belong to more than one
region?
(States/Bundesländer/Communities/...)
That depends on you. You haven't explicitly stated what a region is. A region could be the suburbs of x city or Western Europe depending on how you define it. If a region isn't defined by state boundaries, then it's possible that a city can belong to more than one region. For example, "Paris" could be contained in the "France" region as well as the "Western Europe" region.
A simple solution would be to limit regions to state boundaries, but that might not be a good solution depending on what you need the data for. You could create an array of strings to store your regions, but it's difficult to pick an alternative if you don't say what the data is needed for. Based off of what you've written, I think a separate "String country" would be appropriate since you can then sort by country, and your regions can remain as they are.
As all of this is final, no new
cities, regions or postCodes I thought
about not using the database and put
it into enums!?
You could do that, but it's much easier to manage in a DB.
As I want to separate data for
different countries I have to add this
to a city. I took a look at
multiTenant-plugin but I am not quite
sure if this isn't to much!?
I'm haven't used the plugin so I can't help you there, but if you just want to separate data by country, then adding a country field and sorting would be pretty straightforward.

Resources