• Ad.bayles
  • NEWBIE
  • 40 Points
  • Member since 2011

  • Chatter
    Feed
  • 1
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 13
    Replies
Hello guys,
Considering this use case :

I have a custom object linked to the Opportunity object via a lookup.

I want to embed a report on the custom object's page layout, in order for the report to show only records related to the same parent opportunity as the current record.

The "filtered by"  option makes me think it is possible, but it just does allow me to filter by the parent object.
User-added image

I have tested with various report types (with Opportunity as the master object of the report, my custom object,etc). And of course, I have included ID fields in my reports :-).

Does anyone have an idea on how to make it work ? Or is the only solution still to create a visualforce page ?

Everything is in the question :-)

I try to find a way to limit the cunsomption of the SF API by a user in my org. Does such a method exist in Apex ?

My Org has more than 100k leads and I need to make a SOQL query on the Lead Object.

 

My question is, if query on the standard email field, will I hit the governor limit ?

My query would look like :

for(Lead lid  : [SELECT email,OwnerId FROM Lead WHERE email != null AND email =:setLeadEmail     AND IsDeleted = false AND IsConverted = false ]

Hello guys,

 

I tried to write a trigger which will assign leads to existing account owner if any duplicate account, or contact owner, or lead owner.

 

I see that this trigger uses at least 3 sql queries ; How is it possible to reduce this ?

 

Here is my code below  :

 

trigger AutoAssignDupesOnLeadInsert on Lead (before insert) {


for ( Lead dupelead : Trigger.new){


for ( Integer i=0 ; i < Trigger.new.size(); i++){


for(Lead existinglead :[SELECT email, OwnerId FROM Lead WHERE email=:trigger.new[i].email AND IsDeleted = false ORDER BY CreatedDate DESC] ){
Id existingOwnerId3 = existinglead.OwnerId;
if(existinglead.email == dupelead.email){
dupelead.OwnerId = existingOwnerId3 ;
dupelead.status = 'Duplicate Lead Found';}
}
for(Contact existingctc :[SELECT email,OwnerId FROM Contact WHERE email=:trigger.new[i].email AND IsDeleted = false ORDER BY CreatedDate DESC]){
Id existingOwnerId2 = existingctc.OwnerId;
if(existingctc.email == dupelead.email){
dupelead.OwnerId = existingOwnerId2 ;
dupelead.status = 'Duplicate Contact Found';}
}
for(Account existingacct  :[SELECT Name,OwnerId FROM Account WHERE Name=:trigger.new[i].company AND IsDeleted = false ORDER BY CreatedDate DESC]){
Id existingOwnerId = existingacct.OwnerId;
if(existingacct.name == dupelead.company){
dupelead.OwnerId = existingOwnerId ;
dupelead.status = 'Duplicate Account Found';}
}

}}}

Hello all,

 

I am stuck somewhere when I try add button called "add Contacts" to a Custom Object directly from my CustomObject's detail page, with a Related List Button placed on the Contact.'s related list.

The lookup between Contacts and MyCustomObject exists.

I created a Button which behavior is 'display in existing window with sidebar' and Content Source is 'URL'.

 

The URL of my button is https://cs7.salesforce.com/_ui/common/data/LookupPage?lkpr={!MyCustomObject__c.Id}&lktp=003

 

My problem is that the search page that is displayed does not allow me to select contacts, as there is no checkbox on it.

 

 

Does anybody know the solution ?

Do I miss a parameter in the setting of the URL ?

Or do I need to create a custom VF Search Page ?

 

 

 

Hello all,

I rely on your help on this 'cause I am real noob in Apex code! My usecase is quite simple, but I can't get though it : I would like a child record to be created ("Registration")  on a lead insert or update.

 

This custom object is linked to another parent object, "Session".

 

Leads and Sessions are not directly linked to each other, but through the Registration object. This allows a many-to-many relationship between both parents.

On both parents I have a "Form ID" field, which is a numeric field (the value of this field is unique on the Session Object).

 

My point is that the Registration must be linked to the Session where the Form Id matches the Lead Form ID field, so I need to create a List that will check on all the Session records for that value

 

 

This is my trigger on lead :

 

trigger AutoCreateRegistration on Lead (before insert, before update) {
    List<Registration__c> createregistration = new List <Registration__c> {};
  


for (Lead lead : trigger.new) {

   if (lead.Lead_Source_2__c == 'Event' && lead.Form_Id__c != null)



createregistration.add(new Registration__c
(
 RecordTypeId = '012M00000000BHh',
 Session__c = '?',
 Lead__c = lead.Id

 ));

        }
    }

try {
insert createregistration ;
}
catch (Exception Ex)
{
system.debug(Ex);
}
}

 

 

 

