Assign New Leads of Existing Accounts to Account Owner - triggers

Salesforce - Apex Trigger for New Leads for Existing Accounts. How?
Hello,
I would like to write an Apex Trigger to check if a new lead's COMPANY or NAME already exists as an ACCOUNT, and therefore assign the new lead to the proper ACCOUNT OWNER.
Is there a formula that anyone can provide me to make this happen?
It would be great if the formula would look for CONTAINS "ACCOUNT NAME" rather than a direct match, for cases where a new lead submits their company name in a format slightly different than our existing ACCOUNT NAME.
Thank you greatly for your help.

I don't think this can be done with just a formula. You will need a trigger, preferably one that calls an apex class to do the work. The class will have to be without sharing if you want to reassign the owner id. You'll have to query account for this.

I don't know if anyone is still following this thread, but a client recently asked me for something similar. The client wanted new Leads to be assigned to the same Owner as an existing Contact with a matching email address. Standard Salesforce Lead Assignment Rules didn't support this, so I implemented it using Process Builder and Visual Workflow. There was no need to write Apex code.
It was straightforward and reasonably quick to do, so I put together a blog post outlining the steps. Hopefully someone will find this useful in future.
https://alearningdiary.com/2017/11/12/assign-a-lead-in-salesforce-based-on-existing-contact-owner/
Brian

Related

Getting all related Contact for an Account entity in Dynamics 365 CRM v9.0 web api

Basically, I'm querying the D365 web API and I'm trying to get all of the related contacts for an account.
Been following this link:
https://learn.microsoft.com/en-us/dynamics365/customer-engagement/developer/webapi/query-data-web-api#retrieve-related-entities-by-expanding-navigation-properties
Trying to use $expand but it only will bring over _primarycontactid_value. So just the one primary contact and not everyone that is related to the Account.
It would look something like the following:
/api/data/v9.0/accounts&?select=name&$expand=Contacts(fullname, email)
The only fields in Account that have "contact" in them are:
preferredcontactmethodcode
_primarycontactid_value
address2_primarycontactname
address1_primarycontactname
_tcc_primaryinvoicecontactid_value
_tcc_consultingcontact_value
_tcc_contactlist_value //some custom field that doesn't apparently do anything
_new_foundationcontact_value
_tcc_primaryapcontactid_value
So none of which can be used to look-up all of the contacts... that I know of.
Another way to do it would be to start with the Contact first and then $expand= on the _parentcustomerid_value. But I need to filter on the Account to specify certain accounts that I want... this would just bring over every account and be incredibly slow. I'm not sure there is a way to $filter= on an $expand= value.
So:
How can I query the Account and all the related to Contacts for an Account?
If there is no way, is it possible to use $filter= on and $expand= value?
Trying to keep the amount of queries to a minimum. This could be solved by doing multiple iterative queries, but that will just make it incredibly slow. Or just query everything and piece it together, but that will be slow as well.
Ok, stumbled across the answer: contact_customer_accounts.
Query ends up looking like the following: /api/data/v9.0/accounts&?select=name&$expand=contact_customer_accounts($select=fullname).
As far as I can tell, custom relationships can be used as well, although I have only tested with 1:N types.
Still takes a little while to generate, but works.

How do I set Outlook extended properties on an email in C#?

I have currently written code to send an email in C# using the usual SMTPClient and MailMessage objects.
My new requirement is that the email being sent should have "permissions" set as if the user was sending the email via Outloook and using the option from the ribbon toolbar. The permission to be set is the "Do Not Forward" option.
The option I wish to emulate when sending the email is accessed here;
Can anyone please supply some sample .Net code to achieve this or else provide me with a good code reference online?
Thanks in advance,
Brian.
First of all, I am unaware as to how one might be able to set IRM (Information Rights Management) permissions using only a standard SMTP message (MailMessage). IRM permissions, I believe, are completely Outlook/Exchange-centric, and lack any sort of representation in the SMTP standard.
The only way you're going to be able to enable that permission is through the Outlook Object Model via the Outlook Interop assemblies. IamStalker above me recommended Redemption, which, while 99% of the time is the correct answer for everything Outlook-related, is not the way to go for this particular problem. Because IRM (as far as I know) has no representation in MAPI, Redemption wouldn't be much help here; I don't believe I've ever seen an IRM-related property on Redemption's object model.
You'll most likely be interested in the Permission property exposed by the MailItem object type. It appears that in order to programmatically turn on the "Do Not Forward" option, you will want to set the value of that property to OlPermission.olDoNotForward.
There is another IRM-related property (PermissionTemplateGuid), but it appears that you can leave this as an empty string since you are using a built-in "permission".
I would assume then that all other IRM-related settings are provided to Outlook through the user's Outlook profile.
Good luck!
Hello Brian I have only one suggestion "Redemption"!
I have used it and it's awesome it's very easy to implement the owner Dima is very nice person
he helps alot.
PS: It's not free but worth every penny.

