• S_Batman
  • NEWBIE
  • 95 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 21
    Questions
  • 41
    Replies
trigger Limit1000AccountsForUsers on Account (after insert, after update)
{Account accs = Trigger.new[0];
string accountOwner = accs.OwnerId;

If(accs.Protected_Accounts__c == true){Integer accounts = [ SELECT COUNT()FROM Account WHERE Account.OwnerId=: accountOwner]; 
system.debug(accounts);

If(accounts > 2 ) {accs.addError('You already have 1000 Accounts in your ownership. Please remove one Account before adding a new.');
}
}
}

We have the following code to limit number of Protected Accounts to 1000 per user.  I have one user that has 950 Protected Accounts and 50 unprotected Accounts.  When I try to add another protected Account I am getting the error 'You already have 1000 Accounts in your ownership. Please remove one Account before adding a new.'.

I only want this error to occur when a user tries to add over 1000 Protected Accounts.

Is there something missing within the Apex?
I have a custom number field on the Contact level (let's call it ABC), and I want to create a Field on the Account to show the total of all the ABC fields from all related Contacts to an Account.  Can this be done without triggers?

I am trying to Limit the number of Protected Accounts a User should have under their ownership.  This is the trigger I created with the help of the SFDC Community 

trigger Limit1000AccountsForUsers on Account (before insert, before update) {
    Account accs = Trigger.new[0];

    if (accs.Protected_Accounts__c == true) {
        Integer accounts = [ SELECT COUNT()FROM Account WHERE Account.OwnerId = : userInfo.getUserId()]; 
        system.debug(accounts);

        if (accounts >3 ) {
            accs.addError('You are your limit of Accounts.');
        }
    }
}

But I noticed it only goes by the logged in user.  Is there a way to update the trigger so it limits the Protected Accounts regardless of the user?

 
I have the following Trigger created which counts contacts that have Do not Email as true and Undeliverable as false.

User-added image

But I want to change it so the count actually looks at Do not Email is false and Undeliverable is false.  How can I alter the above trigger to look at both check box being false, and only counting contacts that do not have them checked off?

Thanks for your help in advance
I am trying to limit the number of Accounts per user that have the custom field "Protected" checked off.  I created the following trigger and tested it out on sandbox but it doesn't seem to be working.

User-added image
Showing Full Dashboard on Home Page
I am trying to show the full dashboard vs preview on the Home Page Tab.

I created a VF page with the following:

<apex:page showheader="false" sidebar="false"> <apex:iframe src="/01Z14000000kQBw?isdtp=nv" scrolling="true" height="1000px" width="100%"/> </apex:page>

where the bolded is the Dashboard ID (everything after the "/" in the Dashboard URL)
When I go to preview it however, it's just a blank page.

any idea what could be wrong?


I also tried created a VF with the following:
User-added image


However the reports names do not show up, so I am able to differentiate each reports, is it possible to add the name?
Hello,

Is there a way to edit the Opportunity's Stage (picklist field) or any other from the Account's Related list? I have done it for check mark fields using JavaScript.  

Even adding a button that picks the next or previous value on the pick list (like an up down button) would be helpful.

Thanks for any help in advanced
 
I am trying to create a field which would count number of activities starting August 1, 2016.  However, I would want it to stop counting once 'Specific' field within Activities is selected as Conversation.

What I am trying to accomplish is having 7 touches (emails, voicemails, dials) one one Account labelled Type = Top X.  Once 7 touches and a conversation did NOT take place, I would remove these Accounts from the bucket and place it under different one Type = Nurture.  
But before or on the 7th touch, if a conversation did take place (Specific = Conversation), I want to keep them under the Top X Bucket.  

Changing the bucket I can do manually, but I do require the counter field.  
Is this possible to do with APEX?  I have created counter field before, but I have never done something with a date and the counter stopping at a specific time.

Any help is appreciated!
I want to create a custom field where the most recent activity could be stamped there, I would like this on the Account level.  

This way I can run an Account report and see the most recent activities as well.

Could someone help me creating a trigger for this?

I have a custom field on the Lead object, that captures the lead's email domain and inserts it there.  Is there a way to make it so it does not underline?

Here's the formula that I've used on the custom field:

IF(NOT(ISBLANK(Email)),RIGHT(Email,LEN(Email)-FIND('@',Email)),null)

Currently my field looks like this:
User-added image

I want it to look like this
User-added image

we are syncing over leads from marketo to salesforce, and I am getting the following error:

CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY: mkto_si.RemoveInterestingMomentLinebreaksContact: System.LimitException: Apex CPU time limit exceeded 

I looked at the installed package, but the Apex  coded is "Managed" so I unable to see it.

Anyone know how to bypass or fix it?
I have a bunch of new Contacts without an Account name field.  However, I have a custom field on the Contact Level called email Domain; how can I create a WF or trigger, where if the custom field Email Domain matches then the Account Name should be the same as well.

For Example
I have: 

Name:Bruce Wayne                                       
Account: Wayne Enterprise
Email Domain: abcinc.com

IF
Name: Clark Kent
Account: (blank)
Email Domain: abcinc.com

Then for Contact Clark Kent then Account = Wayne Enterprise.

 
Could someone help me create a trigger for Lead Conversion based on the criteria below;

Basically, I have a custom field called Email Domain in the Lead object and the Account Object.  I want Leads that have specifically have Lead Status as Open to convert to a Contact into the Account where that custom 'Email Domain' fields both match.
I have a custom field on the Lead level called Email Domain, as well as on the Account level.  
Can someone help me create a trigger, where any Leads that have Lead Status = Open are converted as Contacts into Accounts if the Email Domain field on the Lead and Account matches.

For Example;
Lead
Name - John Smith  
Lead Status - Open
Email - j.smith@abc.com
Email Domain - abc.com

Account 
Account Name - ABC
Email Domain - abc.com

Then the Lead John is converted into a Contact that belongs to Account ABC
I want to create a custom field that parses the domain of an email and inserts it in there through a trigger.  Could someone help me create that trigger please?

i.e. if Leads email is jonsmith@abc.com    then custom field = abc.com 
I have Marketo pushing in Leads into Salesforce, and there are about 7000 leads.  

I want to only conver Leads with the Leads Status = Open, into contacts based on their email domain.  

So for example if a Lead has an email jonsmith@apple.com, and I have an Account which has contacts emails as xx@apple.com;  I want jonsmith@apple.com to convert to a contact into that specific Account.

Is that possible to do?
I currently have this trigger which counts contacts within an account that are marked as Primary contacts:

trigger PrimaryContactCount on Contact (after insert, after delete, after undelete, after update) {
    set<Id> accIds = new set<Id>();
    
    if(trigger.isinsert || trigger.isUpdate || trigger.ISundelete){
        for(Contact con: Trigger.new){
        if(Trigger.isInsert || Trigger.isUndelete || (con.Primary_Contact_del__c !=Trigger.oldMap.get(con.Id).Primary_Contact_del__c))
            accIds.add(con.AccountId);
            }
            }
            
            if(trigger.isUpdate || trigger.isDelete) {
            for(Contact con: Trigger.old){
            if(trigger.isDelete || (con.Primary_Contact_del__c != Trigger.oldMap.get(con.ID).Primary_Contact_del__c))
            accIds.add(con.AccountId);
            }
            }
            
            List<Account> accList = [select id, Number_of_Primary_Contacts__c, (Select Id, Primary_Contact_del__c from Contacts) from Account Where ID IN: accIds];
            
            for(Account acc : accList){
            system.debug('Contacts--->'+acc.contacts.size());
            acc.Number_of_Primary_Contacts__c = 0;
            for(Contact con : acc.Contacts) {
            if(con.Primary_Contact_del__c)
            acc.Number_of_Primary_Contacts__c++;
            }
            }
            update accList;
            }

Each contact also has a Do Not Email checkbox, is it possible to alter the trigger so it only counts the Primary Contact when the Do Not Email check box is False.
I want to create a check box field (let's call it  TestABC), which will be on true based on the below criteria;

I have two checkbox fields on the Contact object - Primary Contact & Do Not email (these fields also show up on the Contact Related List on the Account object)

TestABC = True if (Primary Contact is true and Do Not Email is false)

I want this TestABC field on the Account level, and look through all the contacts associated with the account to validate the formula.

Is this possible with a trigger?  Could someone help me write such Trigger?

 
I have a checkbox field called "Primary Contact" on the account level.

This field also shows up on the Contact Related list on the Account Object.

I want to create a custom field on the Account object, which counts and tells me how many contacts have "Primary Contact" box checked.

Could someone help me with the trigger to create that please?
Good Day!

Is there a way to take the '@company.com' portion of the email from the contact level and auto fill it to a custom field in the account level?
I have a custom number field on the Contact level (let's call it ABC), and I want to create a Field on the Account to show the total of all the ABC fields from all related Contacts to an Account.  Can this be done without triggers?

I am trying to Limit the number of Protected Accounts a User should have under their ownership.  This is the trigger I created with the help of the SFDC Community 

trigger Limit1000AccountsForUsers on Account (before insert, before update) {
    Account accs = Trigger.new[0];

    if (accs.Protected_Accounts__c == true) {
        Integer accounts = [ SELECT COUNT()FROM Account WHERE Account.OwnerId = : userInfo.getUserId()]; 
        system.debug(accounts);

        if (accounts >3 ) {
            accs.addError('You are your limit of Accounts.');
        }
    }
}

But I noticed it only goes by the logged in user.  Is there a way to update the trigger so it limits the Protected Accounts regardless of the user?

 
I am trying to limit the number of Accounts per user that have the custom field "Protected" checked off.  I created the following trigger and tested it out on sandbox but it doesn't seem to be working.

User-added image
Showing Full Dashboard on Home Page
I am trying to show the full dashboard vs preview on the Home Page Tab.

I created a VF page with the following:

<apex:page showheader="false" sidebar="false"> <apex:iframe src="/01Z14000000kQBw?isdtp=nv" scrolling="true" height="1000px" width="100%"/> </apex:page>

where the bolded is the Dashboard ID (everything after the "/" in the Dashboard URL)
When I go to preview it however, it's just a blank page.

any idea what could be wrong?


I also tried created a VF with the following:
User-added image


However the reports names do not show up, so I am able to differentiate each reports, is it possible to add the name?
I am trying to create a field which would count number of activities starting August 1, 2016.  However, I would want it to stop counting once 'Specific' field within Activities is selected as Conversation.

What I am trying to accomplish is having 7 touches (emails, voicemails, dials) one one Account labelled Type = Top X.  Once 7 touches and a conversation did NOT take place, I would remove these Accounts from the bucket and place it under different one Type = Nurture.  
But before or on the 7th touch, if a conversation did take place (Specific = Conversation), I want to keep them under the Top X Bucket.  

Changing the bucket I can do manually, but I do require the counter field.  
Is this possible to do with APEX?  I have created counter field before, but I have never done something with a date and the counter stopping at a specific time.

Any help is appreciated!
we are syncing over leads from marketo to salesforce, and I am getting the following error:

CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY: mkto_si.RemoveInterestingMomentLinebreaksContact: System.LimitException: Apex CPU time limit exceeded 

I looked at the installed package, but the Apex  coded is "Managed" so I unable to see it.

Anyone know how to bypass or fix it?
I have a bunch of new Contacts without an Account name field.  However, I have a custom field on the Contact Level called email Domain; how can I create a WF or trigger, where if the custom field Email Domain matches then the Account Name should be the same as well.

For Example
I have: 

Name:Bruce Wayne                                       
Account: Wayne Enterprise
Email Domain: abcinc.com

IF
Name: Clark Kent
Account: (blank)
Email Domain: abcinc.com

Then for Contact Clark Kent then Account = Wayne Enterprise.

 
I want to create a custom field that parses the domain of an email and inserts it in there through a trigger.  Could someone help me create that trigger please?

i.e. if Leads email is jonsmith@abc.com    then custom field = abc.com 
I want to create a check box field (let's call it  TestABC), which will be on true based on the below criteria;

I have two checkbox fields on the Contact object - Primary Contact & Do Not email (these fields also show up on the Contact Related List on the Account object)

TestABC = True if (Primary Contact is true and Do Not Email is false)

I want this TestABC field on the Account level, and look through all the contacts associated with the account to validate the formula.

Is this possible with a trigger?  Could someone help me write such Trigger?

 
I have a checkbox field called "Primary Contact" on the account level.

This field also shows up on the Contact Related list on the Account Object.

I want to create a custom field on the Account object, which counts and tells me how many contacts have "Primary Contact" box checked.

Could someone help me with the trigger to create that please?