Does anyone know how I can create a loop for this ?

Hello,

I am trying to write a simple apex trigger on Account, which will be fired on account update. The trigger will create an Entitlement.

This entitlement should be linked to an Entitlement process defined by default (always the same)

 

I don't get any error with this code, but the trigger does not create anything ^^

 

trigger CreateEntitlement on Account (after update) {

List<Entitlement> createentitlement = new List <Entitlement> {};

for (Account acc : trigger.new) {

if (acc.VAT__c == '1') /* If the Account custom field VAT__c = 1 */

{
createentitlement.add(new Entitlement (
Name = 'OK' /* Give a standard name*/
AccountId = acc.Id, /* Link the Entitlement to the account */
SlaProcessId = '552M00000004CAu' /* Link it to a defined entitlement process */
));
}
}
try {
insert createentitlement ;
}
catch (Exception Ex)
{
system.debug(Ex);
}
}



 

Any suggestion ?

How do you get the same URLs used in HTML templates, in VisualForce templates that are not directly linked to the Approval Process Object Type ?

 

When sending approval requests HTML format, you have the following merge fields :

{!ApprovalRequest.Internal_URL}

{!ApprovalRequest.External_URL}

..that allow you to send direct link to the approval page, additionally to any object-related merge fields.

 

In my VisualForce template, I use a Custom Object as 'relatedToType' Object, so as to display merge fields linked to this object and provide extra information to the assigned approver.

<messaging:emailTemplate subject="{relatedTo.Name"} pending request from {!relatedTo.Owner.Name}"
recipientType="User"
relatedToType="MyCustomObject__c">

 

I would like to use these URLs in my Visualforce template, but cannot find how to set the URL with the appropriate ID parameters.

Any thoughts ?

Hello guys,
Considering this use case :

I have a custom object linked to the Opportunity object via a lookup.

I want to embed a report on the custom object's page layout, in order for the report to show only records related to the same parent opportunity as the current record.

The "filtered by"  option makes me think it is possible, but it just does allow me to filter by the parent object.
User-added image

I have tested with various report types (with Opportunity as the master object of the report, my custom object,etc). And of course, I have included ID fields in my reports :-).

Does anyone have an idea on how to make it work ? Or is the only solution still to create a visualforce page ?
Hello guys,
Considering this use case :

I have a custom object linked to the Opportunity object via a lookup.

I want to embed a report on the custom object's page layout, in order for the report to show only records related to the same parent opportunity as the current record.

The "filtered by"  option makes me think it is possible, but it just does allow me to filter by the parent object.
User-added image

I have tested with various report types (with Opportunity as the master object of the report, my custom object,etc). And of course, I have included ID fields in my reports :-).

Does anyone have an idea on how to make it work ? Or is the only solution still to create a visualforce page ?

Everything is in the question :-)

I try to find a way to limit the cunsomption of the SF API by a user in my org. Does such a method exist in Apex ?

Hello guys,

 

I tried to write a trigger which will assign leads to existing account owner if any duplicate account, or contact owner, or lead owner.

 

I see that this trigger uses at least 3 sql queries ; How is it possible to reduce this ?

 

Here is my code below  :

 

