Select relational values (many to many) while creating new Account - salesforce

I have a custom object call location and I would like to add an association (many to many) with Account object.
One account can have more than one locations.
I did create a junction object and manage to create many to many relations between account and sales area.
But my question is how can I select the location(s) while creating the new account.

you you are using SF classic, then create VF page and override standard view page with your custom VF page. In this page develop controller that will allow to select location and will create junction object with ids of Account and Location
if you are using lightning experience, then you can develop lightning component and simply add it to Account record page. Server-side controller should have the same functionality as for classic-style version.

Related

Dynamics CRM - Add companies that not exists when importing contacts

I'm migrating a customer CRM database to Dynamics CRM. It's about accounts, contacts, and activities. Unfortunately, the previous CRM was not really well used so the data are a bit confused:
While creating a contact, you have a field "Company" that is a "look up" field as we can find in Dynamics. But, if you write something in there and you don't look up for the company entity, the value entered becomes just a value of the field "COMPANY" in the "CONTACT" record.
That's why I have some contacts that are not really associated with companies.
In Dynamics, I'm using the Import Wizard to imports those entities. Is there a way to add the contact's company if it not already exists while importing contacts?
You need to handle this during the Create – by a plugin with a step, or by a workflow. Both works similarly to DB trigger. Plugin is basically .dll written in C#, running in a sandbox, using some of MS libraries. It is registered by external utility. Workflow is something you can do without programming right in the CRM UI. It is easier do deploy, but it has less possibilities. You can find enough information about both online.
I would recommend following process:
Create temporary custom text field on a Contact entity to store account name as a text.
Before the import, in the import file, create a copy of account column with another name.
One account column should be linked to account lookup (parent customer). This is for automatic joining contact and account. The other column is linked to the created field.
Your routine (workflow or plugin) to process this will have following condition to proceed: If account lookup is empty. Then you will create a new account by using information from Contact (mainly account name) and then associate the account and contact (update of the contact record). Optionally erase account text field on the Contact.
At the end, you should deactivate or remove the routine. If you’d use it more often, you need some condition to recognize records are created by import.

User Management in Web Application ( Angularjs, spring, hibernate )

Logical Question
Backend implementation
I am implementing User Management Module in Web application. I have three table User, Role and UserInterce. The user table has ManyToMany relationship with role table and Role table has ManyToMany relationship with User Interface table. So whenever Server return user object, the system will verify it's role and that role has access right to which user interface.
this is background overview of backend implementation.
Front End implementation
Whenever user login into the system,server will return user object. I want to implement access control in form basis. e.g. emp role do not have access right to add button where admin role has access right to add button. To implement form based access control i would require to create another table at server side which has information about ui fields and that will be has relationshiop with User Interface table.
can some one provide better way of doing same thing logically ?
If you don't need to have possibility to edditing role's permissions in runtime, the best way is to use spring JSP tag library and build your frontend using spring security tags
http://docs.spring.io/spring-security/site/docs/3.0.x/reference/taglibs.html
Otherwise, using some table for storing your permisssions is the only option to do that

CakePHP filter queries by user's business accounts

I'm new to CakePHP 2.4 and trying to understand conceptually if I'm on the right track before I start building the following.
By default, when a User first logs in to his online account, he sees Orders, Invoices, and Documents for ALL ACCOUNTS that he has access to. Using an Account dropdown and the button "Go", he can filter Orders, Invoices, and Documents for only ONE ACCOUNT.
Currently, pre-CakePHP, this is all handled in query logic. The User-Account (N:N) relationship is in the database. Any active Account_Id is stored in the SESSION. What is the CakePHP to do this?
The Model looks like:
User hasAndBelongsToMany Accounts
Account hasMany Orders
Account hasMany Invoices
Account hasMany Documents
1.) Should I code the relationship between Users and Accounts in a Model (hasAndBelongsToMany) or in the ACL/Auth component (User is ARO, Account is ACO)?
2.) To show ALL ACCOUNTS, what is the best way to "query for" this filter and apply it to each Model. Or is that done automatically by the Model?... or by ACL/Auth?
3.) To show ONE ACCOUNT, is storing an Id in the Session still the best approach? ...or should I be thinking about a new set of actions in each of the Orders, Invoices, and Documents Controllers?
I will support you with set of links to CakePHP cookbook which clarifies all your queries:
First of all you should read about linking models.
Next thing is creating correct database and tables in there following CakePHP conventions
Another step is "baking" your models/controllers/ views
After that step all you need to do is just play arround with data you get from your models
To be honest you dont have to code any relations at all if you just correctly create your database with corect foreing key names which Cake will detect and build relations through interactive shell (you will be asked if you want console to create relation for you through cake bake ).
$this->ModelName->find('all')
will give you all data of given ModelName and also all related data,
using
$this->ModelName->recursive=-1
will make your model to retrive only data from ModelName without any related data.
In practice some things will probably work for you out of the box but some of things you will have to simply implement. Hope that helps.

External Ids in Salesforce

How do I create an External Id on objects like Profile (for which isCreatable is false). I have to create External Id on Profile for upsert operation, but I am not able to create it.
Is there any work around for this? Or Can we ask salesforce to allow us to create external ids.
Any links or references would be useful!!
Follow up of Create new Profile Object in salesforce?
You can't create external Ids on the metadata components (Profiles, classes, visualforce pages, custom fields). Most of the time they're guarded by having Name or DeveloperName unique. (with addition of namespace but let's ignore managed packages for now)
Profile object doesn't support create but similarly it doesn't support upsert ;) Compare http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_account.htm and http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_profile.htm
I don't understand what exactly are you trying to achieve?

CakePHP ACL use case(s)

I have got a simple web app in development, i want to establish a couple of user groups; Admin, Doctors & Patients.
Each group would have their access restricted to particular controller actions rather than individual content. So for example, Doctors can view patient records (index & view actions), but cannot delete them.
Usually i would create a groups model, and assign the various users to a group. And filter in the beforeFilter() method to determine if the user has access. But if ACL can do the job, why right the code, right?
Thanks
You do not need to filter in the beforeFilter() method to determine if the user has access but you need to provide configuration to Auth component there. Follow Simple Acl controlled Application from tutorial (Setting up permissions).

Resources