Method to allow email recipients to change their account information

I'm using SugarCRM Community Edition. I have a bunch of contact information. There are fields I have empty that would like filled. I want each user to be able to fill out a form and fill in those fields.
I'm not sure how to hook each contact into the database. I imagine creating a generic form that somehow hooks into the database using a key. The form/php is not the issue. What is the 'key' and where is the 'door'? I think the door is the SOAP API but I'm not sure. The key, maybe the tracker id?
The only thing I am familiar with as far as interaction between an email campaign and the contact is the campaign 'Tracker'. I know the tracker url with removeme is used for allowing the user to opt out of emails. Is there a way to use this tracker to allow the person to edit their information? I think the answer to this is easy but I need some guidance.
One way of doing this is using the built-in REST api. There are a couple of helpful tutorials out there, here is a link to the one I used for guidance in a similar situation.
You can have a form post the data to your sugar crm's REST gateway, accessible via the url http://localhost/sugar/v2/rest.php.
Although it is quite straightforward to implement, you may want to look at this wrapper class that can be used to maybe keep things cleaner than the hacked up script churned out on the spur of the moment I used in my project.
Last but not least, be sure to glance over the documentation, in the Web Services section you will find more information.
Good-luck

Is it possible to write t-sql script to show all changes made to the database rows recently?

I'm learning a new product of my company and the database is huge.
What I'm doing is to learn feature by feature and through that to understand the codes and the associated database's data/functions/ect.
What I need: To see the change-set made to the database/data-rows recently, e.g. after I create a new user account, I want to see what are the new rows updated/created after I do that.
Is it possible? Please share if it is. Thank you!
Nam.
I would set up a trace with the SQL Server Profiler. In the trace you can see what the client does when you create a new user.

Jira RPC/SOAP GetCustomFields() can only be used by an administrator?

I'm currently using the Jira SOAP interface within a C# (I suppose the language used here isn't terribly important).
Basically, I'm creating an API and a Winform that wraps some of the functionality of the soap service so that our Devs can programmaticly add bugs when something goes wrong in our application.
As part of this, I need to know the custom field IDs that are in use in Jira, rather than hardcoding them (as they are still prone to the occasional change) I used the GetCustomFields() method in the jira-rpc api then filtered it, so that all the developer needs to know is the name of the field, then the ID is filled in for them automagically.
This all works fine, but with one quite important proviso: that you login to the SOAP/RPC service as a user with administrative privaliges.
The Jira documentation indicates that the soap/rpc service follows the usual workflows and security schemes, however I can't find anything anywhere that would appear to remove this restriction on enumerating custom fields (and quite why in any instance you would want someone to HAVE to be an administrator to gain this access, especially as the custom field id's tend to be in Jira's HTML source is beyond me)
Does anyone know if I've missed a setting somewhere? Or if there is some sort of work-around for this, short of hardcoding the custom field id's?
Or is this a case of having to delve in to Jira's RPC plugin and modifying the source for it in order to give me the functionality I require?
Cheers
Edit for the sake of google/posterity
Wow, all this time on, and it looks like Atlassian still haven't changed this behavior.
Worked around this by creating a custom dictionary that logs in as an administrative user, grabs the custom fields and then logs out. Not ideal, but it should work 'til atlassian change things
You're not missing anything - there's no way to get custom fields via standard SOAP API.
In JIRA Client, we learn about custom fields in two ways:
We download issues via RSS view of the issue navigator, or via XML representation of a specific issue. If a custom field is set for an issue, the XML will have its id, class and value (values).
From time to time we inspect the content of IssueNavigator search page - looking for searchers for the custom fields. Screen-scraping the HTML gives us not only ids of the custom fields but also possible values for enum fields.
This is hackery, of course, and it may go wrong, so a good API would have been a lot better.
In your case, I can suggest two solutions:
Create your own SOAP (or REST) remote API plugin that will give you just that info that you miss from the standard API. Since you're seemingly in control of your JIRA, you can install anything there.
Screen-scrape the "New Bug" page for the project and type of issue you need to submit. You'll get all the info - fields, options, default values, which field is required.