trigger AutoAssignDupesOnLeadInsert on Lead (before insert) {


for ( Lead dupelead : Trigger.new){


for ( Integer i=0 ; i < Trigger.new.size(); i++){


for(Lead existinglead :[SELECT email, OwnerId FROM Lead WHERE email=:trigger.new[i].email AND IsDeleted = false ORDER BY CreatedDate DESC] ){
Id existingOwnerId3 = existinglead.OwnerId;
if(existinglead.email == dupelead.email){
dupelead.OwnerId = existingOwnerId3 ;
dupelead.status = 'Duplicate Lead Found';}
}
for(Contact existingctc :[SELECT email,OwnerId FROM Contact WHERE email=:trigger.new[i].email AND IsDeleted = false ORDER BY CreatedDate DESC]){
Id existingOwnerId2 = existingctc.OwnerId;
if(existingctc.email == dupelead.email){
dupelead.OwnerId = existingOwnerId2 ;
dupelead.status = 'Duplicate Contact Found';}
}
for(Account existingacct  :[SELECT Name,OwnerId FROM Account WHERE Name=:trigger.new[i].company AND IsDeleted = false ORDER BY CreatedDate DESC]){
Id existingOwnerId = existingacct.OwnerId;
if(existingacct.name == dupelead.company){
dupelead.OwnerId = existingOwnerId ;
dupelead.status = 'Duplicate Account Found';}
}

}}}

Hello,

I am trying to write a simple apex trigger on Account, which will be fired on account update. The trigger will create an Entitlement.

This entitlement should be linked to an Entitlement process defined by default (always the same)

 

I don't get any error with this code, but the trigger does not create anything ^^

 

trigger CreateEntitlement on Account (after update) {

List<Entitlement> createentitlement = new List <Entitlement> {};

for (Account acc : trigger.new) {

if (acc.VAT__c == '1') /* If the Account custom field VAT__c = 1 */

{
createentitlement.add(new Entitlement (
Name = 'OK' /* Give a standard name*/
AccountId = acc.Id, /* Link the Entitlement to the account */
SlaProcessId = '552M00000004CAu' /* Link it to a defined entitlement process */
));
}
}
try {
insert createentitlement ;
}
catch (Exception Ex)
{
system.debug(Ex);
}
}



 

Any suggestion ?

How do you get the same URLs used in HTML templates, in VisualForce templates that are not directly linked to the Approval Process Object Type ?

 

When sending approval requests HTML format, you have the following merge fields :

{!ApprovalRequest.Internal_URL}

{!ApprovalRequest.External_URL}

..that allow you to send direct link to the approval page, additionally to any object-related merge fields.

 

In my VisualForce template, I use a Custom Object as 'relatedToType' Object, so as to display merge fields linked to this object and provide extra information to the assigned approver.

<messaging:emailTemplate subject="{relatedTo.Name"} pending request from {!relatedTo.Owner.Name}"
recipientType="User"
relatedToType="MyCustomObject__c">

 

I would like to use these URLs in my Visualforce template, but cannot find how to set the URL with the appropriate ID parameters.

Any thoughts ?

Hello all,

 

I have this requirement where I need to set up more than 100 different lead assignment rules (assigning leads to users based on Lead Zip Code).

 

Wondering if there was any other simpler way to achieve this?

 

Thanks,

VK

  • July 05, 2011
  • Like
  • 0

We've enabled our entitlement module and we need to be able to auto-generate an entitlement id when a new account is created.  Does anyone know how this should be written, looks as if the only way to set this up would be through Apex. 

 

Currently our feed brings over external account information and if that account doesn't already exist, it creates a new account in Salesforce (ID field in the Accounts object).  Ideally we're trying to figure out how an associated entitlement id could be created with the Account ID, generating an entitlement object (Entitlement_c) with the same name as the Account name. 

 

If anyone has tried this approach or if more details are needed, please let me know.

 

I tried to test sending mass emails using following test code

sited form Visualforce Manual.

But failed to have received an error message.

Any suggestion appreciated.

In case of sending a singlemassage test,it was OK.

 

 Error Message:-

       System.EmailException:
       SendEmail failed. First exception on row 0;
       first error: INVALID_ID_FIELD,
       Visualforce templates are not currently supported for mass email.: []

 

 Test Code:-

    User you = [ SELECT Email
             FROM User
             WHERE Id = :UserInfo.getUserId()
             LIMIT 1 ];
    EmailTemplate template = [ SELECT Id
                           FROM EmailTemplate
                           WHERE DeveloperName = 'Test_Template'
                             LIMIT 1 ];
     Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage();
     mail.templateId = template.Id;
    mail.targetObjectIds = new Id[] { you.Id };
    mail.setSaveAsActivity(false);
     Messaging.sendEmail(new Messaging.MassEmailMessage[] { mail });

 

  • April 04, 2010
  • Like
  • 0
We all have a limit to send email from Salesforce.com, i.e 500 emails for Enterprise Edition.

Here my query is, is this only for mass emails or counted for single email sent from “Send An Email” from Contact /other objects?
What about workflow email alerts – this is also countable against the per day limit.?

Please clarify.

I just want to create a simple VF page that includes logic to message a salesperson when the Opp Stage = Won. The messaging works fine, but when I rerender the pageblock based on a stage update, the forecast category and probability do not update along with the stage. This doesn't make sense to me, I'm using the standard opp controller, and the stage is tied to the forecast category and probabily.

 

Does anyone know why the forecastcategoryname field and probability field would not update on a visualforce page when the stageName field is updated, and rerenders the pageblock?

 

<apex:page standardController="Opportunity" sidebar="false" extensions="OppWonExtension"> <apex:sectionHeader title="Edit Opportunity" subtitle="{!opportunity.name}"/> The opportunity amount is the sum of the related products. To edit the total amount, you must first delete all of the products from the opportunity. <apex:form > <apex:pageBlock title="Edit Opportunity" id="PageBlock1" mode="edit"> <apex:pageMessages /> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> <apex:actionRegion > <apex:pagemessage severity="confirm" strength="3" summary="{!DealsheetMessage}" rendered="{!DealsheetMessage != ''}"> </apex:pagemessage> <apex:pageBlockSection title="Opportunity Information" columns="2" id="OppInfo"> <apex:inputField value="{!opportunity.name}"/> <apex:pageBlockSectionItem > <apex:outputLabel value="Stage"/> <apex:outputPanel > <apex:inputField value="{!opportunity.stageName}"> <apex:actionSupport event="onchange" rerender="PageBlock1" status="status"/> </apex:inputField> <apex:actionStatus startText="applying value..." id="status"/> </apex:outputPanel> </apex:pageBlockSectionItem> <apex:inputField value="{!opportunity.account.name}"/> <apex:inputField value="{!Was_This_Revised__c}"/> <apex:inputField value="{!opportunity.CLA_Type__c}"/> <apex:inputField value="{!opportunity.type}"/> <apex:inputField value="{!opportunity.Parent_Opportunity__c}"/> <apex:inputField value="{!opportunity.House__c}"/> <apex:inputField value="{!opportunity.closedate}"/> <apex:inputField value="{!opportunity.probability}"/> <apex:inputField value="{!opportunity.forecastcategoryname}"/> <apex:inputField value="{!opportunity.amount}"/> </apex:pageBlockSection> </apex:actionRegion> </apex:pageBlock> </apex:form> </apex:page>

 

Message Edited by SteveOC on 04-21-2009 04:04 PM
Message Edited by SteveOC on 04-22-2009 01:49 PM
Message Edited by SteveOC on 04-22-2009 04:44 PM
Message Edited by SteveOC on 04-22-2009 04:45 PM
Message Edited by SteveOC on 04-22-2009 04:45 PM
Message Edited by SteveOC on 04-22-2009 04:46 PM
Message Edited by SteveOC on 04-23-2009 09:41 AM
Message Edited by SteveOC on 04-23-2009 09:41 AM
I have a small problem. I have a requirement to display DAY of the week in the application. For : ex SUN, TUE, SAT...etc. Is there a way to extract this from the date field. Please help.